Commit graph

15 commits

Author SHA1 Message Date
jenkins-bot ef4c537d9e Merge "Fix skins option to use currently displayed skin, rather than user preference" 2018-08-03 18:53:39 +00:00
Matt Russell b340532c52 Fix skins option to use currently displayed skin, rather than user preference
The user's preference usually reflects the displayed skin, however this isn't
true if the `useskin` URL query is set, or MobileFrontend is being used.

This fixes gadgets being displayed on the wrong skin when using `useskin`,
and allows mobile-specific gadgets (using `skins=minerva`).

Testing if the gadget is allowed in the current skin is split out from
`isAllowed` to `isSkinSupported` to enable a future patch showing gadgets
on preferences regardless of if they are allowed on the current skin.
Test coverage is added for both functions.

Also fixed another test which wasn't working, presumably because the placeholder
user didn't have the "read" right, so the section wasn't being kept.

Bug: T199478
Change-Id: I21febe92d54d6d0b89925f902581cc2739d824fb
2018-08-01 11:06:17 +10:00
Thiemo Kreuz bede1c0178 More loose @covers annotations in GadgetTest
This is more an integration test than anything. The @covers tags I found
are to strict, in my opinion. These test cases cover more code.

Change-Id: I6cef7ce0c612ac3dfbb855c495032df1fe96f4af
2018-07-31 18:38:26 +02:00
Kunal Mehta 677d4e932c Move classes into includes/
Change-Id: I10bc5234ad2ebeed2514aafc3dbe2a0afa983bd8
2018-02-25 11:19:23 +00:00
Timo Tijhof eabfab52e0 tests: Add @covers tags
Change-Id: Ia3e18e7149292cd23765636111acc846564bf6cc
2018-01-05 00:11:10 +00:00
Umherirrender f102194baf Add phpcs and make pass
Change-Id: I02b7f85f54ffaf8a1c9d5bed6fa20abb1627afe5
2017-05-31 16:36:45 +02:00
Thiemo Mättig 6b22f1089e Use …->assertArrayHasKey() instead of isset()
… as well as update a line of documentation I had stashed. I think this
does not need it's own patch, or does it?

Change-Id: I99eee1f7b5ec96c1c75e73d66200bc41807452fa
2017-05-31 07:52:18 +00:00
Timo Tijhof 3dd92c6f76 Remove duplicate loading of styles (assume type=general if content is mixed)
Follows-up dc834f3, dc4ea6c.

Bug: T92459
Bug: T42284
Change-Id: I94dbdb052a78bbbc3c1b7b8bb8805a5f327670d9
2017-05-12 21:44:42 +00:00
Gergő Tisza b5befcbbe2 Switch TestingAccessWrapper to librarized version
Bug: T163434
Change-Id: I493d9b28d2c0d265e003a9851746eb07c7d15770
Depends-On: I52cc257e593da3d6c3b01a909e554a950225aec8
2017-04-20 11:35:09 +00:00
Fomafix 1a569b590b Convert PHP syntax from array() to []
Performed using:
find . -name \*.php -exec php ~/convert.php -w "{}" \;

Script from:
https://github.com/thomasbachem/php-short-array-syntax-converter

And convert syntax in comments manually.

Change-Id: I7ea9e57f9ab1250c8687885ad9e010771603bf78
2016-12-28 13:51:30 +01:00
Timo Tijhof 27a0ca6568 Implement support for 'hidden' feature in MediaWikiGadgetsDefinitionRepo
Follows-up 152484566, which added support for it in Gadgets 2.0, but
it's easy enough to make it work in existing definitions as well.

That way, people can stop using 'rights=hidden' hacks.

Bug: T33150
Change-Id: Idd6944a9ad38279e117c1a02a4b5fd0343455ba0
2016-11-22 23:46:38 +00:00
Timo Tijhof 846b979578 Remove redundant 'position', 'top', and getPosition() code
Unused as of bc374082fa in MediaWiki core (T109837).

Change-Id: Idcec3c4fa2bc3bc05ac417062139794880040a6d
2016-11-18 13:55:30 -08:00
Timo Tijhof 906aaeeb82 Default to type=general for styles-only gadgets having dependencies
Bug: T147726
Change-Id: I4153851b0e2f5cc067b1f31a7cd80f73d0620d7c
2016-11-16 17:53:10 -08:00
Timo Tijhof dc834f3933 Implement support for specifying type=styles
T87871 formally introduced the concept of a styles module,
which sets mw.loader.state to "ready" when loaded through addModuleStyles().

Previously, addModuleStyles couldn't safely do that because a module may
contain scripts also, in which case mw.loader must still load the (rest)
of the module (causes styles to load twice).

In MediaWiki core or extensions this is easily avoided by calling not
calling both addModules() and addModuleStyles().

For Gadgets we call both as a workaround to allow users to provide styles
(without a FOUC), but also to provide scripts+styles. Since we don't declare
which one is intended (and some gadgets do both), we loaded them both ways.
This will no longer be allowed in the future (see T92459).

The new 'type=styles' Gadget attribute promises to ResourceLoader that a
gadget only contains styles.

Impact:

* [Bug fix] When mw.loader requires a styles module that already loaded,
            it will not load again.

* [Feature] It is possible for a general scripts+styles gadget to depend on
            a styles gadget. Previously this caused the styles to load twice.

* Specifying type=styles will load the module through addModuleStyles() only.

  Use this for modules that contain styles that relate to elements already
  on the page (e.g. when customising the skin, layout, or article content).

* Specifying type=general will load the module through addModules() only.

  Use this if your module contains both scripts and styles and the styles
  only relate to elements created by the script. This means the styles do not
  need to be loaded separately through addModuleStyles() and will not apply
  to noscript mode.

Effective difference:

* Gadgets with only styles: We assume type=styles.

  This fixes the main bug (styles loading twice) and requires no migration!

* Gadgets with only scripts: We assume type=general.

  This requires no migration! (And: No more empty stylesheet request)

* Gadgets with scripts (with or without styles): We assume type=general, but
  unless type=general was explicitly set we'll still load it both ways so
  that the styles apply directly on page load.

  If this is not needed, set type=general.

  If this is needed, it should become two separate modules. We do not support
  a single module having two purposes (1: apply styles to the page,
  2: provide scripts+styles). The styles module should be separate.
  It can be made hidden, and listed as dependency of the other module.

The latter case is detected on page load and results in a console warning
with a link to T42284.

Bug: T42284
Bug: T92459
Change-Id: Ia3c9ddee243f710022144fc2884434350695699a
2016-09-30 10:43:29 +00:00
Reedy 34795a8803 Remove 'UnitTestList' hook
No longer needed now that extension unittests are autodiscovered.

Bug: T142120
Bug: T142121
Change-Id: I89cfc1ea3e652ebec1cd67f62810586c4ef49574
2016-08-06 01:14:53 -07:00