forked from mirrors/gecko-dev
bug 1570378: remote: add bc test helper setup() for empty documents r=remote-protocol-reviewers,jdescottes
For many browser-chrome (bc) tests is does not matter what the
document is, as long as it is does not cause state to bleed over
from the previous test.
For these cases this patch introduces a shorthand, setup(), which
calls setupForURL(url) with an empty document generated by toDataURL("").
Differential Revision: https://phabricator.services.mozilla.com/D40216
--HG--
extra : moz-landing-system : lando
This commit is contained in:
parent
53d0ddbba2
commit
37c8f955e6
9 changed files with 19 additions and 19 deletions
|
|
@ -3,12 +3,10 @@
|
||||||
|
|
||||||
"use strict";
|
"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
|
// Test a browser alert is detected via Page.javascriptDialogOpening and can be
|
||||||
// closed with Page.handleJavaScriptDialog
|
// closed with Page.handleJavaScriptDialog
|
||||||
add_task(async function() {
|
add_task(async function() {
|
||||||
const { client, tab } = await setupTestForUri(TEST_URI);
|
const { client, tab } = await setup();
|
||||||
|
|
||||||
const { Page } = client;
|
const { Page } = client;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,6 @@
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
const TEST_URI = "data:text/html;charset=utf-8,default-test-page";
|
|
||||||
|
|
||||||
// Test beforeunload dialog events.
|
// Test beforeunload dialog events.
|
||||||
add_task(async function() {
|
add_task(async function() {
|
||||||
info("Allow to trigger onbeforeunload without user interaction");
|
info("Allow to trigger onbeforeunload without user interaction");
|
||||||
|
|
@ -15,7 +13,7 @@ add_task(async function() {
|
||||||
SpecialPowers.pushPrefEnv(options, resolve);
|
SpecialPowers.pushPrefEnv(options, resolve);
|
||||||
});
|
});
|
||||||
|
|
||||||
const { client, tab } = await setupTestForUri(TEST_URI);
|
const { client, tab } = await setup();
|
||||||
|
|
||||||
const { Page } = client;
|
const { Page } = client;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,12 +3,10 @@
|
||||||
|
|
||||||
"use strict";
|
"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
|
// Test for window.confirm(). Check that the dialog is correctly detected and that it can
|
||||||
// be rejected or accepted.
|
// be rejected or accepted.
|
||||||
add_task(async function() {
|
add_task(async function() {
|
||||||
const { client, tab } = await setupTestForUri(TEST_URI);
|
const { client, tab } = await setup();
|
||||||
|
|
||||||
const { Page } = client;
|
const { Page } = client;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,13 +3,13 @@
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
const TEST_URI = "data:text/html;charset=utf-8,default-test-page";
|
const FIRST_DOC = toDataURL("default-test-page");
|
||||||
const OTHER_URI = "data:text/html;charset=utf-8,other-test-page";
|
const SECOND_DOC = toDataURL("other-test-page");
|
||||||
|
|
||||||
// Test that javascript dialog events are emitted by the page domain only if
|
// Test that javascript dialog events are emitted by the page domain only if
|
||||||
// the dialog is created for the window of the target.
|
// the dialog is created for the window of the target.
|
||||||
add_task(async function() {
|
add_task(async function() {
|
||||||
const { client, tab } = await setupTestForUri(TEST_URI);
|
const { client, tab } = await setupForURL(FIRST_DOC);
|
||||||
|
|
||||||
const { Page } = client;
|
const { Page } = client;
|
||||||
|
|
||||||
|
|
@ -24,7 +24,7 @@ add_task(async function() {
|
||||||
info("Open another tab");
|
info("Open another tab");
|
||||||
const otherTab = await BrowserTestUtils.openNewForegroundTab(
|
const otherTab = await BrowserTestUtils.openNewForegroundTab(
|
||||||
gBrowser,
|
gBrowser,
|
||||||
OTHER_URI
|
SECOND_DOC
|
||||||
);
|
);
|
||||||
is(gBrowser.selectedTab, otherTab, "Selected tab is now the new tab");
|
is(gBrowser.selectedTab, otherTab, "Selected tab is now the new tab");
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,12 +3,10 @@
|
||||||
|
|
||||||
"use strict";
|
"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
|
// Test for window.prompt(). Check that the dialog is correctly detected and that it can
|
||||||
// be rejected or accepted, with a custom prompt text.
|
// be rejected or accepted, with a custom prompt text.
|
||||||
add_task(async function() {
|
add_task(async function() {
|
||||||
const { client, tab } = await setupTestForUri(TEST_URI);
|
const { client, tab } = await setup();
|
||||||
|
|
||||||
const { Page } = client;
|
const { Page } = client;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
// See also browser_runtime_evaluate, which covers basic usages of this method.
|
// See also browser_runtime_evaluate, which covers basic usages of this method.
|
||||||
|
|
||||||
add_task(async function() {
|
add_task(async function() {
|
||||||
const { client } = await setupForURL(toDataURL(""));
|
const { client } = await setup();
|
||||||
|
|
||||||
const firstContext = await testRuntimeEnable(client);
|
const firstContext = await testRuntimeEnable(client);
|
||||||
const contextId = firstContext.id;
|
const contextId = firstContext.id;
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
// Test the Runtime remote object
|
// Test the Runtime remote object
|
||||||
|
|
||||||
add_task(async function() {
|
add_task(async function() {
|
||||||
const { client } = await setupForURL(toDataURL(""));
|
const { client } = await setup();
|
||||||
|
|
||||||
const firstContext = await testRuntimeEnable(client);
|
const firstContext = await testRuntimeEnable(client);
|
||||||
const contextId = firstContext.id;
|
const contextId = firstContext.id;
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
// Test the Runtime remote object
|
// Test the Runtime remote object
|
||||||
|
|
||||||
add_task(async function() {
|
add_task(async function() {
|
||||||
const { client } = await setupForURL(toDataURL(""));
|
const { client } = await setup();
|
||||||
|
|
||||||
const firstContext = await testRuntimeEnable(client);
|
const firstContext = await testRuntimeEnable(client);
|
||||||
const contextId = firstContext.id;
|
const contextId = firstContext.id;
|
||||||
|
|
|
||||||
|
|
@ -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
|
* Set up test environment by starting the remote agent, connecting
|
||||||
* the CDP client over loopback, and creating a fresh tab to avoid
|
* the CDP client over loopback, and creating a fresh tab to avoid
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue