mirror of
https://github.com/HeyPuter/firefox.git
synced 2026-11-15 17:55:15 -10:00
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
38 lines
1.3 KiB
JavaScript
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");
|
|
});
|