Commit graph

26 commits

Author SHA1 Message Date
Timo Tijhof
e03380c714 ResourceLoader: Fix content-links compat
This never worked because it looked for `element` instead of `elements`.
The test repeated the same mistake.

Bug: T278576
Bug: T255717
Change-Id: I9bfceb6b8bd761244af6eda0e2ae08e98238aa76
2024-09-17 03:22:14 +00:00
Timo Tijhof
123da635a1 ResourceLoader: Fix SkinModule aliases to not override existing keys
While not documented or tested, aliases previously not only adding
but also replaced values.

Instead, emit a warning to inform skin developers of this conflict.

Note that the `content-links => elements` alias already behaves
this way (only if not already set), which the other aliases would
now be consistent with.

Change-Id: I66ae66b37bba14b2f65710f3d32f17d4e9a5a7a3
2024-09-17 03:22:04 +00:00
Timo Tijhof
3d924e4ed1 ResourceLoader: Minor doc blocks and coding style cleanup
* Function alls are either complete on one line or one arg
  per line. Avoid confusing calls where the args are on their
  own line as this creates visual ambiguity over how many args
  are passed, and what each piece belongs to. For example, is
  `true` or `false` passed as 2nd arg to applyFeaturesCompatibility?

* Replace comment about list-form behaviour with something that
  provides intention and insight instead of merely repeating what
  can already be seen from the code.

* Fix malformed `@param` docs that used variable as part of sentence.

* Use named data providers to ease PHPUnit debugging,
  and to make code coverage reports on doc.wikimedia.org more useful.

Change-Id: I2efd6cc7ac59c80684c9411025c4226473a36d43
2024-09-17 03:20:15 +00:00
Timo Tijhof
3ee96d47b6 ResourceLoader: Reduce deprecation clutter in SkinModule
* Move docs for deprecated aliases from top-level mentions into
  footnotes under primary docs. Still easy to search for, but no
  longer advertised as important for skin devs to know about
  or scan past when reading.

* Fix bug in 'legacy' logic where the key was not unset, thus
  mandating a needless entry in FEATURES constant. With the bug
  fixed, this internal entry is no longer needed.

* Fix bug in 'interface' logic where the key was not unset
  when the value is false. This would break the "skins.vector.styles"
  module otherwise, and had a similar workaround in place that
  is now no longer needed.

* Remove other unneeded entries in FEATURES for keys that were
  already being unset by applyFeaturesCompatibility().

* Remove deprecation warnings in favour of letting ResourceModules
  give a stable interface from ResourceLoader to skin.json.

* Add missing test to confirm no-op behaviour.

Bug: T374262
Change-Id: I9f4b1d48127d0afe67bada44d8dc4472507f9506
2024-09-16 20:17:34 -07:00
thiemowmde
4bd95cd96b Use MainConfigNames constants in tests where possible
I believe this makes the code less brittle, and also makes it a bit
more obvious what these strings are meant to represent.

Change-Id: Ia39b5c80af4b495931d0a68fd091b783645dd709
2024-07-10 10:11:22 +00:00
Umherirrender
f3524224f0 build: Fix line indents
Fixed SkinModuleTest::provideGetFeatureFilePathsOrder as nesting of
arrays for parameters is wrong

Change-Id: I9875008adf62d284c48662ebfbd245d72e5be064
2024-03-11 00:14:16 +01:00
Jan Drewniak
9b3a215975 Output skin related styles after SkinModule feature styles
Changes SkinModule::getStyles to output config features
first, then skin customization styles last. This requires
using the ResourceLoader::makeCombinedStyles method to
first combine feature styles, then combine style related styles,
and return the concatenated result in SkinModule::getStyles().

The resulting stylesheet ordering is changed so that all
skin customization styles are always output after core styles,
which allows skins to override core-styles via cascade order instead
of increased specificity.

Previous output order:
- all (core+custom)
- print (core+custom)
- screen (core+custom)
- other custom

New output order:
- all (core)
- print (core)
- screen (core)
- other (core)
- all (custom)
- print (custom)
- screen (custom)
- other (custom)

SkinModule is refactored to separate logo-related style
generation, as well as skin feature generation, in order to maintain
testability. Tests are also refactored to better cover different
skin feature configurations.

Bug: T354975
Change-Id: I261742c0ae4c3d57353bf1854af66f39df6132f7
2024-02-29 11:56:57 -05:00
Esanders
9783ee9482 Revert "SkinModule - Ensure skins can easily override skin feature styles"
This reverts commit afdc92987f.

