Commit graph

129 commits

Author SHA1 Message Date
James D. Forrester
5a622b6a2e build: Upgrade eslint-config-wikimedia from 0.17.0 to 0.18.1
Change-Id: I5e3687be2b197134578126e1b890ee37dbc1bc1b
2021-02-18 08:39:09 -08:00
Santhosh Thottingal
ce8d0e9599 Update formatNum implementation to match tr35 and latest CLDR
* Update digitGroupingPattern to match CLDR 31: New versions of CLDR has
  digit grouping pattern with decimal part. Update digitGroupingPattern
  values in Message classes with this improved pattern.
  Refer: http://unicode.org/reports/tr35/tr35-numbers.html

* Refer the following chart for the decimal patterns.
  http://www.unicode.org/cldr/charts/31/by_type/numbers.number_formatting_patterns.html

* Uses PHP NumberFormatter class for the commafy implementation, which
  is available in PHP 7.

* Some tests need to update to match the TR 35 spec

* The formatNum public method in Language.php is the preferred way to
  use this feature. It does separator transformation and digit transformation
  wherever applicable.

* Renamed the second param name for formatNum from noCommafy to noSeparators

* commafy method is deprecated and formatNum is preferred. Practically,
  we are not just adding comma, but seperators according to the language.
  Replaced some tests based on commafy methods with tests based on formatNum.

Note: The corresponding js implementation is not changed in this commit.
It would probably be a good idea to use globalize.js, which is also based
on the CLDR patterns.

Note: This patch preserves the existing off-by-one error in
$minimumGroupingDigits; T262500 will eventually fix this.

Bug: T167088
Co-Authored-By: C. Scott Ananian <cscott@cscott.net>
Change-Id: Ic721b9a91e78e4ef07040339d1006b7a90a910c0
2020-10-21 10:08:04 -04:00
Ed Sanders
cb5e67844d QUnit tests: Avoid variable shadowing
Change-Id: I632458ff6fd3b5a4962359d782df0ae951594092
2020-06-24 13:22:33 +01:00
Ed Sanders
ceb2cd2fe8 build: Update eslint-config-wikimedia to 0.16.2
Use jsduck config.

Change-Id: I3a1a0c8f0ca535c9661b3774498866fdb98a4255
2020-06-18 19:12:10 +00:00
Ed Sanders
2743c1ce9f Tests: Autofix ESLint rule exceptions
Change-Id: I7b8b4d7a549dd33315d9a8f96b0d75e1f9ff95b1
2020-06-15 21:55:47 +01:00
Ed Sanders
b845e3707d docs: Add missing @property types and some other missing docs
Change-Id: I000b0741bb729b29562d2f23388b520d414ba16b
2020-06-13 19:53:36 +00:00
Ed Sanders
a0b717fcb0 Documentation fixes for upcoming ESLint config change
Change-Id: I1ca2bf9d31b20317e8f8c5992ebccc4b0a05451a
2020-05-16 20:02:13 +00:00
Timo Tijhof
c0eaa457ef resourceloader: Fix load.mock.php query parameter corruption in tests
=== Observe the bug

1. Run Special:JavaScriptTest
   (add ?module=mediawiki.loader to run only the relevant tests)
2. In the Network panel, check the JS requests to load.mock.php?…
3. Without this patch, they are like:
   "load.mock.php?1234?lang=en&modules=…&…"
   With this patch, they are like:
   "load.mock.php?lang=en&modules=…&…"

The question mark is only valid as the start of the query string,
not as divider between them. This means without this patch, the
"lang" parameter is simply ignored because it becomes part
of the key "1234?lang" with value "en".

=== What

The mock server doesn't do anything with "lang". And given that
RL sorts its query parameters for optimum cache-hit rate, the
corrupted parameter is always "lang", as its sorts before
"module" or "version", which our mock server does utilize.

As part of server-side compression of the startup module (d13e5b75),
we filter redundant base parameters that match the default. For
RLContext, this is `{ debug: false, lang: qqx, skin: fallback }`.

