diff options
Diffstat (limited to '')
10 files changed, 80 insertions, 42 deletions
diff --git a/devtools/shared/commands/inspector/tests/browser_inspector_command_findNodeFrontFromSelectors.js b/devtools/shared/commands/inspector/tests/browser_inspector_command_findNodeFrontFromSelectors.js index 7991421c8d..8817c8b685 100644 --- a/devtools/shared/commands/inspector/tests/browser_inspector_command_findNodeFrontFromSelectors.js +++ b/devtools/shared/commands/inspector/tests/browser_inspector_command_findNodeFrontFromSelectors.js @@ -17,14 +17,21 @@ add_task(async () => { <iframe id="iframe-org" src="https://example.org/document-builder.sjs?delay=3000&html=${iframeOrgHtml}"></iframe> <iframe id="iframe-com" src="https://example.com/document-builder.sjs?delay=6000&html=${iframeComHtml}"></iframe>` ); - const tab = await addTab( - "https://example.org/document-builder.sjs?html=" + html, - { waitForLoad: false } - ); + const testUrl = "https://example.org/document-builder.sjs?html=" + html; + + // We aren't waiting for load as it would only resolve on full loading of the page, including the full loading of all the iframes. + const tab = await addTab(testUrl, { waitForLoad: false }); const commands = await CommandsFactory.forTab(tab); await commands.targetCommand.startListening(); + // As addTab isn't waiting for full document load, we may still be on the first WindowGlobal refering to the initial about:blank document + // Ensure that the top level target refers to the test document and not the about:blank one. + await waitFor( + () => commands.targetCommand.targetFront.url == testUrl, + "Waiting for the top level target to refer to the test page" + ); + info("Check that it returns null when no params are passed"); let nodeFront = await commands.inspectorCommand.findNodeFrontFromSelectors(); is( diff --git a/devtools/shared/commands/resource/legacy-listeners/source.js b/devtools/shared/commands/resource/legacy-listeners/source.js index 45ee62f70f..2c629e4fb9 100644 --- a/devtools/shared/commands/resource/legacy-listeners/source.js +++ b/devtools/shared/commands/resource/legacy-listeners/source.js @@ -37,6 +37,7 @@ module.exports = async function ({ targetCommand, targetFront, onAvailable }) { } const threadFront = await targetFront.getFront("thread"); + await threadFront.attach({}); // Use a list of all notified SourceFront as we don't have a newSource event for all sources // but we sometime get sources notified both via newSource event *and* sources() method... diff --git a/devtools/shared/commands/resource/legacy-listeners/thread-states.js b/devtools/shared/commands/resource/legacy-listeners/thread-states.js index b24bdfa8cc..aa1328abaf 100644 --- a/devtools/shared/commands/resource/legacy-listeners/thread-states.js +++ b/devtools/shared/commands/resource/legacy-listeners/thread-states.js @@ -19,11 +19,6 @@ module.exports = async function ({ targetCommand, targetFront, onAvailable }) { return; } - // Wait for the thread actor to be attached, otherwise getFront(thread) will throw for worker targets - // This is because worker target are still kind of descriptors and are only resolved into real target - // after being attached. And the thread actor ID is only retrieved and available after being attached. - await targetFront.onThreadAttached; - if (targetFront.isDestroyed()) { return; } diff --git a/devtools/shared/commands/resource/tests/browser_resources_last_private_context_exit.js b/devtools/shared/commands/resource/tests/browser_resources_last_private_context_exit.js index 1e2d894be3..738e70bc2d 100644 --- a/devtools/shared/commands/resource/tests/browser_resources_last_private_context_exit.js +++ b/devtools/shared/commands/resource/tests/browser_resources_last_private_context_exit.js @@ -66,7 +66,7 @@ add_task(async function () { }); info("Close the second private window"); - secondPrivateWindow.BrowserTryToCloseWindow(); + secondPrivateWindow.BrowserCommands.tryToCloseWindow(); // Let a chance to an unexpected async event to be fired await wait(1000); @@ -80,7 +80,7 @@ add_task(async function () { info( "close the private window and check if LAST_PRIVATE_CONTEXT_EXIT resource is sent" ); - privateWindow.BrowserTryToCloseWindow(); + privateWindow.BrowserCommands.tryToCloseWindow(); info("Wait for LAST_PRIVATE_CONTEXT_EXIT"); await waitFor(() => availableResources.length == 1); diff --git a/devtools/shared/commands/resource/tests/browser_resources_network_events_parent_process.js b/devtools/shared/commands/resource/tests/browser_resources_network_events_parent_process.js index c5b3e436db..0c8583aa97 100644 --- a/devtools/shared/commands/resource/tests/browser_resources_network_events_parent_process.js +++ b/devtools/shared/commands/resource/tests/browser_resources_network_events_parent_process.js @@ -32,6 +32,10 @@ const FETCH_URI = "https://example.com/document-builder.sjs?html=foo"; const uuid = `${Date.now()}-${Math.random()}`; const IMAGE_URI = URL_ROOT_SSL + "test_image.png?" + uuid; +// Loading the content page might also trigger priviledge image requests from the firefox UI, this seems to +// happen when a new tab is created for the page. +const ignoreRequestPatterns = "file:///"; + add_task(async function testParentProcessRequests() { // The test expects the main process commands instance to receive resources // for content process requests. @@ -46,6 +50,9 @@ add_task(async function testParentProcessRequests() { const onAvailable = resources => { for (const resource of resources) { if (resource.resourceType == resourceCommand.TYPES.NETWORK_EVENT) { + if (resource.url.startsWith(ignoreRequestPatterns)) { + return; + } receivedNetworkEvents.push(resource); } else if ( resource.resourceType == resourceCommand.TYPES.NETWORK_EVENT_STACKTRACE diff --git a/devtools/shared/commands/resource/tests/browser_resources_stylesheets.js b/devtools/shared/commands/resource/tests/browser_resources_stylesheets.js index ec81e8118d..6c4f2e867a 100644 --- a/devtools/shared/commands/resource/tests/browser_resources_stylesheets.js +++ b/devtools/shared/commands/resource/tests/browser_resources_stylesheets.js @@ -118,6 +118,8 @@ const ADDITIONAL_FROM_ACTOR_RESOURCE = { }; add_task(async function () { + // Enable @property + await pushPref("layout.css.properties-and-values.enabled", true); await testResourceAvailableDestroyedFeature(); await testResourceUpdateFeature(); await testNestedResourceUpdateFeature(); @@ -496,13 +498,18 @@ async function testNestedResourceUpdateFeature() { } } } + } + @property --my-property { + syntax: "<color>"; + inherits: true; + initial-value: #f06; }`, false ); await waitUntil(() => updates.length === 3); is( updates.at(-1).resource.ruleCount, - 7, + 8, "Resource in update has expected ruleCount" ); @@ -554,6 +561,10 @@ async function testNestedResourceUpdateFeature() { type: "container", conditionText: "root (width > 10px)", }, + { + type: "property", + propertyName: "--my-property", + }, ]; assertAtRules(targetUpdate.resource.atRules, expectedAtRules); @@ -562,7 +573,7 @@ async function testNestedResourceUpdateFeature() { const styleSheetResult = await getStyleSheetResult(tab); is( styleSheetResult.ruleCount, - 7, + 8, "ruleCount of actual stylesheet is updated correctly" ); assertAtRules(styleSheetResult.atRules, expectedAtRules); @@ -620,6 +631,11 @@ async function getStyleSheetResult(tab) { type: "support", conditionText: rule.conditionText, }); + } else if (rule instanceof content.CSSPropertyRule) { + atRules.push({ + type: "property", + propertyName: rule.name, + }); } if (rule.cssRules) { @@ -655,6 +671,8 @@ function assertAtRules(atRules, expectedAtRules) { is(atRule.matches, expected.matches, "matches is correct"); } else if (expected.type === "layer") { is(atRule.layerName, expected.layerName, "layerName is correct"); + } else if (expected.type === "property") { + is(atRule.propertyName, expected.propertyName, "propertyName is correct"); } if (expected.line !== undefined) { diff --git a/devtools/shared/commands/resource/tests/browser_resources_thread_states.js b/devtools/shared/commands/resource/tests/browser_resources_thread_states.js index f9d49e227a..fb4848c4c3 100644 --- a/devtools/shared/commands/resource/tests/browser_resources_thread_states.js +++ b/devtools/shared/commands/resource/tests/browser_resources_thread_states.js @@ -42,9 +42,8 @@ async function checkBreakpointBeforeWatchResources() { const tab = await addTab(BREAKPOINT_TEST_URL); - const { client, resourceCommand, targetCommand } = await initResourceCommand( - tab - ); + const { commands, resourceCommand, targetCommand } = + await initResourceCommand(tab); // Ensure that the target front is initialized early from TargetCommand.onTargetAvailable // By the time `initResourceCommand` resolves, it should already be initialized. @@ -53,6 +52,11 @@ async function checkBreakpointBeforeWatchResources() { ); await targetCommand.targetFront.initialized; + // We have to ensure passing any thread configuration in order to have breakpoints being handled. + await commands.threadConfigurationCommand.updateConfiguration({ + skipBreakpoints: false, + }); + info("Run the 'debugger' statement"); // Note that we do not wait for the resolution of spawn as it will be paused ContentTask.spawn(tab.linkedBrowser, null, () => { @@ -104,7 +108,7 @@ async function checkBreakpointBeforeWatchResources() { assertResumedResource(resumed); targetCommand.destroy(); - await client.close(); + await commands.destroy(); } async function checkBreakpointAfterWatchResources() { @@ -114,9 +118,8 @@ async function checkBreakpointAfterWatchResources() { const tab = await addTab(BREAKPOINT_TEST_URL); - const { client, resourceCommand, targetCommand } = await initResourceCommand( - tab - ); + const { commands, resourceCommand, targetCommand } = + await initResourceCommand(tab); info("Call watchResources"); const availableResources = []; @@ -176,7 +179,7 @@ async function checkBreakpointAfterWatchResources() { assertResumedResource(resumed); targetCommand.destroy(); - await client.close(); + await commands.destroy(); } async function checkRealBreakpoint() { @@ -186,9 +189,8 @@ async function checkRealBreakpoint() { const tab = await addTab(BREAKPOINT_TEST_URL); - const { client, resourceCommand, targetCommand } = await initResourceCommand( - tab - ); + const { commands, resourceCommand, targetCommand } = + await initResourceCommand(tab); info("Call watchResources"); const availableResources = []; @@ -258,7 +260,7 @@ async function checkRealBreakpoint() { assertResumedResource(resumed); targetCommand.destroy(); - await client.close(); + await commands.destroy(); } async function checkPauseOnException() { @@ -342,9 +344,8 @@ async function checkSetBeforeWatch() { const tab = await addTab(BREAKPOINT_TEST_URL); - const { client, resourceCommand, targetCommand } = await initResourceCommand( - tab - ); + const { commands, resourceCommand, targetCommand } = + await initResourceCommand(tab); // Instantiate the thread front in order to be able to set a breakpoint before watching for thread state info("Attach the top level thread actor"); @@ -381,10 +382,9 @@ async function checkSetBeforeWatch() { onAvailable: resources => availableResources.push(...resources), }); - await waitFor( - () => availableResources.length == 1, - "Got the THREAD_STATE related to the debugger statement" - ); + await waitFor(() => { + return availableResources.length == 1; + }, "Got the THREAD_STATE related to the debugger statement"); const threadState = availableResources.pop(); assertPausedResource(threadState, { @@ -418,7 +418,7 @@ async function checkSetBeforeWatch() { assertResumedResource(resumed); targetCommand.destroy(); - await client.close(); + await commands.destroy(); } async function checkDebuggerStatementInIframes() { @@ -426,9 +426,8 @@ async function checkDebuggerStatementInIframes() { const tab = await addTab(BREAKPOINT_TEST_URL); - const { client, resourceCommand, targetCommand } = await initResourceCommand( - tab - ); + const { commands, resourceCommand, targetCommand } = + await initResourceCommand(tab); info("Call watchResources"); const availableResources = []; @@ -507,14 +506,14 @@ async function checkDebuggerStatementInIframes() { assertResumedResource(resumed); targetCommand.destroy(); - await client.close(); + await commands.destroy(); } async function testMultiprocessThreadState() { // Ensure debugging the content processes and the tab await pushPref("devtools.browsertoolbox.scope", "everything"); - const { client, resourceCommand, targetCommand } = + const { commands, resourceCommand, targetCommand } = await initMultiProcessResourceCommand(); info("Call watchResources"); @@ -586,7 +585,7 @@ async function testMultiprocessThreadState() { is(availableResources.length, 0, "There should be no other pause"); targetCommand.destroy(); - await client.close(); + await commands.destroy(); } async function assertPausedResource(resource, expected) { diff --git a/devtools/shared/commands/target/tests/browser_target_command_bfcache.js b/devtools/shared/commands/target/tests/browser_target_command_bfcache.js index c5ce76848e..03de5e3b5d 100644 --- a/devtools/shared/commands/target/tests/browser_target_command_bfcache.js +++ b/devtools/shared/commands/target/tests/browser_target_command_bfcache.js @@ -145,7 +145,12 @@ async function testTopLevelNavigations(bfcacheInParent) { // Go back to the first page, this should be a bfcache navigation, and, // we should get a new target info("Go back to the first page"); + const onPageShow = BrowserTestUtils.waitForContentEvent( + gBrowser.selectedBrowser, + "pageshow" + ); gBrowser.selectedBrowser.goBack(); + await onPageShow; await waitFor( () => targets.length == 3, diff --git a/devtools/shared/commands/target/tests/browser_target_command_detach.js b/devtools/shared/commands/target/tests/browser_target_command_detach.js index a0056cd7a5..800832a111 100644 --- a/devtools/shared/commands/target/tests/browser_target_command_detach.js +++ b/devtools/shared/commands/target/tests/browser_target_command_detach.js @@ -30,9 +30,9 @@ add_task(async function () { info("Call any target front method, to ensure it works fine"); await targetCommand.targetFront.focus(); - // Destroying the target front should end up calling "WindowGlobalTargetActor.detach" - // which should destroy the target on the server side - await targetCommand.targetFront.destroy(); + // Simulate a toolbox closing by the cleanup of TargetCommand. + // This will stop watching for all target types and destroy all target actors/fronts. + await targetCommand.stopListening(); info( "Now create a second commands after destroy, to see if we can spawn a new, functional target" diff --git a/devtools/shared/commands/target/tests/browser_target_command_scope_flag.js b/devtools/shared/commands/target/tests/browser_target_command_scope_flag.js index 0ceaaf39ee..883cf9356b 100644 --- a/devtools/shared/commands/target/tests/browser_target_command_scope_flag.js +++ b/devtools/shared/commands/target/tests/browser_target_command_scope_flag.js @@ -27,6 +27,12 @@ add_task(async function () { const commands = await CommandsFactory.forMainProcess(); const targetCommand = commands.targetCommand; await targetCommand.startListening(); + + // Pass any configuration, in order to ensure attaching all the thread actors + await commands.threadConfigurationCommand.updateConfiguration({ + skipBreakpoints: false, + }); + const { TYPES } = targetCommand; const targets = new Set(); |