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
This will help with improving human readability of JS and JSON
objects encoded by both ResourceLoader and the API. This patch
also adds new "utf8" parameter to the JSON formatter of the API.
Changes to FormatJson class:
* Added escaping of '<', '>', and '&' by default to protect against XSS.
* Removed unnecessary escaping of '/' and added an additional option to
unescape non-ASCII characters (those above U+007F) as well.
* Added PHP 5.3 pretty printing code (to replace Services_JSON) that
uses a four-space indent as PHP 5.4 does.
Changes to Xml class:
* Defined Xml::encodeJsVar() in terms of FormatJson::encode()
and added a pretty printing option. Also added a pretty printing
option to Xml::encodeJsCall() as well.
* Deprecated Xml::escapeJsString() and QuickTemplate::jstext();
callers have to add quotes themselves, hence the escaping of
both double quotes and apostrophes.
Bug: 26818
Change-Id: I1987190f1ba5bf41738e7bd611209706c1f6bb5c
· Use env(1) in shebangs instead of hardcoding paths.
· $IP is already set in the constructor of Maintenance classes.
· Add sapi guard to some phpunit files.
Change-Id: I6c6fd6c61e2861b5992f2ccd67a4e3f62e2c445e
* testloader.php was resolving dependencies when it shouldn't
the server *never* does that. That's handled by the client, which
knows the state of what is and isn't module.
Due to a race condition between:
- handlePending() call from loader.state() call for
load.phpmodules?=testMissing
- asynchronous callback from mw.loader.using as dependencies
are being resolved.
It didn't expose any actual problem, the unit test was simply
assuming that they would arrive in a certain order, when that isn't
the case by design.
Random failures are seen here:
- https://integration.mediawiki.org/testswarm/user/mediawiki/
- http://integration.wmflabs.org/testswarm/job/4
> Module "test.missing" must have state "missing"
> - "missing"
> + "loading"
-> Because callback was triggered from mw.loader.state() already
it didn't get to the implement() call yet.
> Module "test.use_missing" must have state "error"
> - "error"
> + "loading"
-> (same reason)
This is now fixed.
* Greatly simplified the mock load.php
Change-Id: I000ee726a062f6c6d630ad6c07cfc0b48d145d35