Bug 1707823 - [devtools] Replace usage of navigateTo in browser_toolbox_backward_forward_navigation.js. r=ochameau.

the test document has a script that adds dom nodes, js sources and stylesheet
to the document every 200ms. It might that the navigateTo call we were using to navigate
to the document would never resolve, as the load event won't fire because of the constant
addition of stylesheets and scripts.
This is fixed by not using navigateTo, as we don't really need the document to be ready,
but only register the navigation so later in the test we can do backward and forward navigations.

Depends on D113479

Differential Revision: https://phabricator.services.mozilla.com/D113480
This commit is contained in:
Nicolas Chevobbe 2021-04-28 07:52:21 +00:00
Родитель 13980e9a4f
Коммит 763039ce66
1 изменённых файлов: 29 добавлений и 4 удалений

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

@ -19,18 +19,34 @@ Services.scriptloader.loadSubScript(
); );
add_task(async function() { add_task(async function() {
// Start with a page without much activity so the toolbox gets initialized safely // Don't show the third panel to limit the logs and activity.
const tab = await addTab(`data:text/html,<meta charset=utf8>`); await pushPref("devtools.inspector.three-pane-enabled", false);
await pushPref("devtools.inspector.activeSidebar", "ruleview");
const DATA_URL = `data:text/html,<meta charset=utf8>`;
const tab = await addTab(DATA_URL);
// Select the debugger so there will be more activity // Select the debugger so there will be more activity
const toolbox = await openToolboxForTab(tab, "jsdebugger"); const toolbox = await openToolboxForTab(tab, "jsdebugger");
const inspector = await toolbox.selectTool("inspector"); const inspector = await toolbox.selectTool("inspector");
info("Navigate to the ORG test page"); info("Navigate to the ORG test page");
await navigateTo(TEST_URI_ORG); // We don't use `navigateTo` as the page is adding stylesheets and js files which might
// delay the load event indefinitely (and we don't need for anything to be loaded, or
// ready, just to register the initial navigation so we can go back and forth between urls)
let onLocationChange = BrowserTestUtils.waitForLocationChange(
gBrowser,
TEST_URI_ORG
);
BrowserTestUtils.loadURI(gBrowser, TEST_URI_ORG);
await onLocationChange;
info("And then navigate to a different origin"); info("And then navigate to a different origin");
await navigateTo(TEST_URI_COM); onLocationChange = BrowserTestUtils.waitForLocationChange(
gBrowser,
TEST_URI_COM
);
BrowserTestUtils.loadURI(gBrowser, TEST_URI_COM);
await onLocationChange;
info( info(
"Navigate backward and forward multiple times between the two origins, with different delays" "Navigate backward and forward multiple times between the two origins, with different delays"
@ -40,12 +56,18 @@ add_task(async function() {
// Navigate one last time to a document with less activity so we don't have to deal // Navigate one last time to a document with less activity so we don't have to deal
// with pending promises when we destroy the toolbox // with pending promises when we destroy the toolbox
const onInspectorReloaded = inspector.once("reloaded"); const onInspectorReloaded = inspector.once("reloaded");
info("Navigate to final document");
await navigateTo(`${TEST_URI_ORG}?no-mutation`); await navigateTo(`${TEST_URI_ORG}?no-mutation`);
info("Waiting for inspector to reload…");
await onInspectorReloaded; await onInspectorReloaded;
info("-> inspector reloaded");
await checkToolboxState(toolbox); await checkToolboxState(toolbox);
}); });
add_task(async function() { add_task(async function() {
// Don't show the third panel to limit the logs and activity.
await pushPref("devtools.inspector.three-pane-enabled", false);
await pushPref("devtools.inspector.activeSidebar", "ruleview");
const DATA_URL = `data:text/html,<meta charset=utf8>`; const DATA_URL = `data:text/html,<meta charset=utf8>`;
const tab = await addTab(DATA_URL); const tab = await addTab(DATA_URL);
@ -65,8 +87,11 @@ add_task(async function() {
// Navigate one last time to a document with less activity so we don't have to deal // Navigate one last time to a document with less activity so we don't have to deal
// with pending promises when we destroy the toolbox // with pending promises when we destroy the toolbox
const onInspectorReloaded = inspector.once("reloaded"); const onInspectorReloaded = inspector.once("reloaded");
info("Navigate to final document");
await navigateTo(`${TEST_URI_ORG}?no-mutation`); await navigateTo(`${TEST_URI_ORG}?no-mutation`);
info("Waiting for inspector to reload…");
await onInspectorReloaded; await onInspectorReloaded;
info("-> inspector reloaded");
await checkToolboxState(toolbox); await checkToolboxState(toolbox);
}); });