Also reverts Ib44687b which was a follow-up.

Reason for revert: Caused T357929

Bug: T357929
Bug: T354975
Change-Id: Ic6d0b472cc2b26cb7c375bf9a5d2e03a4d6c6a18
2024-02-19 18:52:53 +00:00
James D. Forrester
d6fd1436a3 tests: Namespace ResourceLoaderTestCase and friends
Leave class aliases behind because they might be being used somewhere,
but we don't normally flag these kinds of things in the release notes,
do we?

Bug: T357823
Change-Id: I7fc7f34494d5c4df81f6746d63df1d0f990f8ae9
2024-02-16 21:32:22 +00:00
jenkins-bot
70942c2378 Merge "SkinModule - Ensure skins can easily override skin feature styles" 2024-02-15 00:21:29 +00:00
Jan Drewniak
afdc92987f SkinModule - Ensure skins can easily override skin feature styles
Reorders ResourceLoader\\SkinModule style output so that all styles
produced by skins are output after styles that are produces by
skin "features" such as normalize.

Refactors & expands SkinModuleTest.php to include tests for default
values, print styles and correct style ordering.

Bug: T354975
Change-Id: I0000b4ad8eb2de40be293f0e693d873c282ea785
2024-02-14 17:44:01 -05:00
Amir Sarabadani
167fbd0a20 Drop deprecated config $wgLogoHD
It has been deprecated since 1.35, hard deprecated since at least I9776d11d4e2d184

No grep result in wmf-config

Change-Id: I2c67bab3e3212f25a0cbce7301f5e32a082f76da
2024-01-24 19:46:04 +01:00
James D. Forrester
c1599c91b3 Namespace Config-related classes under \MediaWiki\Config
Bug: T166010
Change-Id: I4066885a7ea071d22497abcdb3f95e73e154d08c
2023-09-21 05:41:58 +00:00
Jan Drewniak
2eedee7974 Create mediawiki.tempUserBanner module
Creates a new resourceLoader module which holds the
scripts and styles related to the temp user (IP masking) banner
described in T339379.

The temp user banner includes a tooltip which explains
what temporary accounts are. This is built using OO.ui.PopupWidget
and includes a clock icon and parsed i18n messages.

The Tooltip dependencies are loaded and instantiated on a click event
in order to minimize the dependencies on page load.

Bug: T339379
Change-Id: Ie2631221b0a07dd3bf55e970805d30fbb3cac190
Depends-on: Id5a4a9a00e50420c50868c54f899d36d7ddd373d
Depends-on: Icf622c4be910f5d14de95355efa02c05930179bf
2023-06-30 00:41:46 +00:00
Umherirrender
580439e604 tests: Use MainConfigNames consts to refer config names
PasswordSalt was dropped in 2e909bcb

Change-Id: I58d2b8d4e2a235afdc8054eafdea4e85b61f03c1
2023-06-19 20:21:08 +00:00
Jan Drewniak
62196c2fa1 Create new TempUserBanner skin component
Creates a new skin component for informing users with
temporary accounts that they can login or register if they choose.

Adds:
- New skin component: SkinComponentTempUserBanner.php
- Skin feature: "temp-user-banner"
- Associated styles
- New i18n messages for banner

NOTE: This component is not registered via the skinComponentRegistry
because it doesn't output any data, only a string of HTML.
Instead it is appended to the body element before the skin is rendered.

Bug: T330510
Change-Id: I1e137dbd29f3c73efac901f43f8a8258e2a111fc
2023-06-16 16:50:06 +00:00
Tim Starling
25d0d37adc ResourceLoader: tweak comments and error messages
Change-Id: Ifcaefedf65b090a87ec1417808277ae6451302dc
2023-04-03 18:21:30 +10:00
Tim Starling
5e30a927bc tests: Make some PHPUnit data providers static
Just methods where adding "static" to the declaration was enough, I
didn't do anything with providers that used $this.

Initially by search and replace. There were many mistakes which I
found mostly by running the PHPStorm inspection which searches for
$this usage in a static method. Later I used the PHPStorm "make static"
action which avoids the more obvious mistakes.

