mw.loader: Don't unset 'require' after execution in debug mode
authorTimo Tijhof <krinklemail@gmail.com>
Fri, 30 Sep 2016 23:59:28 +0000 (00:59 +0100)
committerKrinkle <krinklemail@gmail.com>
Tue, 4 Oct 2016 16:55:34 +0000 (16:55 +0000)
commit3eef71c701abc899cb842a9bcd00cd1cb18c4e11
tree9d55c6b660c60e14743de08d6e9dda3b946a48eb
parentfa0f50727940eb52f60d5399267de22819d4d76e
mw.loader: Don't unset 'require' after execution in debug mode

Follows-up bc4e07b6f6.

In production mode, 'module' and 'require' are lexically provided
through closure to the executing script and will continue to be
accessible through the script's life-time.

In debug mode, the script executes without wrapper directly from
disk (and as such, in the global scope) and variables are provided
as global variables. Since a variable can only be set to one value,
we swap the object that 'module' points to after each file. And
to avoid leakage, it is removed in-between files and after the
last one. Aside from it being technically infeasible right now,
async access to 'module' is discouraged regardless.

Late access to 'require', however, is not uncommon and should
work as expected.

Bug: T144879
Change-Id: I6ede10fd42676bb035ea26c693c78bcdc1438a7d
resources/src/mediawiki/mediawiki.js
tests/qunit/data/defineCallMwLoaderTestCallback.js
tests/qunit/data/requireCallMwLoaderTestCallback.js
tests/qunit/suites/resources/mediawiki/mediawiki.loader.test.js