When running the whole JavaScript test with the flag noglobals it reports:
mediawiki.jqueryMsg: formatnum (2, 14, 16) Introduced global variable(s): pluralRuleParser
When rerun the problematic test the error does not occur.
When running the whole JavaScript test with the flag noglobals it reports:
mediawiki.jqueryMsg: formatnum (2, 14, 16) Introduced global variable(s): pluralRuleParser
When rerun the problematic test the error does not occur.
Subject | Repo | Branch | Lines +/- | |
---|---|---|---|---|
Use mw.libs.pluralRuleParser directly | mediawiki/extensions/UniversalLanguageSelector | master | +3 -8 |
Change 190446 had a related patch set uploaded (by Gerrit Patch Uploader):
Use mw.libs.pluralRuleParser directly
The test complains because the global appears half-way through the test suite, long after all source dependencies have been loaded. That is the problem.
The check indicates an unknown global appeared within the test execution. That can mean either, 1) a new variable was created and accidentally let to be global due to omission of a var statement), or 2) It was meant to be global, but created too late.
In this case it's case #2. This code very intentionally (window means global) makes it a global variable. The problem is merely it appearing too late (tests shouldn't create new global variables).
Note that this check is optional and not enabled at the moment (QUnit: checkbox "Check for globals"). It'd be nice, but not a major issue.
When QUnit re-runs tests, it remembers which failed last time and runs those first.
Since this global is likely introduced by an asynchronous request, the individual assertion that first noticed this global probably isn't loading the global itself. As such, when re-running only that one test, the global doesn't appear. When re-running all tests, it appears again.
Change 190446 abandoned by Nikerabbit:
Use mw.libs.pluralRuleParser directly
Reason:
This issue needs different approach. See the bug for more details. This patch has not moved for a long time.
I can't reproduce this anymore. It was most likely fixed due to ensuring dependencies load in the right order, thus pluralRuleParser now exists before QUnit creates the snapshot of "allowed" globals, as it should.