Files
firefox/devtools/client/framework/test/browser_target_loading.js
T
Nicolas Chevobbe 370da89f66 Bug 1721907 - [devtools] Retry creation of initial target on AbortError. r=jdescottes.
It can happen that the call to `instantiateTarget` from frame-helper.js fails if
the document gets destroyed quickly. In such case, we receive an `AbortError`
and me try again to create the initial targets.
As a result, it might happens that the DevToolsFrameChild handles the actual document via the
`DOMWindowCreated` event handler which would make the `DevToolsFrameParent:instantiate-already-available`
message handling fail as we're trying to create yet another target for the same
document.
In such situation we simply don't throw anymore

This makes browser_styleeditor_loading to pass with server side target switching.

Differential Revision: https://phabricator.services.mozilla.com/D121375
2021-08-12 05:34:26 +00:00

38 lines
1.3 KiB
JavaScript

/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
// Test that toolbox can be opened right after a tab is added, while the document
// is still loading.
add_task(async function testOpenToolboxOnLoadingDocument() {
const TEST_URI =
`https://example.com/document-builder.sjs?` +
`html=Test<script>console.log("page loaded")</script>`;
// ⚠️ Note that we don't await for `addTab` here, as we want to open the toolbox just
// after the tab is addded, with the document still loading.
info("Add tab…");
const onTabAdded = addTab(TEST_URI);
const tab = gBrowser.selectedTab;
info("…and open the toolbox right away");
const onToolboxShown = gDevTools.showToolboxForTab(tab, {
toolId: "webconsole",
});
await onTabAdded;
ok(true, "The tab as done loading");
const toolbox = await onToolboxShown;
ok(true, "The toolbox is shown");
info("Check that the console opened and has the message from the page");
const { hud } = toolbox.getPanel("webconsole");
await waitFor(() =>
Array.from(
hud.ui.window.document.querySelectorAll(".message-body")
).some(el => el.innerText.includes("page loaded"))
);
ok(true, "The console opened with the expected content");
});