diff --git a/remote/test/browser/browser_page_javascriptDialog_alert.js b/remote/test/browser/browser_page_javascriptDialog_alert.js index a6d5ff1f89c3..2bcab178b617 100644 --- a/remote/test/browser/browser_page_javascriptDialog_alert.js +++ b/remote/test/browser/browser_page_javascriptDialog_alert.js @@ -3,12 +3,10 @@ "use strict"; -const TEST_URI = "data:text/html;charset=utf-8,default-test-page"; - // Test a browser alert is detected via Page.javascriptDialogOpening and can be // closed with Page.handleJavaScriptDialog add_task(async function() { - const { client, tab } = await setupTestForUri(TEST_URI); + const { client, tab } = await setup(); const { Page } = client; diff --git a/remote/test/browser/browser_page_javascriptDialog_beforeunload.js b/remote/test/browser/browser_page_javascriptDialog_beforeunload.js index ce752d5c59f2..500ed6a1ac22 100644 --- a/remote/test/browser/browser_page_javascriptDialog_beforeunload.js +++ b/remote/test/browser/browser_page_javascriptDialog_beforeunload.js @@ -3,8 +3,6 @@ "use strict"; -const TEST_URI = "data:text/html;charset=utf-8,default-test-page"; - // Test beforeunload dialog events. add_task(async function() { info("Allow to trigger onbeforeunload without user interaction"); @@ -15,7 +13,7 @@ add_task(async function() { SpecialPowers.pushPrefEnv(options, resolve); }); - const { client, tab } = await setupTestForUri(TEST_URI); + const { client, tab } = await setup(); const { Page } = client; diff --git a/remote/test/browser/browser_page_javascriptDialog_confirm.js b/remote/test/browser/browser_page_javascriptDialog_confirm.js index 015742156c64..dfea7958c9e7 100644 --- a/remote/test/browser/browser_page_javascriptDialog_confirm.js +++ b/remote/test/browser/browser_page_javascriptDialog_confirm.js @@ -3,12 +3,10 @@ "use strict"; -const TEST_URI = "data:text/html;charset=utf-8,default-test-page"; - // Test for window.confirm(). Check that the dialog is correctly detected and that it can // be rejected or accepted. add_task(async function() { - const { client, tab } = await setupTestForUri(TEST_URI); + const { client, tab } = await setup(); const { Page } = client; diff --git a/remote/test/browser/browser_page_javascriptDialog_otherTarget.js b/remote/test/browser/browser_page_javascriptDialog_otherTarget.js index 40746eb140f2..73cff3b019fe 100644 --- a/remote/test/browser/browser_page_javascriptDialog_otherTarget.js +++ b/remote/test/browser/browser_page_javascriptDialog_otherTarget.js @@ -3,13 +3,13 @@ "use strict"; -const TEST_URI = "data:text/html;charset=utf-8,default-test-page"; -const OTHER_URI = "data:text/html;charset=utf-8,other-test-page"; +const FIRST_DOC = toDataURL("default-test-page"); +const SECOND_DOC = toDataURL("other-test-page"); // Test that javascript dialog events are emitted by the page domain only if // the dialog is created for the window of the target. add_task(async function() { - const { client, tab } = await setupTestForUri(TEST_URI); + const { client, tab } = await setupForURL(FIRST_DOC); const { Page } = client; @@ -24,7 +24,7 @@ add_task(async function() { info("Open another tab"); const otherTab = await BrowserTestUtils.openNewForegroundTab( gBrowser, - OTHER_URI + SECOND_DOC ); is(gBrowser.selectedTab, otherTab, "Selected tab is now the new tab"); diff --git a/remote/test/browser/browser_page_javascriptDialog_prompt.js b/remote/test/browser/browser_page_javascriptDialog_prompt.js index dc3efaebb83d..c3e30be11815 100644 --- a/remote/test/browser/browser_page_javascriptDialog_prompt.js +++ b/remote/test/browser/browser_page_javascriptDialog_prompt.js @@ -3,12 +3,10 @@ "use strict"; -const TEST_URI = "data:text/html;charset=utf-8,default-test-page"; - // Test for window.prompt(). Check that the dialog is correctly detected and that it can // be rejected or accepted, with a custom prompt text. add_task(async function() { - const { client, tab } = await setupTestForUri(TEST_URI); + const { client, tab } = await setup(); const { Page } = client; diff --git a/remote/test/browser/browser_runtime_callFunctionOn.js b/remote/test/browser/browser_runtime_callFunctionOn.js index 5e491943a3fe..4b6bba4364fb 100644 --- a/remote/test/browser/browser_runtime_callFunctionOn.js +++ b/remote/test/browser/browser_runtime_callFunctionOn.js @@ -7,7 +7,7 @@ // See also browser_runtime_evaluate, which covers basic usages of this method. add_task(async function() { - const { client } = await setupForURL(toDataURL("")); + const { client } = await setup(); const firstContext = await testRuntimeEnable(client); const contextId = firstContext.id; diff --git a/remote/test/browser/browser_runtime_get_properties.js b/remote/test/browser/browser_runtime_get_properties.js index 42700a146cfd..7fc121b09ce8 100644 --- a/remote/test/browser/browser_runtime_get_properties.js +++ b/remote/test/browser/browser_runtime_get_properties.js @@ -6,7 +6,7 @@ // Test the Runtime remote object add_task(async function() { - const { client } = await setupForURL(toDataURL("")); + const { client } = await setup(); const firstContext = await testRuntimeEnable(client); const contextId = firstContext.id; diff --git a/remote/test/browser/browser_runtime_remote_objects.js b/remote/test/browser/browser_runtime_remote_objects.js index 7cb45ae3c9e8..c23b334a1460 100644 --- a/remote/test/browser/browser_runtime_remote_objects.js +++ b/remote/test/browser/browser_runtime_remote_objects.js @@ -6,7 +6,7 @@ // Test the Runtime remote object add_task(async function() { - const { client } = await setupForURL(toDataURL("")); + const { client } = await setup(); const firstContext = await testRuntimeEnable(client); const contextId = firstContext.id; diff --git a/remote/test/browser/head.js b/remote/test/browser/head.js index a9606c90228b..183d9822018f 100644 --- a/remote/test/browser/head.js +++ b/remote/test/browser/head.js @@ -101,6 +101,14 @@ function getTargets(CDP) { }); } +/** + * Set up test environment in same fashion as setupForURL(), + * except using an empty document. + */ +async function setup() { + return setupForURL(toDataURL("")); +} + /** * Set up test environment by starting the remote agent, connecting * the CDP client over loopback, and creating a fresh tab to avoid