Bug 1500079 - Ensure that new about:debugging tests wait for initial load requests before proceeding with the tests. r=jdescottes

MozReview-Commit-ID: 9ClZ2lkdq01

Depends on D8868

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Alexandre Poirot 2018-10-29 16:10:46 +00:00
Родитель 52f12ef5a5
Коммит 045e70296e
2 изменённых файлов: 23 добавлений и 1 удалений

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

@ -140,3 +140,6 @@ window.addEventListener("DOMContentLoaded", () => {
window.addEventListener("unload", () => {
AboutDebugging.destroy();
}, {once: true});
// Expose AboutDebugging to tests so that they can access to the store.
window.AboutDebugging = AboutDebugging;

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

@ -13,6 +13,11 @@ Services.scriptloader.loadSubScript(
"chrome://mochitests/content/browser/devtools/client/shared/test/shared-head.js",
this);
// Load the shared Redux helpers into this compartment.
Services.scriptloader.loadSubScript(
"chrome://mochitests/content/browser/devtools/client/shared/test/shared-redux-head.js",
this);
// Load collapsibilities helpers
Services.scriptloader.loadSubScript(
CHROME_URL_ROOT + "debug-target-pane_collapsibilities_head.js", this);
@ -45,6 +50,7 @@ async function openAboutDebugging(page, win) {
const browser = tab.linkedBrowser;
const document = browser.contentDocument;
const window = browser.contentWindow;
const { AboutDebugging } = window;
info("Wait until the main about debugging container is available");
await waitUntil(() => document.querySelector(".app"));
@ -56,7 +62,20 @@ async function openAboutDebugging(page, win) {
// Otherwise, we might have a race condition where TAB1 is discovered by the initial
// listTabs from the watchRuntime action, instead of being discovered after the
// TAB_UPDATED event. See analysis in Bug 1493968.
await waitUntil(() => findDebugTargetByText("about:debugging", document));
info("Wait until tabs are displayed");
await waitUntilState(AboutDebugging.store, state => {
return state.debugTargets.tabs.length > 0;
});
info("Wait until pre-installed add-ons are displayed");
await waitUntilState(AboutDebugging.store, state => {
return state.debugTargets.installedExtensions.length > 0;
});
info("Wait until internal 'other workers' are displayed");
await waitUntilState(AboutDebugging.store, state => {
return state.debugTargets.otherWorkers.length > 0;
});
return { tab, document, window };
}