Bug 1497447: Add test for connection prompt preference setting. r=jdescottes

Depends on D9067

Differential Revision: https://phabricator.services.mozilla.com/D9068

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Daisuke Akatsuka 2018-10-23 01:13:44 +00:00
Родитель b124f68dec
Коммит 39993dba21
5 изменённых файлов: 53 добавлений и 12 удалений

Просмотреть файл

@ -39,7 +39,7 @@ class ConnectionPromptSetting extends PureComponent {
}, },
dom.button( dom.button(
{ {
className: "default-button", className: "default-button js-connection-prompt-toggle-button",
onClick: () => this.onToggleClick(), onClick: () => this.onToggleClick(),
}, },
localizedState localizedState

Просмотреть файл

@ -13,6 +13,7 @@ support-files =
[browser_aboutdebugging_connect_networklocations.js] [browser_aboutdebugging_connect_networklocations.js]
[browser_aboutdebugging_connect_toggle_usb_devices.js] [browser_aboutdebugging_connect_toggle_usb_devices.js]
skip-if = (os == 'linux' && bits == 32) # ADB start() fails on linux 32, see Bug 1499638 skip-if = (os == 'linux' && bits == 32) # ADB start() fails on linux 32, see Bug 1499638
[browser_aboutdebugging_connection_prompt_setting.js]
[browser_aboutdebugging_debug-target-pane_collapsibilities_interaction.js] [browser_aboutdebugging_debug-target-pane_collapsibilities_interaction.js]
[browser_aboutdebugging_debug-target-pane_collapsibilities_preference.js] [browser_aboutdebugging_debug-target-pane_collapsibilities_preference.js]
[browser_aboutdebugging_debug-target-pane_empty.js] [browser_aboutdebugging_debug-target-pane_empty.js]

Просмотреть файл

@ -0,0 +1,40 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
/**
* Check whether can toggle enable/disable connection prompt setting.
*/
add_task(async function() {
info("Set initial state for test");
await pushPref("devtools.debugger.prompt-connection", true);
const { document, tab } = await openAboutDebugging();
info("Check whether connection prompt toggle button exists");
const connectionPromptToggleButton =
document.querySelector(".js-connection-prompt-toggle-button");
ok(connectionPromptToggleButton, "Toggle button existed");
await waitUntil(() => connectionPromptToggleButton.textContent.includes("Disable"));
info("Click on the toggle button");
connectionPromptToggleButton.click();
info("Wait until the toggle button text is updated");
await waitUntil(() => connectionPromptToggleButton.textContent.includes("Enable"));
info("Check the preference");
is(Services.prefs.getBoolPref("devtools.debugger.prompt-connection"),
false,
"The preference should be updated");
info("Click on the toggle button again");
connectionPromptToggleButton.click();
info("Wait until the toggle button text is updated");
await waitUntil(() => connectionPromptToggleButton.textContent.includes("Disable"));
info("Check the preference");
is(Services.prefs.getBoolPref("devtools.debugger.prompt-connection"),
true,
"The preference should be updated");
await removeTab(tab);
});

Просмотреть файл

@ -25,12 +25,6 @@ add_task(async function() {
ok(isSidebarItemSelected(thisFirefoxSidebarItem), ok(isSidebarItemSelected(thisFirefoxSidebarItem),
"ThisFirefox sidebar item is selected by default"); "ThisFirefox sidebar item is selected by default");
// Wait until the about:debugging target is visible in the tab list
// Otherwise, we might have a race condition where TAB1 is discovered by the initial
// listTabs from the watchRuntime action, instead of being discovered after the
// TAB_UPDATED event. See analysis in Bug 1493968.
await waitUntil(() => findDebugTargetByText("about:debugging", document));
info("Open a new background tab TAB1"); info("Open a new background tab TAB1");
const backgroundTab1 = await addTab(TAB_URL_1, { background: true }); const backgroundTab1 = await addTab(TAB_URL_1, { background: true });
@ -78,8 +72,3 @@ add_task(async function() {
function isSidebarItemSelected(item) { function isSidebarItemSelected(item) {
return item.classList.contains("js-sidebar-item-selected"); return item.classList.contains("js-sidebar-item-selected");
} }
function findDebugTargetByText(text, document) {
const targets = [...document.querySelectorAll(".js-debug-target-item")];
return targets.find(target => target.textContent.includes(text));
}

Просмотреть файл

@ -51,6 +51,12 @@ async function openAboutDebugging(page, win) {
info("Wait until the client connection was established"); info("Wait until the client connection was established");
await waitUntil(() => document.querySelector(".js-runtime-page")); await waitUntil(() => document.querySelector(".js-runtime-page"));
// Wait until the about:debugging target is visible in the tab list
// Otherwise, we might have a race condition where TAB1 is discovered by the initial
// listTabs from the watchRuntime action, instead of being discovered after the
// TAB_UPDATED event. See analysis in Bug 1493968.
await waitUntil(() => findDebugTargetByText("about:debugging", document));
return { tab, document, window }; return { tab, document, window };
} }
@ -71,6 +77,11 @@ async function selectConnectPage(doc) {
await waitUntil(() => doc.querySelector(".js-connect-page")); await waitUntil(() => doc.querySelector(".js-connect-page"));
} }
function findDebugTargetByText(text, document) {
const targets = [...document.querySelectorAll(".js-debug-target-item")];
return targets.find(target => target.textContent.includes(text));
}
function findSidebarItemByText(text, document) { function findSidebarItemByText(text, document) {
const sidebarItems = document.querySelectorAll(".js-sidebar-item"); const sidebarItems = document.querySelectorAll(".js-sidebar-item");
return [...sidebarItems].find(element => { return [...sidebarItems].find(element => {