As such, if one were to mock the localisation backend with
uselang=qqx internally, the "lang" parameter will not need to be
sent, and thus the above bug will start corrupting the "modules"
paramater instead, which our test suite correctly detects as being
very badly broken.

=== Why

mediawiki.loader.test.js used QUnit.fixurl() as paranoid way to
avoid accidental caching. This blindly adds "?<random>" to the
url. Upstream QUnit assumes the URL will be a simple file on disk,
not expecting existing query parameters.

=== Fix

* Removing the call to QUnit.fixurl(). It was set by me years ago.
  But, there is no reason to believe a browser would cache this
  anyway. Plus, the file hardly ever changes. Just in case,
  set a no-cache header on the server side instead.

* Relatedly, the export of $VARS.reqBase is an associative array in
  PHP and becomes an object in JSON. Make sure this works even if
  the PHP array is empty, by casting to an object. Otherwise, it
  becomes `[]` instead of `{}` given an PHP php array is ambiguous
  in terms of whether it is meant as hashtable or list.

Bug: T250045
Change-Id: I3b8ff427577af9df3f1c26500ecf3646973ad34c
2020-04-28 16:04:50 +00:00
Timo Tijhof
eabf8afbd8 mediawiki.jqueryMsg: Refactor test suite to not make any API requests
This test was an awful, awful, mess. (And I take full responsibility.)
Changing the global user language mid-way into execution is in no way
supported by ResourceLoader and this test was going through great
lengths to fool mw.loader about what's really going on.

Basically, all we're doing is get a list of instructions on what tests
to run, get comparison values based how the PHP side proceses these
(for parity comparison), and then run the assertions.

The mw.language singleton already has support for multiple languages,
and mediawiki.jqueryMsg already supports injecting data and constructing
new instances for each test case. Make use of that :)

Instead of calling ResourceLoaderLanguageDataModule::getData by
trying to hot load the same module repeatedly from load.php,
just export this data using 'packageFiles'.

The mediawiki.jqueryMsg QUnit suite previously took 4s to run locally
and now only 0.1s (145ms). This is not only significant for this
particular module, but also for QUnit in general as Headless Chrome
only took about 7s to run all of MediaWiki core's test suites prior
to this change, which is now down to ~3s. (MacBook Pro)

For WMF CI:

* Before (master commit):
  - mediawiki.jqueryMsg.test: ~2.1s (2135ms)
  - MediaWiki core total: ~4.8s
* After (this patch):
  - mediawiki.jqueryMsg.test: ~0.015s (15ms)
  - MediaWiki core total: ~3.6s

Bug: T250045
Bug: T225730
Change-Id: I5f1067feb0a43d63bfc5e7fff5110285a5e433c8
2020-04-23 21:59:50 +01:00
jenkins-bot
39e2395bfc Merge "qunit: Add assert.domEqual helper method" 2020-04-23 19:58:20 +00:00
Timo Tijhof
851eb4b9c8 qunit: Use "test.*" module names only for actual test suites
This will make it easy to later allow the user to select which
component's specs to load and run (via CLI and GUI), e.g. for
an entire extension. We currently only have very narrow or very
wide selection mechanisms ('module' param for 1 module,
'rerun' for 1 test case, 'filter' param for global pattern match).

Bug: T250045
Depends-On: I55fe27e1c74972fcb3cdafefdc78e10e24f95b80
Change-Id: I5c01f720d787c3847228de511ce913284786ad66
2020-04-22 21:11:12 +00:00
Timo Tijhof
0f663e9c01 qunit: Add assert.domEqual helper method
Change-Id: I29832f1b883be44220e1a5522ef15adc8e277487
2020-04-22 19:38:39 +01:00
Timo Tijhof
35d02383b9 docs: Remove use of 'jqXHR' and 'mediaWiki' jsduck aliases
The `@alternateClassName` feature does not map cleanly to
JSDoc, so reduce its use to make the migration smoother.

Also, it was my intention to only use `@alternateClassName`
as a way to overcome limitations in JSDuck and/or as a stop-gap
to document hacky or overly clever code, not as a general way
to just randomly have two names for the same thing within docs.

* jqXHR: Just use jQuery.jqXHR instead. Also add missing
  inheritence to Promise.

* mediaWiki: Just use mw instead. It's already discouraged
  in real code, we really don't need to allow it within
  doc typehints.

Bug: T138401
Change-Id: I915f747e440bad8f9bb2c11f35abc32ebdb69247
2020-04-19 21:10:53 +01:00
Ammar Abdulhamid
61ff46196e Use class keyword for classname resolution
Change-Id: I149abf837c6bd79f05648b1acbfaf45dc900125e
2020-03-27 09:33:01 +01:00
Timo Tijhof
d05dfe4736 qunit: Remove use of jquery.getAttrs
Bug: T245894
Change-Id: I0c95f23d7501b6255b2264028163a10f88e1b74b
2020-02-24 16:38:34 +00:00
Ed Sanders
3c2cea4559 build: Update linters and fix errors
Change-Id: Ieb1eff174f5168bf6c9e9aaeb58ec1a1bcd33538
2019-10-23 11:22:41 +01:00
Ed Sanders
a3e3a80329 Always $-prefix jQuery variable names
Change-Id: I82d7788fbd01b73fc8a3255d5af2de75c85279e1
2019-10-08 13:12:17 +01:00
Timo Tijhof
e1c3b04267 resourceloader: Remove my @author comments from unit tests
Previously removed from includes/ already.

Also remove odd `@package`, which we never use.
And remove `@since` which doesn't make sense for test-only files.

Change-Id: Ib7265d39329ecadd5279b11820f77f54189b55d2
2019-06-20 01:24:50 +01:00
Derick Alangi
a5e2854b82 maintenance: Use addDescription() instead of accessing mDescription directly
Change-Id: I705a3fab4a6b151b81b45a3e2d7559f554986378
2019-06-11 19:02:26 +00:00
Timo Tijhof
f2bf73a4c4 resourceloader: Move expandModuleNames() to ResourceLoader.php
This has always been an odd case, as indicicated by the cross-class
comment references, and the fact that its test cases are already
in ResourceLoaderTest.php, for convenience, as that's also where
the creation of 'module name strings' is done and tested.

Actually move it there instead of pretending it is there.

Change-Id: Ied9569436cc78704a5c1b75eeebb73f8631350f6
2019-04-11 21:06:53 +00:00
Evad37
3b4a7cbd58 resourceloader: Add getScript() method for loading scripts with callback
Provides a friendly wrapper for loading scripts using $.ajax().
Returns a promise when the script dependency -- a single
script url -- has been loaded. This matches how mw.loader.load
is able to load a script url, and how mw.loader.using will
return a promised that is resolved when dependecies are loaded,
or rejected if there is an error.

Added as a separate function mw.loader.getScript(), rather
than adding this functionality to using(), as it is a separate
use case, less confusing for users, and there is no shared or
duplicated code between loading a script and loading one
or more named modules.

Bug: T27962
Change-Id: I13be426d03261a2d0c6a1631af94a9f9af58394b
2019-02-26 09:12:22 +08:00
Ed Sanders
9097f95ecc build: Update eslint-config-wikimedia to 0.11.0
Change-Id: Iee025a518962e68c5ec2c07d952f402cd2a7f69b
2019-02-20 23:36:03 +00:00
Ed Sanders
b3e490bba6 build: Update eslint-config-wikimedia to 0.10.0
Change-Id: I2930bcabeeb7b7b2eb36063e77b26e664a691b43
2019-01-08 17:40:11 +00:00
Ed Sanders
3e4e0a5774 build: Use eslint-config-wikimedia v0.9.0 and make pass
Change-Id: I7b5d228a3de4b3006751a427dec907a5bebf2f51
2018-11-23 14:20:24 +00:00
Timo Tijhof
add9bd191f resources: Strip '$' and 'mw' from file closures
Follows-up Id6d13bbea6:
- '$': mw.loader.implement does this already.
- 'mw': Use the canonical name directly.

