Avoid exception when checking for loaded modules

The test would lead to an exception when 'mediaWiki' is not defined. The
exception would then also abort the whole execution so in this context it's
safer to use typeof with 'undefined'.

When the mediaWiki js base is loaded though, loader.getState() is guaranteed
to be available since it is part of the root module.

This also uses "mw" instead of "mediaWiki" for consistency in test.

Change-Id: I1262d0b5c4a1136f4d2294f125336e72118c6e2c
This commit is contained in:
WMDE-Fisch 2019-04-08 19:20:02 +02:00
parent 54702bff62
commit 79ee43fbeb
2 changed files with 4 additions and 4 deletions

View file

@ -6,7 +6,8 @@
"node": true
},
"globals": {
"browser": "readonly"
"browser": "readonly",
"mw": "readonly"
},
"rules": {
"no-console": 0

View file

@ -41,9 +41,8 @@ class PopupsPage extends Page {
// https://github.com/webdriverio/webdriverio/blob/master/lib/utils/Timer.js
browser.waitUntil( () => {
return browser.execute( ( module ) => {
return mediaWiki &&
mediaWiki.loader &&
mediaWiki.loader.getState( module.name ) === module.status;
return typeof mw !== 'undefined' &&
mw.loader.getState( module.name ) === module.status;
}, { status: moduleStatus, name: moduleName } );
}, 10000, errMsg );
}