resourceloader: Implement "skip function" feature
authorTimo Tijhof <krinklemail@gmail.com>
Wed, 30 Apr 2014 21:06:51 +0000 (23:06 +0200)
committerTimo Tijhof <krinklemail@gmail.com>
Thu, 12 Jun 2014 01:48:26 +0000 (03:48 +0200)
commit75c08916b02ac87066f6b7a5549f3f72d757ee86
tree798adfb408a25aa5bf85b36fc0501e734dcc55c3
parenta41cd4d6c478092ba77c3db582b23cbfd738f155
resourceloader: Implement "skip function" feature

A module can be registered with a skip function. Such function,
if provided, will be invoked by the client when a module is
queued for loading. If the function returns true, the client will
bypass any further loading action and mark the module as 'ready'.

This can be used to implement a feature test for a module
providing a shim or polyfill.

* Change visibility of method ResourceLoader::filter to public.

So that it can be invoked by ResourceLoaderStartupModule.

* Add option to suppress the cache key report in ResourceLoader::filter.

We usually only call the minifier once on an entire request
reponse (because it's all concatenated javascript or embedded
javascript in various different closures, still valid as one
large script) and only add a little bottom line for the cache
key. When embedding the skip function we have to run the minifier
on them separately as they're output as strings (not actual
functions). These strings are typically quite small and blowing
up the response with loads of cache keys is not desirable in
production.

* Add method to clear the static cache of ResourceLoader::inDebugMode.

Global static state is evil but, as long as we have it, we at
least need to clear it after switching contexts in the test suite.

Also:
* Remove obsolete setting of 'debug=true' in the FauxRequest in
  ResourceLoaderTestCase. It already sets global wgResourceLoaderDebug
  in the setUp() method.

Bug: 66390
Change-Id: I87a0ea888d791ad39f114380c42e2daeca470961
RELEASE-NOTES-1.24
includes/resourceloader/ResourceLoader.php
includes/resourceloader/ResourceLoaderFileModule.php
includes/resourceloader/ResourceLoaderModule.php
includes/resourceloader/ResourceLoaderStartUpModule.php
resources/src/mediawiki/mediawiki.js
tests/phpunit/ResourceLoaderTestCase.php
tests/phpunit/includes/resourceloader/ResourceLoaderStartupModuleTest.php
tests/qunit/data/load.mock.php
tests/qunit/suites/resources/mediawiki/mediawiki.test.js