browser_target_loading.js (1296B)
1 /* Any copyright is dedicated to the Public Domain. 2 http://creativecommons.org/publicdomain/zero/1.0/ */ 3 "use strict"; 4 5 // Test that toolbox can be opened right after a tab is added, while the document 6 // is still loading. 7 8 add_task(async function testOpenToolboxOnLoadingDocument() { 9 const TEST_URI = 10 `https://example.com/document-builder.sjs?` + 11 `html=Test<script>console.log("page loaded")</script>`; 12 13 // ⚠️ Note that we don't await for `addTab` here, as we want to open the toolbox just 14 // after the tab is addded, with the document still loading. 15 info("Add tab…"); 16 const onTabAdded = addTab(TEST_URI); 17 const tab = gBrowser.selectedTab; 18 info("…and open the toolbox right away"); 19 const onToolboxShown = gDevTools.showToolboxForTab(tab, { 20 toolId: "webconsole", 21 }); 22 23 await onTabAdded; 24 ok(true, "The tab as done loading"); 25 26 const toolbox = await onToolboxShown; 27 ok(true, "The toolbox is shown"); 28 29 info("Check that the console opened and has the message from the page"); 30 const { hud } = toolbox.getPanel("webconsole"); 31 await waitFor(() => 32 Array.from(hud.ui.window.document.querySelectorAll(".message-body")).some( 33 el => el.innerText.includes("page loaded") 34 ) 35 ); 36 ok(true, "The console opened with the expected content"); 37 });