This replaces the following patterns:

File closures (common):
- `( function ( $, mw ) {`     => `( function () {`
- `( function ( $ ) {`         => `( function () {`
- `( function ( mw ) {`        => `( function () {`
- `( function ( mw, $ ) {`     => `( function () {`

File closures (rare):
- `( function ( mw, $, OO ) {`    => `( function () {`
- `( function ( mw, OO, $ ) {`    => `( function () {`
- `( function ( mw, document ) {` => `( function () {`

Combined dom-ready and file closure (rare):
- `jQuery( function ( $ ) {` => `$( function () {
- `jQuery( function () {` => `$( function () {

Remaining references in files without a closure, as found by
the new ESLint setting (rare):
- `jQuery`    => `$`
- `mediaWiki` => `mw`

Change-Id: I7cf2426cde597259e8c6f3f6f615a1a81a0ca82b
2018-09-14 00:59:27 +01:00
jdlrobson
1ded08465b Hygiene: Discourage use of $.each
Even though Array.prototype.forEach only works on arrays, and
$.each is more generic, I think it makes sense to begin discouraging
the usage of $.each now. This can be overriden by ignore lines or
by Array.prototype.forEach compatible lines. This doesn't seem too
much of an ask of engineers and helps future migrations

Bug: T200877
Change-Id: I339cff311a830699c8e32f07cec338a39870c53f
2018-09-05 17:21:29 -07:00
Timo Tijhof
6815e35575 resourceloader: Remove support for state(name, state) signature
This has no usage in non-test code anywhere in Wikimedia Git,
and was only used in the test suite for mw.loader in core,
and in the test suite for the NavigationTiming extension.

The core usage is as part of this commit. The usage in NavTiming
is updated by I240ced4e65988f9.

Bug: T127328
Depends-On: I240ced4e65988f96c7ece3772378c2c9a335fb9a
Change-Id: Ic17c797e528feaf07a4777709d705615fea353e5
2018-08-14 00:01:42 +00:00
Ed Sanders
4e6a6b4871 build: Enable qunit/no-assert-equal and enforce
This is the equivalent of the '===' rule ("eqeqeq") in eslint core.

Change-Id: I1e6ea8bc1e86c6629ebe938f1b4a6bd288bcfcf7
2018-06-06 11:49:12 +01:00
Ed Sanders
5e18d925e7 build: Introduce eslint-plugin-qunit and enforce
Change-Id: Iefe06cc865c458000ca5350c2d9205f5b768bac8
2018-06-05 21:58:25 +01:00
Bartosz Dziewoński
485f66f174 Use PHP 7 '??' operator instead of '?:' with 'isset()' where convenient
Find: /isset\(\s*([^()]+?)\s*\)\s*\?\s*\1\s*:\s*/
Replace with: '\1 ?? '

(Everywhere except includes/PHPVersionCheck.php)
(Then, manually fix some line length and indentation issues)

Then manually reviewed the replacements for cases where confusing
operator precedence would result in incorrect results
(fixing those in I478db046a1cc162c6767003ce45c9b56270f3372).

Change-Id: I33b421c8cb11cdd4ce896488c9ff5313f03a38cf
2018-05-30 18:06:13 -07:00
Kunal Mehta
06ca92eb8c Re-enable MediaWiki.Usage.SuperGlobalsUsage.SuperGlobals sniff
Disable it in specific files and places where there are legitimate uses
to access $_GET and $_POST directly.

For EditPage, which wants to output $_POST for debugging information,
introduce WebRequest::getPostValues() as a wrapper, matching the
existing ::getQueryValues().

Change-Id: I2cb0a7012fb7ed29dcd720056b42f56508ddc5fa
2018-05-19 15:07:25 -07:00
Timo Tijhof
14df990822 mediawiki.jqueryMsg: Rename .parser class to .Parser
This class is marked @private, but nonetheless, there is at least
one use in MobileFrontend, so keeping a back-compat alias for now.

Also rename the HtmlEmitter utility class (also private, not used
anywhere outside this file), and fix its broken documentation by
repeating the @class and @private tags on its own constructor.
It previously had all its methods indexed by JSDuck as part of the
previous class in that file (Parser), which created doc pages
with examples that don't work.

Change-Id: I02d851d9b6eac89f1a2b85b438b982bd055bedee
2018-04-06 16:20:24 +01:00
Timo Tijhof
fb234d9a5a resourceloader: Fix mw.loader to compute combined version in packed order
The 'version' param was being computed based on the order of the modules list
before we perform string compression. And this compression can change the order
for its optimisation purposes.

Specifically, when requesting modules like 'a', 'b.1', 'b.2' and 'c'. The
version was computed based on a + b.1 + b.2 + c (standard sort order),
whereas the optimised list is 'a,c|b.1,2', which expands to a + c + b.1 + b.2,
which makes hash validation fail.

Bug: T188076
Change-Id: I00d6985c054fecd88acf73041aa02878e83d62bc
2018-03-08 03:24:34 +00:00
Timo Tijhof
15b0e65327 resourceloader: Fix mw.loader to compute version for current request only
Previously, the 'version' query parameter was computed before request-splitting
which meant that all requests within the same 'source/group'-batch carried the
same 'version' parameter. This was then consistently rejected on the server due
to it not batching the combined hash of modules for any given request.

In practice this happened very rarely (if at all) in production, because
urls don't usually hit anywhere near 2000 in common use.

Bug: T188076
Change-Id: I211523d4781623873887a05d048f56cccd28432c
2018-03-07 21:09:08 +00:00
Timo Tijhof
b90bc351e3 resourceloader: Fix broken code in load.php mock used to make a test fail
The load.mock.php has some module implementation stubs that call global
QUnit methods. This has been broken since the upgrade to QUnit 2, which removed
support for these (deprecated) methods, in favour of context-based assert.

However, this went unnoticed because these stubs are only there to make
our test fail if code is behaving incorrectly. Naturally, this isn't the
case normally. In theory, any unmerged code between QUnit 2 upgrade and now
would've failed Jenkins for something like 'QUnit.ok undefined' instead of
the more descriptive error message the stub supplies.

Fix this by instead statically exposing the contextual assert object
to the stubs.

Also centralise the clean up (teardown) for this new exposure, and also
clean up the other static exposure we have (testCallback) in the same way,
and document the cases where we intentionally clean it up inline.

Change-Id: I00b71e7bc9aa97275dfabf1070c4141fa76adb05
2018-03-07 20:55:23 +00:00
Timo Tijhof
870d3a6532 resourceloader: Simplify load.mock.php by removing includes dependency
It previously depended on Xml.php for Xml::encodeJsCall, which
in turn depends on FormatJson. Other Xml.php methods also depend
on Sanitizer, but that was carefully not triggered.

Avoid both of these by simply constructing the string inline,
and using json_encode() directly for the one variable parameter.

Also, fix the names of one of the ResourceLoaderTest cases for
dotless module names. It claims to have been added to cover a
regression fixed in r88706, but that commit seems rather unrelated.
A bit of searching revealed as the relevant commit instead.

Bug: T188076
Change-Id: I04851d0355227f3a6b79b8d41a51d4beadce0e80
2018-03-06 15:59:13 -08:00
Aleksey Bekh-Ivanov (WMDE)
27fb62af34 qunit: Test before and after hooks in QUnit testrunner
Change-Id: Ib5b5d29e860d37dbec675e5d24c31b57c5e64102
2018-02-01 09:53:20 +00:00
Timo Tijhof
c3217d587d qunit: Refactor and simplify testrunner to fix nested modules
Follows-up 5a49381406, 43dc5c1539, 2454f51b27.

* Merge the three QUnit.module extensions into one.
* Change makeSafeEnv() to use Object.create() instead of creating
  a simplified objects so that other properties are still accessible.

The 'testrunner-nested > Dummy' test now actually runs,
previously it was lost.

Change-Id: Id4aeb93582f8cc73b0dffe768a7864002ec85deb
2018-01-31 13:27:48 -08:00
Fomafix
1edba8029a Use native ES5 Array prototype methods instead of jQuery
Replace
* $.each( array, function ( index, value ) { ... } ) by
  array.forEach( function ( value, index ) { ... } )

* $.grep( array, function ( value ) { ... } ) by
  array.filter( function ( value ) { ... } )

* $.map( array, function ( value ) { ... } ) by
  array.map( function ( value ) { ... } )

This change is a follow-up to 9d67e9973e.

Change-Id: I8ef9af8c4d2f440faca65ec7c78a977ea7c31ad2
2018-01-11 21:06:14 +01:00
WMDE-Fisch
6df9ed1ad6 update mediawiki-codesniffer to 0.11.0 and fix issues
- mostly auto fixes
- some too long lines fixed
- ignore amp space in one case  passing by reference

Change-Id: I6472f83bc3cbf4bd629d83050cc3319b19ec465c
2017-08-11 22:27:51 +02:00
Timo Tijhof
2454f51b27 Upgrade QUnit from v1.23.1 to v2.4.0
Source
 https://code.jquery.com/qunit/qunit-2.4.0.js
 https://code.jquery.com/qunit/qunit-2.4.0.css

Changelog
 https://github.com/qunitjs/qunit/blob/2.4.0/History.md

This release makes 'moduleStack' private, which means we can no
longer use it to detect nested modules. Change the method of
detection to be a local 'nested' variable that we toggle in
a wrapped version of any 'executeNow' callback, in which nesting
happens.

Bug: T170515
Change-Id: Ib4ed386990125a6c713cb4351408c8f7ae7c070f
2017-07-25 22:14:09 +00:00
Timo Tijhof
43dc5c1539 qunit: Prepare testrunner for QUnit 2
* Nested modules:
  - Support for Sinon extension was fixed by Ib17bbbef45b2bd.
  - Support for Fixture extension was still broken, masked by the use
    of a local variable that made the handler not fail when setup ran twice
    in a row. Fixed using the same moduleStack.length check.
  - Add regression test.

* beforeEach/afterEach:
  - Added in 1.16, with compat for setup/teardown.
    Our wrapper adds its own setup/teardown, and preserves any original one.
    However, it didn't account for beforeEach/afterEach, so it ends up
    sending both but only one is used.
  - Fix to support both on the incoming localEnv object, and also switch
    our wrapper to use beforeEach/afterEach in prep for QUnit 2.0.
  - Fix our wrappers to preserve return value since QUnit 2 allows beforeEach
    and afterEach hooks to be asynchronous by returning a Promise, similar
    to how one can do from QUnit.test().
  - Add regression test.

* Centralise makeSafeEnv logic
  - We always create our own env object to pass to orgModule().
    Document why this is (to avoid recursion).
  - Add regression test.

* Custom assertion methods:
  - Use this.pushResult instead of the deprecated QUnit.push() method.
    This also improves the in-browser reporting of errors by properly
    supporting 'negative' results for notHtmlEqual reporter.

Bug: T170515
Change-Id: If4141df10eae55cbe8a5ca7a26707be1cd7b9217
2017-07-20 20:45:18 +00:00
Timo Tijhof
5a49381406 qunit: Remove redundant conditional for sandbox teardown
Follows-up 0a208911a2, which added support for the `executeNow`
parameter to QUnit.module.

To properly support nested modules, we also need to skip registering
a second setup and teardown because nested modules already run the
beforeEach (setup), and afterEach (teardown), of their parent modules.

During setup this would needlessly create two sandboxes and override
the 'sandbox' property on the same 'this' context object. During
teardown it would fail because the inner module's teardown would
have already torn down the sandbox.

Change-Id: Ib17bbbef45b2bd0247979cf0fa8aed17800c54a0
2017-07-17 20:25:11 +00:00
Timo Tijhof
6418c54c4a mw.loader: Avoid use of deprecated QUnit.asyncTest/QUnit.start
Deprecated since QUnit 1.16, removed in QUnit 2.0. (We're on 1.23 currently.)

Migrate to assert.async().

This is a fairly atypical use of QUnit.start(), because it functions here
as a cross-script callback, where lexical scope cannot be used to share
the async() callback directly.

Other mw.loader tests already solved this by using a static callback instead
which inherits the lexical scope from the test to call done(). The old
'qunitOkCall' script is no longer used after this and thus removed.

Change-Id: I430df14b35a69c71df8685494d1379e22af0d6df
2017-07-13 04:44:43 +00:00
Umherirrender
b5cddfb27b Remove empty lines at begin of function, if, foreach, switch
Organize phpcs.xml a bit

Change-Id: Ifb767729b481b4b686e6d6444cf48b1f580cc478
2017-07-01 11:34:16 +00:00
Aleksey Bekh-Ivanov (WMDE)
0a208911a2 Ability to create tests with nested modules
Change-Id: Ie0bf2dcfb63e7dc53cd5afe411e2fbb8d1bbfd73
2017-06-02 11:28:48 +00:00
Timo Tijhof
1073b75139 qunit: Also clear $.timers when stopping unfinished animations
Stopping the animation is essentially the same as pausing, it remains in the
animation registry and will continue to fail all subsequent tests until one
of those later tests starts the animation queue again and also happens to
wait long enough for this unrelated animation to finish.

Fix the testrunner to actually fully stop the pre-existing animations, which
requires clearing $.timers as well. This matches the logic we have for
pending ajax requests.

Bug: T163211
Change-Id: Ic7d848187bc3c800e8347e0650093b2ffce6dddc
2017-04-18 16:52:41 -07:00
Timo Tijhof
d8af25c706 qunit: Improve testrunner logging for pending ajax
* Move `restoreWarnings()` in tearDown() to the mirrored location
  of related code in setUp().

* Ensure that accidentally calling `suppressWarnings()` twice will
  not wipe out the original reference indefinitely. If it was
  already set, subsequent calls should do nothing instead of
  overwriting them again so that recovery is still possible.

* Log all ajax requests logged during the test, not just the
  one currently still pending. This should avoid situations
  where we throw "Pending ajax requests" but no information
  is logged about which requests those might be.

Change-Id: I900ad98c4c8520bdd6ae00a24ac82272f3becfee
2017-04-14 17:23:16 -07:00
Timo Tijhof
2bbce5264b qunit: Remove experimental CompletenessTest feature
The CompletenessTest was my attempt at measuring a basic code coverage
using run-time inspection instead of static instrumentation.

Originally added in 540419a82e (2010; MediaWiki 1.17).

It was never finished, remained fairly buggy and disabled by default.
It is also no longer used anywhere.

Bug: T155194
Change-Id: I26e7466426dddb43596f402e31005a89060c1b96
2017-03-24 17:33:40 -07:00
Timo Tijhof
96f40f152a qunit: Make eslint config pass on qunit test files
Follows-up c0fb8a8836, I890e6e49b.

* Disable 'qunit' env in general source code. And re-declare
  locally in the few src files that use it properly.

* Create separate eslint config for tests/qunit with various
  rules disabled (e.g. valid-jsdoc and es3-keywords).

Change-Id: I37ccec2019de55edfee92697eb80478df7cb6220
2017-02-22 11:15:40 -08:00