Bug: T332865
Change-Id: I47ed6692945607dfa5c139d42edbd934fa4f3a36
2023-03-24 02:53:57 +00:00
Bartosz Dziewoński
d3c64c5ce6 ResourceLoader: Remove SVG fallback hack from SkinModule
Bug: T329127
Change-Id: I28c02efc137c3a9ceacdc07366ac374c70b0fb7e
2023-02-08 00:32:52 +00:00
Jon Robson
ac389cf0f0 ResourceLoaderSkinModule: Split up interface feature into multiple parts
While working on the site notice in Vector we've noticed these
styles are proving more problematic than helpful so splitting these
up allows us more granularity in the styles we ship.

The core interface styles are now enabled by default as they contain
important logic relating to empty portlets and the print footer

Bug: T316027
Change-Id: Ib5ae640bb260cee46e654228b785c776722c7003
2022-08-24 13:59:17 +00:00
Timo Tijhof
11f729301b ResourceLoader: Hoist and simplify @covers in test cases
I consider it busywork to maintain this, for no tangible benefit.
Limiting the credited coverage to a class is limiting enough to
exclude unintended coverage from reports. Especially as this
helps ensure tracking coverage correctly for implementation details
such as helper methods and internal methods that do not warrant
their own test as that would defeat the purpose of tests exercising
the contract and demonstrating good usage.

Change-Id: Icf865f15cbd86585bbc02fc4943a960efb40c0eb
2022-08-23 23:59:17 +00:00
Thiemo Kreuz
02971ace54 Remove confusing ->onlyMethods( [] ) with empty array from tests
Calling ->onlyMethods( [] ) with an empty array does have an effect.
By default, all methods are mocked, which means the original code is
not called. Calling ->onlyMethods( [] ) turns this around. No methods
are mocked but all call the original code.

This is almost the same as ->enableProxyingToOriginalMethods(). The
difference is that ->enableProxyingToOriginalMethods() also requires
the original constructor to be called, but ->onlyMethods( [] ) does
not.

We can get rid of this confusing setup in tests that don't need it.
All tests in this patch that succeed with a simple ->createMock()
just demonstrated that they don't need it.

Change-Id: I341323a1ca793c039498f80b7f073c124b6b6ae0
2022-08-08 15:49:59 +02:00
Thiemo Kreuz
61ae7504df Replace trivial usa of mock builder with createMock() shortcut
createMock() does the same, but is much easier to read.

A small difference is that some of the replacements made in this
patch didn't use disableOriginalConstructor() before. In case this
was relevant we should see the respective test fail. If not we can
save some CPU cycles and skip these constructors.

Change-Id: Ib98fb06e0fe753b7a53cb087a47e1159515a8ad5
2022-07-15 16:43:48 +00:00
Tim Starling
3e2653f83b ResourceLoader namespace (attempt 2)
Move ResourceLoader classes to their own namespace. Strip the
"ResourceLoader" prefix from all except ResourceLoader itself.

Move the tests by analogy.

I used a namespace alias "RL" in some callers since RL\Module is less
ambiguous at the call site than just "Module".

I did not address DependencyStore which continues to have a non-standard
location and namespace.

Revert of a241d83e0a.

Bug: T308718
Change-Id: Id08a220e1d6085e2b33f3f6c9d0e3935a4204659
2022-05-24 15:41:46 +00:00
Lucas Werkmeister (WMDE)
a241d83e0a Revert "ResourceLoader namespace"
This reverts commit e08ea8ccb9.

Reason for revert: Breaks Phan in extensions, and as far as I’m aware,
this change isn’t urgently needed for anything, so the simplest fix is
to revert it again for now. After PHP 7.4 it should be safer to try this
again (we hopefully won’t need the two “hack” classes by then).

Bug: T308443
Change-Id: Iff3318cbf97a67f821f78e60da62a583f63e389e
2022-05-16 14:43:33 +00:00
Tim Starling
e08ea8ccb9 ResourceLoader namespace
Move ResourceLoader classes to their own namespace. Strip the
"ResourceLoader" prefix from all except ResourceLoader and
ResourceLoaderContext.

Move the tests by analogy.

I used a namespace alias "RL" in some callers since RL\Module is less
ambiguous at the call site than just "Module".

I did not address DependencyStore which continues to have a non-standard
location and namespace.

Change-Id: I92998ae6a82e0b935c13e02a183e7c324fa410a3
2022-05-16 14:41:27 +10:00
Renamed from tests/phpunit/includes/resourceloader/ResourceLoaderSkinModuleTest.php (Browse further)