diff --git a/devtools/shared/commands/resource/tests/browser.ini b/devtools/shared/commands/resource/tests/browser.ini index 543b5a4f96a3..23a26bad1140 100644 --- a/devtools/shared/commands/resource/tests/browser.ini +++ b/devtools/shared/commands/resource/tests/browser.ini @@ -12,7 +12,9 @@ support-files = network_document.html early_console_document.html fission_document.html + fission_document_workers.html fission_iframe.html + fission_iframe_workers.html service-worker-sources.js sources.html sources.js diff --git a/devtools/shared/commands/resource/tests/browser_resources_console_messages.js b/devtools/shared/commands/resource/tests/browser_resources_console_messages.js index 6fdb3b889d41..84c97a39400d 100644 --- a/devtools/shared/commands/resource/tests/browser_resources_console_messages.js +++ b/devtools/shared/commands/resource/tests/browser_resources_console_messages.js @@ -47,12 +47,6 @@ async function testTabConsoleMessagesResources(executeInIframe) { const onRuntimeDone = new Promise(resolve => (runtimeDoneResolve = resolve)); const onAvailable = resources => { for (const resource of resources) { - if (resource.message.arguments?.[0] === "[WORKER] started") { - // XXX Ignore message from workers as we can't know when they're logged, and we - // have a dedicated test for them (browser_resources_console_messages_workers.js). - continue; - } - is( resource.resourceType, resourceCommand.TYPES.CONSOLE_MESSAGE, @@ -105,12 +99,6 @@ async function testTabConsoleMessagesResources(executeInIframe) { targetCommand.destroy(); await client.close(); - - await SpecialPowers.spawn(tab.linkedBrowser, [], async () => { - // registrationPromise is set by the test page. - const registration = await content.wrappedJSObject.registrationPromise; - registration.unregister(); - }); } async function testTabConsoleMessagesResourcesWithIgnoreExistingResources( @@ -178,12 +166,6 @@ async function testTabConsoleMessagesResourcesWithIgnoreExistingResources( targetCommand.destroy(); await client.close(); - - await SpecialPowers.spawn(tab.linkedBrowser, [], async () => { - // registrationPromise is set by the test page. - const registration = await content.wrappedJSObject.registrationPromise; - registration.unregister(); - }); } async function logExistingMessages(browser, executeInIframe) { diff --git a/devtools/shared/commands/resource/tests/browser_resources_console_messages_navigation.js b/devtools/shared/commands/resource/tests/browser_resources_console_messages_navigation.js index 07c2d9b40d79..4d1b179dc51e 100644 --- a/devtools/shared/commands/resource/tests/browser_resources_console_messages_navigation.js +++ b/devtools/shared/commands/resource/tests/browser_resources_console_messages_navigation.js @@ -35,13 +35,7 @@ async function testCrossProcessTabNavigation(browser, resourceCommand) { const onConsoleLogsComplete = new Promise(resolve => (doneResolve = resolve)); const onAvailable = resources => { - messages.push( - // Ignore all unexpected messages from workers as they are not - // useful here and they are tested elsewhere. - ...resources.filter( - r => !r.message.arguments[0].startsWith("[WORKER] started") - ) - ); + messages.push(...resources); if (messages.length == 2) { doneResolve(); } diff --git a/devtools/shared/commands/resource/tests/browser_resources_console_messages_workers.js b/devtools/shared/commands/resource/tests/browser_resources_console_messages_workers.js index 698882b53a5e..2188b6de1b82 100644 --- a/devtools/shared/commands/resource/tests/browser_resources_console_messages_workers.js +++ b/devtools/shared/commands/resource/tests/browser_resources_console_messages_workers.js @@ -5,9 +5,9 @@ // Test the ResourceCommand API around CONSOLE_MESSAGE in workers -const FISSION_TEST_URL = URL_ROOT_SSL + "fission_document.html"; +const FISSION_TEST_URL = URL_ROOT_SSL + "fission_document_workers.html"; const WORKER_FILE = "test_worker.js"; -const IFRAME_FILE = `${URL_ROOT_ORG_SSL}fission_iframe.html`; +const IFRAME_FILE = `${URL_ROOT_ORG_SSL}fission_iframe_workers.html`; add_task(async function() { // Set the following pref to false as it's the one that enables direct connection diff --git a/devtools/shared/commands/resource/tests/browser_resources_getAllResources.js b/devtools/shared/commands/resource/tests/browser_resources_getAllResources.js index 82663e011fb9..cbcebbecb4ee 100644 --- a/devtools/shared/commands/resource/tests/browser_resources_getAllResources.js +++ b/devtools/shared/commands/resource/tests/browser_resources_getAllResources.js @@ -35,7 +35,20 @@ add_task(async function() { info("Check the resources after some resources are available"); const messages = ["a", "b", "c"]; await logMessages(tab.linkedBrowser, messages); - await waitUntil(() => availableResources.length >= messages.length); + + try { + await waitFor(() => availableResources.length === messages.length); + } catch (e) { + ok( + false, + `Didn't receive the expected number of resources. Got ${ + availableResources.length + }, expected ${messages.length} - ${availableResources + .map(r => r.message.arguments[0]) + .join(" - ")}` + ); + } + assertResources( resourceCommand.getAllResources(resourceCommand.TYPES.CONSOLE_MESSAGE), availableResources @@ -55,12 +68,27 @@ add_task(async function() { ); info("Append some resources again to test unwatching"); + const newMessages = ["d", "e", "f"]; await logMessages(tab.linkedBrowser, messages); - await waitUntil( - () => - resourceCommand.getAllResources(resourceCommand.TYPES.CONSOLE_MESSAGE) - .length === messages.length - ); + try { + await waitFor( + () => + resourceCommand.getAllResources(resourceCommand.TYPES.CONSOLE_MESSAGE) + .length === newMessages.length + ); + } catch (e) { + const resources = resourceCommand.getAllResources( + resourceCommand.TYPES.CONSOLE_MESSAGE + ); + ok( + false, + `Didn't receive the expected number of resources. Got ${ + resources.length + }, expected ${messages.length} - ${resources + .map(r => r.message.arguments.join(" | ")) + .join(" - ")}` + ); + } info("Check the resources after unwatching"); resourceCommand.unwatchResources([resourceCommand.TYPES.CONSOLE_MESSAGE], { @@ -90,8 +118,8 @@ function assertResources(resources, expectedResources) { } function logMessages(browser, messages) { - return ContentTask.spawn(browser, { messages }, args => { - for (const message of args.messages) { + return SpecialPowers.spawn(browser, [messages], innerMessages => { + for (const message of innerMessages) { content.console.log(message); } }); diff --git a/devtools/shared/commands/resource/tests/browser_resources_target_switching.js b/devtools/shared/commands/resource/tests/browser_resources_target_switching.js index a178fc64fba1..ff075c4480b6 100644 --- a/devtools/shared/commands/resource/tests/browser_resources_target_switching.js +++ b/devtools/shared/commands/resource/tests/browser_resources_target_switching.js @@ -28,13 +28,7 @@ add_task(async function() { ); const availableResources = []; const onAvailable = resources => { - // Ignore message coming from shared worker started by previous tests and - // logging late a console message - resources - .filter(r => { - return !r.message.arguments[0].startsWith("[WORKER] started"); - }) - .map(r => availableResources.push(r)); + availableResources.push(...resources); }; await resourceCommand.watchResources([CONSOLE_MESSAGE], { onAvailable }); diff --git a/devtools/shared/commands/resource/tests/fission_document.html b/devtools/shared/commands/resource/tests/fission_document.html index c2239faca62e..222f92d999eb 100644 --- a/devtools/shared/commands/resource/tests/fission_document.html +++ b/devtools/shared/commands/resource/tests/fission_document.html @@ -5,30 +5,6 @@ Test fission document -

Test fission iframe

diff --git a/devtools/shared/commands/resource/tests/fission_document_workers.html b/devtools/shared/commands/resource/tests/fission_document_workers.html new file mode 100644 index 000000000000..bbbe3e8bf8f9 --- /dev/null +++ b/devtools/shared/commands/resource/tests/fission_document_workers.html @@ -0,0 +1,47 @@ + + + + + Test fission document + + + + +

Test fission iframe

+ + + + diff --git a/devtools/shared/commands/resource/tests/fission_iframe.html b/devtools/shared/commands/resource/tests/fission_iframe.html index deae49f83326..f67432110204 100644 --- a/devtools/shared/commands/resource/tests/fission_iframe.html +++ b/devtools/shared/commands/resource/tests/fission_iframe.html @@ -5,23 +5,6 @@ Test fission iframe document -

remote iframe

diff --git a/devtools/shared/commands/resource/tests/fission_iframe_workers.html b/devtools/shared/commands/resource/tests/fission_iframe_workers.html new file mode 100644 index 000000000000..deae49f83326 --- /dev/null +++ b/devtools/shared/commands/resource/tests/fission_iframe_workers.html @@ -0,0 +1,29 @@ + + + + + Test fission iframe document + + + + +

remote iframe

+ + diff --git a/devtools/shared/commands/target/tests/test_worker.js b/devtools/shared/commands/target/tests/test_worker.js index 873041fcf071..3e6cd21f04d3 100644 --- a/devtools/shared/commands/target/tests/test_worker.js +++ b/devtools/shared/commands/target/tests/test_worker.js @@ -3,8 +3,6 @@ "use strict"; -console.log("[WORKER] started", globalThis.location.toString(), globalThis); - globalThis.onmessage = function(e) { const { type, message } = e.data;