Bug 1504133 - Make pageloader tests wait for TalosPowers to become available before starting. r=aswan

Depends on D11261

Differential Revision: https://phabricator.services.mozilla.com/D11262

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Mike Conley 2018-11-09 14:03:32 +00:00
Родитель a4f7342569
Коммит a7d1e37186
1 изменённых файлов: 19 добавлений и 2 удалений

Просмотреть файл

@ -39,6 +39,7 @@
ChromeUtils.import("resource://gre/modules/Services.jsm");
ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
ChromeUtils.import("resource://gre/modules/Timer.jsm");
XPCOMUtils.defineLazyServiceGetter(this, "aomStartup",
"@mozilla.org/addons/addon-manager-startup;1",
@ -93,9 +94,25 @@ this.pageloader = class extends ExtensionAPI {
]);
if (env.exists("MOZ_USE_PAGELOADER")) {
// This is async but we're delibeately not await-ing or return-ing
// TalosPowers is a separate WebExtension that may or may not already have
// finished loading. tryLoad is used to wait for TalosPowers to be around
// before continuing.
async function tryLoad() {
try {
ChromeUtils.import("resource://talos-powers/TalosParentProfiler.jsm");
} catch (err) {
await new Promise(resolve => setTimeout(resolve, 500));
return tryLoad();
}
return null;
}
// talosStart is async but we're deliberately not await-ing or return-ing
// it here since it doesn't block extension startup.
talosStart();
tryLoad().then(() => {
talosStart();
});
}
}