зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1500383 - Rename test helpers to enable stronger linting;r=daisuke,Ola
Using head-*.js as the name of a test helper makes it automagically visible from all tests in the suite thanks to the import-headjs-globals.js plugin. Renaming them to helper-*.js forces to explicitly import them and get linting errors if we forgot to do so. All helpers have been consistently renamed to helper-*.js. One method from the collapsibilities helper has been moved to the main head.js, because it doesn't have any relation with collapsing target panes. All ADB tests also now check that ADB is not running before starting. I tried forcing ADB to stop in this case, but we can't kill it from the tests apparently, so the only option is for the user to manually kill the process. At least now we get a somewhat helpful error message, and no timeout. Differential Revision: https://phabricator.services.mozilla.com/D15465 --HG-- rename : devtools/client/aboutdebugging-new/test/browser/head-addons-script.js => devtools/client/aboutdebugging-new/test/browser/helper-addons.js rename : devtools/client/aboutdebugging-new/test/browser/debug-target-pane_collapsibilities_head.js => devtools/client/aboutdebugging-new/test/browser/helper-collapsibilities.js rename : devtools/client/aboutdebugging-new/test/browser/head-mocks.js => devtools/client/aboutdebugging-new/test/browser/helper-mocks.js rename : devtools/client/aboutdebugging-new/test/browser/head-serviceworker.js => devtools/client/aboutdebugging-new/test/browser/helper-serviceworker.js rename : devtools/client/aboutdebugging-new/test/browser/mocks/head-client-wrapper-mock.js => devtools/client/aboutdebugging-new/test/browser/mocks/helper-client-wrapper-mock.js rename : devtools/client/aboutdebugging-new/test/browser/mocks/head-runtime-client-factory-mock.js => devtools/client/aboutdebugging-new/test/browser/mocks/helper-runtime-client-factory-mock.js rename : devtools/client/aboutdebugging-new/test/browser/mocks/head-usb-runtimes-mock.js => devtools/client/aboutdebugging-new/test/browser/mocks/helper-usb-runtimes-mock.js extra : moz-landing-system : lando
This commit is contained in:
Родитель
daa7fbeb2e
Коммит
a36a923325
|
@ -6,11 +6,12 @@ prefs =
|
|||
# ensure consistent test behavior by always setting this to false.
|
||||
devtools.aboutdebugging.showSystemAddons=false
|
||||
support-files =
|
||||
debug-target-pane_collapsibilities_head.js
|
||||
head-addons-script.js
|
||||
head-mocks.js
|
||||
head-serviceworker.js
|
||||
head.js
|
||||
helper-adb.js
|
||||
helper-addons.js
|
||||
helper-collapsibilities.js
|
||||
helper-mocks.js
|
||||
helper-serviceworker.js
|
||||
mocks/*
|
||||
resources/bad-extension/*
|
||||
resources/service-workers/*
|
||||
|
|
|
@ -1,22 +1,21 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
/* import-globals-from head-addons-script.js */
|
||||
|
||||
"use strict";
|
||||
|
||||
const { adbAddon } = require("devtools/shared/adb/adb-addon");
|
||||
|
||||
const ABD_ADDON_NAME = "ADB binary provider";
|
||||
|
||||
// Load addons helpers
|
||||
Services.scriptloader.loadSubScript(CHROME_URL_ROOT + "head-addons-script.js", this);
|
||||
/* import-globals-from helper-adb.js */
|
||||
Services.scriptloader.loadSubScript(CHROME_URL_ROOT + "helper-adb.js", this);
|
||||
|
||||
// Test that manifest URLs for addon targets show the manifest correctly in a new tab.
|
||||
// This test reuses the ADB extension to be sure to have a valid manifest URL to open.
|
||||
add_task(async function() {
|
||||
await pushPref("devtools.remote.adb.extensionURL",
|
||||
CHROME_URL_ROOT + "resources/test-adb-extension/adb-extension-#OS#.xpi");
|
||||
await checkAdbNotRunning();
|
||||
|
||||
const { document, tab, window } = await openAboutDebugging();
|
||||
const usbStatusElement = document.querySelector(".js-sidebar-usb-status");
|
||||
|
|
|
@ -9,8 +9,8 @@ const USB_RUNTIME_ID = "test-runtime-id";
|
|||
const USB_RUNTIME_DEVICE_NAME = "test device name";
|
||||
const USB_RUNTIME_APP_NAME = "TestUsbApp";
|
||||
|
||||
/* import-globals-from head-mocks.js */
|
||||
Services.scriptloader.loadSubScript(CHROME_URL_ROOT + "head-mocks.js", this);
|
||||
/* import-globals-from helper-mocks.js */
|
||||
Services.scriptloader.loadSubScript(CHROME_URL_ROOT + "helper-mocks.js", this);
|
||||
|
||||
// Test that addons are displayed and updated for USB runtimes when expected.
|
||||
add_task(async function() {
|
||||
|
|
|
@ -3,6 +3,9 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
/* import-globals-from helper-adb.js */
|
||||
Services.scriptloader.loadSubScript(CHROME_URL_ROOT + "helper-adb.js", this);
|
||||
|
||||
const { AddonManager } = require("resource://gre/modules/AddonManager.jsm");
|
||||
|
||||
/**
|
||||
|
@ -11,6 +14,7 @@ const { AddonManager } = require("resource://gre/modules/AddonManager.jsm");
|
|||
add_task(async function() {
|
||||
await pushPref("devtools.remote.adb.extensionURL",
|
||||
CHROME_URL_ROOT + "resources/test-adb-extension/adb-extension-#OS#.xpi");
|
||||
await checkAdbNotRunning();
|
||||
|
||||
const { document, tab } = await openAboutDebugging();
|
||||
|
||||
|
|
|
@ -3,9 +3,8 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
/* import-globals-from head-mocks.js */
|
||||
Services.scriptloader.loadSubScript(
|
||||
CHROME_URL_ROOT + "head-mocks.js", this);
|
||||
/* import-globals-from helper-mocks.js */
|
||||
Services.scriptloader.loadSubScript(CHROME_URL_ROOT + "helper-mocks.js", this);
|
||||
|
||||
/**
|
||||
* Check whether can toggle enable/disable connection prompt setting.
|
||||
|
|
|
@ -3,6 +3,9 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
/* import-globals-from helper-collapsibilities.js */
|
||||
Services.scriptloader.loadSubScript(CHROME_URL_ROOT + "helper-collapsibilities.js", this);
|
||||
|
||||
/**
|
||||
* Test that collapsibilities of DebugTargetPane on RuntimePage by mouse clicking.
|
||||
*/
|
||||
|
|
|
@ -3,6 +3,9 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
/* import-globals-from helper-collapsibilities.js */
|
||||
Services.scriptloader.loadSubScript(CHROME_URL_ROOT + "helper-collapsibilities.js", this);
|
||||
|
||||
/**
|
||||
* Test for preference of DebugTargetPane collapsibilities.
|
||||
*/
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
/* import-globals-from head-addons-script.js */
|
||||
|
||||
"use strict";
|
||||
|
||||
// Load addons helpers
|
||||
Services.scriptloader.loadSubScript(CHROME_URL_ROOT + "head-addons-script.js", this);
|
||||
/* import-globals-from helper-addons.js */
|
||||
Services.scriptloader.loadSubScript(CHROME_URL_ROOT + "helper-addons.js", this);
|
||||
/* import-globals-from helper-collapsibilities.js */
|
||||
Services.scriptloader.loadSubScript(CHROME_URL_ROOT + "helper-collapsibilities.js", this);
|
||||
|
||||
/**
|
||||
* Test that an "empty" message is displayed when there are no debug targets in a debug
|
||||
|
|
|
@ -3,13 +3,15 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
/* import-globals-from helper-collapsibilities.js */
|
||||
Services.scriptloader.loadSubScript(CHROME_URL_ROOT + "helper-collapsibilities.js", this);
|
||||
/* import-globals-from helper-mocks.js */
|
||||
Services.scriptloader.loadSubScript(CHROME_URL_ROOT + "helper-mocks.js", this);
|
||||
|
||||
const RUNTIME_ID = "test-runtime-id";
|
||||
const RUNTIME_DEVICE_NAME = "test device name";
|
||||
const RUNTIME_APP_NAME = "TestApp";
|
||||
|
||||
/* import-globals-from head-mocks.js */
|
||||
Services.scriptloader.loadSubScript(CHROME_URL_ROOT + "head-mocks.js", this);
|
||||
|
||||
// Test that the expected supported categories are displayed for USB runtimes.
|
||||
add_task(async function() {
|
||||
const mocks = new Mocks();
|
||||
|
|
|
@ -3,6 +3,9 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
/* import-globals-from helper-collapsibilities.js */
|
||||
Services.scriptloader.loadSubScript(CHROME_URL_ROOT + "helper-collapsibilities.js", this);
|
||||
|
||||
/**
|
||||
* Check that DevTools are not closed when leaving This Firefox runtime page.
|
||||
*/
|
||||
|
|
|
@ -3,6 +3,9 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
/* import-globals-from helper-collapsibilities.js */
|
||||
Services.scriptloader.loadSubScript(CHROME_URL_ROOT + "helper-collapsibilities.js", this);
|
||||
|
||||
/**
|
||||
* Check that navigating from This Firefox to Connect and back to This Firefox works and
|
||||
* does not leak.
|
||||
|
|
|
@ -9,8 +9,8 @@ const USB_RUNTIME_ID = "test-runtime-id";
|
|||
const USB_DEVICE_NAME = "test device name";
|
||||
const USB_APP_NAME = "TestApp";
|
||||
|
||||
/* import-globals-from head-mocks.js */
|
||||
Services.scriptloader.loadSubScript(CHROME_URL_ROOT + "head-mocks.js", this);
|
||||
/* import-globals-from helper-mocks.js */
|
||||
Services.scriptloader.loadSubScript(CHROME_URL_ROOT + "helper-mocks.js", this);
|
||||
|
||||
// Test that remote runtime connections are persisted across about:debugging reloads.
|
||||
add_task(async function() {
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
/* import-globals-from head-mocks.js */
|
||||
Services.scriptloader.loadSubScript(CHROME_URL_ROOT + "head-mocks.js", this);
|
||||
/* import-globals-from helper-mocks.js */
|
||||
Services.scriptloader.loadSubScript(CHROME_URL_ROOT + "helper-mocks.js", this);
|
||||
|
||||
/**
|
||||
* Test that the initial route is /runtime/this-firefox
|
||||
|
|
|
@ -3,9 +3,9 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
/* import-globals-from head-mocks.js */
|
||||
/* import-globals-from helper-mocks.js */
|
||||
Services.scriptloader.loadSubScript(
|
||||
CHROME_URL_ROOT + "head-mocks.js", this);
|
||||
CHROME_URL_ROOT + "helper-mocks.js", this);
|
||||
|
||||
/**
|
||||
* Test that remote runtimes show the connection prompt,
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
/* import-globals-from head-mocks.js */
|
||||
Services.scriptloader.loadSubScript(CHROME_URL_ROOT + "head-mocks.js", this);
|
||||
/* import-globals-from helper-mocks.js */
|
||||
Services.scriptloader.loadSubScript(CHROME_URL_ROOT + "helper-mocks.js", this);
|
||||
|
||||
const RUNTIME_DEVICE_ID = "1234";
|
||||
const RUNTIME_DEVICE_NAME = "A device";
|
||||
|
|
|
@ -3,14 +3,14 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
/* import-globals-from helper-mocks.js */
|
||||
Services.scriptloader.loadSubScript(CHROME_URL_ROOT + "helper-mocks.js", this);
|
||||
|
||||
const NETWORK_RUNTIME_HOST = "localhost:6080";
|
||||
const NETWORK_RUNTIME_APP_NAME = "TestNetworkApp";
|
||||
const NETWORK_RUNTIME_CHANNEL = "SomeChannel";
|
||||
const NETWORK_RUNTIME_VERSION = "12.3";
|
||||
|
||||
/* import-globals-from head-mocks.js */
|
||||
Services.scriptloader.loadSubScript(CHROME_URL_ROOT + "head-mocks.js", this);
|
||||
|
||||
// Test that network runtimes can be selected.
|
||||
add_task(async function() {
|
||||
const mocks = new Mocks();
|
||||
|
|
|
@ -1,12 +1,10 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
/* global sendAsyncMessage */
|
||||
|
||||
"use strict";
|
||||
|
||||
/* import-globals-from head-serviceworker.js */
|
||||
Services.scriptloader.loadSubScript(CHROME_URL_ROOT + "head-serviceworker.js", this);
|
||||
/* import-globals-from helper-serviceworker.js */
|
||||
Services.scriptloader.loadSubScript(CHROME_URL_ROOT + "helper-serviceworker.js", this);
|
||||
|
||||
const SERVICE_WORKER = URL_ROOT + "resources/service-workers/push-sw.js";
|
||||
const TAB_URL = URL_ROOT + "resources/service-workers/push-sw.html";
|
||||
|
|
|
@ -1,12 +1,10 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
/* global sendAsyncMessage */
|
||||
|
||||
"use strict";
|
||||
|
||||
/* import-globals-from head-serviceworker.js */
|
||||
Services.scriptloader.loadSubScript(CHROME_URL_ROOT + "head-serviceworker.js", this);
|
||||
/* import-globals-from helper-serviceworker.js */
|
||||
Services.scriptloader.loadSubScript(CHROME_URL_ROOT + "helper-serviceworker.js", this);
|
||||
|
||||
const SERVICE_WORKER = URL_ROOT + "resources/service-workers/push-sw.js";
|
||||
const TAB_URL = URL_ROOT + "resources/service-workers/push-sw.html";
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
/* import-globals-from head-mocks.js */
|
||||
Services.scriptloader.loadSubScript(CHROME_URL_ROOT + "head-mocks.js", this);
|
||||
/* import-globals-from helper-mocks.js */
|
||||
Services.scriptloader.loadSubScript(CHROME_URL_ROOT + "helper-mocks.js", this);
|
||||
|
||||
// Test that USB runtimes appear and disappear from the sidebar.
|
||||
add_task(async function() {
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
/* import-globals-from head-mocks.js */
|
||||
Services.scriptloader.loadSubScript(CHROME_URL_ROOT + "head-mocks.js", this);
|
||||
/* import-globals-from helper-mocks.js */
|
||||
Services.scriptloader.loadSubScript(CHROME_URL_ROOT + "helper-mocks.js", this);
|
||||
|
||||
const RUNTIME_ID = "test-runtime-id";
|
||||
const RUNTIME_DEVICE_NAME = "test device name";
|
||||
|
|
|
@ -3,6 +3,9 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
/* import-globals-from helper-mocks.js */
|
||||
Services.scriptloader.loadSubScript(CHROME_URL_ROOT + "helper-mocks.js", this);
|
||||
|
||||
const RUNTIME_ID = "test-runtime-id";
|
||||
const RUNTIME_DEVICE_NAME = "test device name";
|
||||
const RUNTIME_APP_NAME = "TestApp";
|
||||
|
@ -10,9 +13,6 @@ const RUNTIME_APP_NAME = "TestApp";
|
|||
const OTHER_RUNTIME_ID = "other-runtime-id";
|
||||
const OTHER_RUNTIME_APP_NAME = "OtherApp";
|
||||
|
||||
/* import-globals-from head-mocks.js */
|
||||
Services.scriptloader.loadSubScript(CHROME_URL_ROOT + "head-mocks.js", this);
|
||||
|
||||
// Test that USB runtimes are ot disconnected on refresh.
|
||||
add_task(async function() {
|
||||
const mocks = new Mocks();
|
||||
|
|
|
@ -3,12 +3,12 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
/* import-globals-from helper-mocks.js */
|
||||
Services.scriptloader.loadSubScript(CHROME_URL_ROOT + "helper-mocks.js", this);
|
||||
|
||||
const RUNTIME_DEVICE_ID = "1234";
|
||||
const RUNTIME_DEVICE_NAME = "A device";
|
||||
|
||||
/* import-globals-from head-mocks.js */
|
||||
Services.scriptloader.loadSubScript(CHROME_URL_ROOT + "head-mocks.js", this);
|
||||
|
||||
// Test that we can select a runtime in the sidebar
|
||||
add_task(async function() {
|
||||
const mocks = new Mocks();
|
||||
|
|
|
@ -3,6 +3,9 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
/* import-globals-from helper-adb.js */
|
||||
Services.scriptloader.loadSubScript(CHROME_URL_ROOT + "helper-adb.js", this);
|
||||
|
||||
const { adbAddon } = require("devtools/shared/adb/adb-addon");
|
||||
|
||||
/**
|
||||
|
@ -12,6 +15,7 @@ const { adbAddon } = require("devtools/shared/adb/adb-addon");
|
|||
add_task(async function() {
|
||||
await pushPref("devtools.remote.adb.extensionURL",
|
||||
CHROME_URL_ROOT + "resources/test-adb-extension/adb-extension-#OS#.xpi");
|
||||
await checkAdbNotRunning();
|
||||
|
||||
const { document, tab } = await openAboutDebugging();
|
||||
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
/* import-globals-from head-mocks.js */
|
||||
Services.scriptloader.loadSubScript(CHROME_URL_ROOT + "head-mocks.js", this);
|
||||
/* import-globals-from helper-mocks.js */
|
||||
Services.scriptloader.loadSubScript(CHROME_URL_ROOT + "helper-mocks.js", this);
|
||||
|
||||
const RUNTIME_NAME = "Firefox 123";
|
||||
|
||||
|
|
|
@ -3,6 +3,9 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
/* import-globals-from helper-adb.js */
|
||||
Services.scriptloader.loadSubScript(CHROME_URL_ROOT + "helper-adb.js", this);
|
||||
|
||||
const { adbAddon } = require("devtools/shared/adb/adb-addon");
|
||||
const { check } = require("devtools/shared/adb/adb-running-checker");
|
||||
|
||||
|
@ -14,14 +17,7 @@ const { check } = require("devtools/shared/adb/adb-running-checker");
|
|||
add_task(async function() {
|
||||
await pushPref("devtools.remote.adb.extensionURL",
|
||||
CHROME_URL_ROOT + "resources/test-adb-extension/adb-extension-#OS#.xpi");
|
||||
|
||||
info("Check if ADB is already running before the test starts");
|
||||
const isAdbAlreadyRunning = await check();
|
||||
if (isAdbAlreadyRunning) {
|
||||
ok(false, "The ADB process is already running on this machine, it should be " +
|
||||
"stopped before running this test");
|
||||
return;
|
||||
}
|
||||
await checkAdbNotRunning();
|
||||
|
||||
const { tab } = await openAboutDebugging();
|
||||
|
||||
|
|
|
@ -3,12 +3,12 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
/* import-globals-from mocks/head-client-wrapper-mock.js */
|
||||
/* import-globals-from mocks/helper-client-wrapper-mock.js */
|
||||
Services.scriptloader.loadSubScript(
|
||||
CHROME_URL_ROOT + "mocks/head-client-wrapper-mock.js", this);
|
||||
/* import-globals-from mocks/head-runtime-client-factory-mock.js */
|
||||
CHROME_URL_ROOT + "mocks/helper-client-wrapper-mock.js", this);
|
||||
/* import-globals-from mocks/helper-runtime-client-factory-mock.js */
|
||||
Services.scriptloader.loadSubScript(
|
||||
CHROME_URL_ROOT + "mocks/head-runtime-client-factory-mock.js", this);
|
||||
CHROME_URL_ROOT + "mocks/helper-runtime-client-factory-mock.js", this);
|
||||
|
||||
// Test that system addons are only displayed when the showSystemAddons preference is
|
||||
// true.
|
||||
|
|
|
@ -1,12 +1,10 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
/* import-globals-from head-addons-script.js */
|
||||
|
||||
"use strict";
|
||||
|
||||
// Load addons helpers
|
||||
Services.scriptloader.loadSubScript(CHROME_URL_ROOT + "head-addons-script.js", this);
|
||||
/* import-globals-from helper-addons.js */
|
||||
Services.scriptloader.loadSubScript(CHROME_URL_ROOT + "helper-addons.js", this);
|
||||
|
||||
/**
|
||||
* Test that the installation error messages are displayed when installing temporary
|
||||
|
|
|
@ -3,12 +3,12 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
/* import-globals-from mocks/head-client-wrapper-mock.js */
|
||||
/* import-globals-from mocks/helper-client-wrapper-mock.js */
|
||||
Services.scriptloader.loadSubScript(
|
||||
CHROME_URL_ROOT + "mocks/head-client-wrapper-mock.js", this);
|
||||
/* import-globals-from mocks/head-runtime-client-factory-mock.js */
|
||||
CHROME_URL_ROOT + "mocks/helper-client-wrapper-mock.js", this);
|
||||
/* import-globals-from mocks/helper-runtime-client-factory-mock.js */
|
||||
Services.scriptloader.loadSubScript(
|
||||
CHROME_URL_ROOT + "mocks/head-runtime-client-factory-mock.js", this);
|
||||
CHROME_URL_ROOT + "mocks/helper-runtime-client-factory-mock.js", this);
|
||||
|
||||
/**
|
||||
* Check that the runtime info is correctly displayed for ThisFirefox.
|
||||
|
|
|
@ -3,12 +3,13 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
/* import-globals-from mocks/head-client-wrapper-mock.js */
|
||||
/* import-globals-from mocks/helper-client-wrapper-mock.js */
|
||||
Services.scriptloader.loadSubScript(
|
||||
CHROME_URL_ROOT + "mocks/head-client-wrapper-mock.js", this);
|
||||
/* import-globals-from mocks/head-runtime-client-factory-mock.js */
|
||||
CHROME_URL_ROOT + "mocks/helper-client-wrapper-mock.js", this);
|
||||
/* import-globals-from mocks/helper-runtime-client-factory-mock.js */
|
||||
Services.scriptloader.loadSubScript(
|
||||
CHROME_URL_ROOT + "mocks/head-runtime-client-factory-mock.js", this);
|
||||
CHROME_URL_ROOT + "mocks/helper-runtime-client-factory-mock.js", this);
|
||||
|
||||
const { gDevToolsBrowser } = require("devtools/client/framework/devtools-browser");
|
||||
|
||||
add_task(async function() {
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
/* eslint-env browser */
|
||||
/* eslint no-unused-vars: [2, {"vars": "local"}] */
|
||||
/* import-globals-from ../../../shared/test/shared-head.js */
|
||||
/* import-globals-from debug-target-pane_collapsibilities_head.js */
|
||||
|
||||
"use strict";
|
||||
|
||||
// Load the shared-head file first.
|
||||
Services.scriptloader.loadSubScript(
|
||||
|
@ -18,10 +17,6 @@ Services.scriptloader.loadSubScript(
|
|||
"chrome://mochitests/content/browser/devtools/client/shared/test/shared-redux-head.js",
|
||||
this);
|
||||
|
||||
// Load collapsibilities helpers
|
||||
Services.scriptloader.loadSubScript(
|
||||
CHROME_URL_ROOT + "debug-target-pane_collapsibilities_head.js", this);
|
||||
|
||||
// Make sure the ADB addon is removed and ADB is stopped when the test ends.
|
||||
registerCleanupFunction(async function() {
|
||||
try {
|
||||
|
@ -153,6 +148,24 @@ async function selectConnectPage(doc) {
|
|||
await waitUntil(() => doc.querySelector(".js-connect-page"));
|
||||
}
|
||||
|
||||
function getDebugTargetPane(title, document) {
|
||||
// removes the suffix "(<NUMBER>)" in debug target pane's title, if needed
|
||||
const sanitizeTitle = (x) => {
|
||||
return x.replace(/\s+\(\d+\)$/, "");
|
||||
};
|
||||
|
||||
const targetTitle = sanitizeTitle(title);
|
||||
for (const titleEl of document.querySelectorAll(".js-debug-target-pane-title")) {
|
||||
if (sanitizeTitle(titleEl.textContent) !== targetTitle) {
|
||||
continue;
|
||||
}
|
||||
|
||||
return titleEl.closest(".js-debug-target-pane");
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
function findDebugTargetByText(text, document) {
|
||||
const targets = [...document.querySelectorAll(".js-debug-target-item")];
|
||||
return targets.find(target => target.textContent.includes(text));
|
||||
|
@ -193,27 +206,3 @@ async function selectRuntime(deviceName, name, document) {
|
|||
return runtimeInfo && runtimeInfo.textContent.includes(name);
|
||||
});
|
||||
}
|
||||
|
||||
// Returns a promise that resolves when the adb process exists and is running.
|
||||
async function waitForAdbStart() {
|
||||
info("Wait for ADB to start");
|
||||
const { adbProcess } = require("devtools/shared/adb/adb-process");
|
||||
const { check } = require("devtools/shared/adb/adb-running-checker");
|
||||
return asyncWaitUntil(async () => {
|
||||
const isProcessReady = adbProcess.ready;
|
||||
const isRunning = await check();
|
||||
return isProcessReady && isRunning;
|
||||
});
|
||||
}
|
||||
|
||||
// Returns a promise that resolves when the adb process is no longer running.
|
||||
async function waitForAdbStop() {
|
||||
info("Wait for ADB to stop");
|
||||
const { adbProcess } = require("devtools/shared/adb/adb-process");
|
||||
const { check } = require("devtools/shared/adb/adb-running-checker");
|
||||
return asyncWaitUntil(async () => {
|
||||
const isProcessReady = adbProcess.ready;
|
||||
const isRunning = await check();
|
||||
return !isProcessReady && !isRunning;
|
||||
});
|
||||
}
|
||||
|
|
|
@ -0,0 +1,43 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
/* import-globals-from head.js */
|
||||
|
||||
async function checkAdbNotRunning() {
|
||||
info("Check if ADB is already running before the test starts");
|
||||
const { check } = require("devtools/shared/adb/adb-running-checker");
|
||||
const isAdbAlreadyRunning = await check();
|
||||
if (isAdbAlreadyRunning) {
|
||||
throw new Error("The ADB process is already running on this machine, it should be " +
|
||||
"stopped before running this test");
|
||||
}
|
||||
}
|
||||
/* exported checkAdbNotRunning */
|
||||
|
||||
// Returns a promise that resolves when the adb process exists and is running.
|
||||
async function waitForAdbStart() {
|
||||
info("Wait for ADB to start");
|
||||
const { adbProcess } = require("devtools/shared/adb/adb-process");
|
||||
const { check } = require("devtools/shared/adb/adb-running-checker");
|
||||
return asyncWaitUntil(async () => {
|
||||
const isProcessReady = adbProcess.ready;
|
||||
const isRunning = await check();
|
||||
return isProcessReady && isRunning;
|
||||
});
|
||||
}
|
||||
/* exported waitForAdbStart */
|
||||
|
||||
// Returns a promise that resolves when the adb process is no longer running.
|
||||
async function waitForAdbStop() {
|
||||
info("Wait for ADB to stop");
|
||||
const { adbProcess } = require("devtools/shared/adb/adb-process");
|
||||
const { check } = require("devtools/shared/adb/adb-running-checker");
|
||||
return asyncWaitUntil(async () => {
|
||||
const isProcessReady = adbProcess.ready;
|
||||
const isRunning = await check();
|
||||
return !isProcessReady && !isRunning;
|
||||
});
|
||||
}
|
||||
/* exported waitForAdbStop */
|
|
@ -1,13 +1,13 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
/* import-globals-from ../../../shared/test/shared-head.js */
|
||||
/* import-globals-from head.js */
|
||||
|
||||
"use strict";
|
||||
|
||||
/* import-globals-from head.js */
|
||||
|
||||
const { Management } = ChromeUtils.import("resource://gre/modules/Extension.jsm", {});
|
||||
|
||||
function getSupportsFile(path) {
|
||||
function _getSupportsFile(path) {
|
||||
const cr = Cc["@mozilla.org/chrome/chrome-registry;1"]
|
||||
.getService(Ci.nsIChromeRegistry);
|
||||
const uri = Services.io.newURI(CHROME_URL_ROOT + path);
|
||||
|
@ -19,7 +19,6 @@ function getSupportsFile(path) {
|
|||
* Install a temporary extension at the provided path, with the provided name.
|
||||
* Will use a mock file picker to select the file.
|
||||
*/
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
async function installTemporaryExtension(path, name, document) {
|
||||
// Mock the file picker to select a test addon
|
||||
prepareMockFilePicker(path);
|
||||
|
@ -41,6 +40,7 @@ async function installTemporaryExtension(path, name, document) {
|
|||
info("Wait for addon to be installed");
|
||||
await onAddonInstalled;
|
||||
}
|
||||
/* exported installTemporaryExtension */
|
||||
|
||||
async function removeTemporaryExtension(name, document) {
|
||||
info(`Remove the temporary extension with name: '${name}'`);
|
||||
|
@ -50,10 +50,12 @@ async function removeTemporaryExtension(name, document) {
|
|||
info("Wait until the debug target item disappears");
|
||||
await waitUntil(() => !findDebugTargetByText(name, document));
|
||||
}
|
||||
/* exported removeTemporaryExtension */
|
||||
|
||||
function prepareMockFilePicker(path) {
|
||||
// Mock the file picker to select a test addon
|
||||
const MockFilePicker = SpecialPowers.MockFilePicker;
|
||||
MockFilePicker.init(window);
|
||||
MockFilePicker.setFiles([getSupportsFile(path).file]);
|
||||
MockFilePicker.setFiles([_getSupportsFile(path).file]);
|
||||
}
|
||||
/* exported prepareMockFilePicker */
|
|
@ -3,7 +3,6 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
const TARGET_PANES = [
|
||||
{
|
||||
title: "Temporary Extensions",
|
||||
|
@ -30,41 +29,23 @@ const TARGET_PANES = [
|
|||
pref: "devtools.aboutdebugging.collapsibilities.otherWorker",
|
||||
},
|
||||
];
|
||||
/* exported TARGET_PANES */
|
||||
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
function getDebugTargetPane(title, document) {
|
||||
// removes the suffix "(<NUMBER>)" in debug target pane's title, if needed
|
||||
const sanitizeTitle = (x) => {
|
||||
return x.replace(/\s+\(\d+\)$/, "");
|
||||
};
|
||||
|
||||
const targetTitle = sanitizeTitle(title);
|
||||
for (const titleEl of document.querySelectorAll(".js-debug-target-pane-title")) {
|
||||
if (sanitizeTitle(titleEl.textContent) !== targetTitle) {
|
||||
continue;
|
||||
}
|
||||
|
||||
return titleEl.closest(".js-debug-target-pane");
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
function prepareCollapsibilitiesTest() {
|
||||
// Make all collapsibilities to be expanded.
|
||||
for (const { pref } of TARGET_PANES) {
|
||||
Services.prefs.setBoolPref(pref, false);
|
||||
}
|
||||
}
|
||||
/* exported prepareCollapsibilitiesTest */
|
||||
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
async function toggleCollapsibility(debugTargetPane) {
|
||||
debugTargetPane.querySelector(".js-debug-target-pane-title").click();
|
||||
// Wait for animation of collapse/expand.
|
||||
const animations = debugTargetPane.ownerDocument.getAnimations();
|
||||
await Promise.all(animations.map(animation => animation.finished));
|
||||
}
|
||||
/* exported toggleCollapsibility */
|
||||
|
||||
registerCleanupFunction(() => {
|
||||
for (const { pref } of TARGET_PANES) {
|
|
@ -3,18 +3,19 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
/* import-globals-from ../../../shared/test/shared-head.js */
|
||||
|
||||
const MOCKS_ROOT = CHROME_URL_ROOT + "mocks/";
|
||||
/* import-globals-from mocks/helper-client-wrapper-mock.js */
|
||||
Services.scriptloader.loadSubScript(MOCKS_ROOT + "helper-client-wrapper-mock.js", this);
|
||||
/* import-globals-from mocks/helper-runtime-client-factory-mock.js */
|
||||
Services.scriptloader.loadSubScript(MOCKS_ROOT + "helper-runtime-client-factory-mock.js",
|
||||
this);
|
||||
/* import-globals-from mocks/helper-usb-runtimes-mock.js */
|
||||
Services.scriptloader.loadSubScript(MOCKS_ROOT + "helper-usb-runtimes-mock.js", this);
|
||||
|
||||
const { RUNTIMES } = require("devtools/client/aboutdebugging-new/src/constants");
|
||||
|
||||
/* import-globals-from mocks/head-client-wrapper-mock.js */
|
||||
Services.scriptloader.loadSubScript(MOCKS_ROOT + "head-client-wrapper-mock.js", this);
|
||||
/* import-globals-from mocks/head-runtime-client-factory-mock.js */
|
||||
Services.scriptloader.loadSubScript(MOCKS_ROOT + "head-runtime-client-factory-mock.js",
|
||||
this);
|
||||
/* import-globals-from mocks/head-usb-runtimes-mock.js */
|
||||
Services.scriptloader.loadSubScript(MOCKS_ROOT + "head-usb-runtimes-mock.js", this);
|
||||
|
||||
/**
|
||||
* This wrapper around the mocks used in about:debugging tests provides helpers to
|
||||
* quickly setup mocks for runtime tests involving USB, network or wifi runtimes that can
|
||||
|
@ -160,3 +161,5 @@ class Mocks {
|
|||
}
|
||||
}
|
||||
}
|
||||
/* exported Mocks */
|
||||
|
|
@ -1,10 +1,10 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
/* import-globals-from ../../../shared/test/shared-head.js */
|
||||
/* import-globals-from head.js */
|
||||
|
||||
"use strict";
|
||||
|
||||
/* import-globals-from head.js */
|
||||
|
||||
/**
|
||||
* Temporarily flip all the preferences necessary for service worker testing.
|
||||
*/
|
||||
|
@ -19,6 +19,7 @@ async function enableServiceWorkerDebugging() {
|
|||
await pushPref("dom.ipc.processCount", 1);
|
||||
Services.ppmm.releaseCachedProcesses();
|
||||
}
|
||||
/* exported enableServiceWorkerDebugging */
|
||||
|
||||
/**
|
||||
* Helper to listen once on a message sent using postMessage from the provided tab.
|
||||
|
@ -37,6 +38,7 @@ function onTabMessage(tab, message) {
|
|||
});
|
||||
});
|
||||
}
|
||||
/* exported onTabMessage */
|
||||
|
||||
async function waitForServiceWorkerRunning(workerText, document) {
|
||||
await waitUntil(() => {
|
||||
|
@ -47,6 +49,7 @@ async function waitForServiceWorkerRunning(workerText, document) {
|
|||
|
||||
return findDebugTargetByText(workerText, document);
|
||||
}
|
||||
/* exported waitForServiceWorkerRunning */
|
||||
|
||||
/**
|
||||
* Helper to listen once on a message sent using postMessage from the provided tab.
|
||||
|
@ -65,6 +68,7 @@ function forwardServiceWorkerMessage(tab) {
|
|||
});
|
||||
});
|
||||
}
|
||||
/* exported forwardServiceWorkerMessage */
|
||||
|
||||
/**
|
||||
* Unregister the service worker from the content page. The content page should define
|
||||
|
@ -82,3 +86,4 @@ async function unregisterServiceWorker(tab) {
|
|||
win.getRegistration().unregister();
|
||||
});
|
||||
}
|
||||
/* exported unregisterServiceWorker */
|
|
@ -1,6 +1,5 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
/* import-globals-from ../../../../shared/test/shared-head.js */
|
||||
|
||||
"use strict";
|
||||
|
||||
|
@ -106,3 +105,5 @@ function createThisFirefoxClientMock() {
|
|||
|
||||
return mockThisFirefoxClient;
|
||||
}
|
||||
/* exported createThisFirefoxClientMock */
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
/* import-globals-from ../../../../shared/test/shared-head.js */
|
||||
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
|
@ -16,6 +16,7 @@ function enableRuntimeClientFactoryMock(mock) {
|
|||
setMockedModule(mock,
|
||||
"devtools/client/aboutdebugging-new/src/modules/runtime-client-factory");
|
||||
}
|
||||
/* exported enableRuntimeClientFactoryMock */
|
||||
|
||||
/**
|
||||
* Update the loader to clear the mock entry for the runtime-client-factory module.
|
||||
|
@ -25,6 +26,7 @@ function disableRuntimeClientFactoryMock() {
|
|||
removeMockedModule(
|
||||
"devtools/client/aboutdebugging-new/src/modules/runtime-client-factory");
|
||||
}
|
||||
/* exported disableRuntimeClientFactoryMock */
|
||||
|
||||
/**
|
||||
* Creates a simple mock version for runtime-client-factory, implementing all the expected
|
||||
|
@ -38,3 +40,4 @@ function createRuntimeClientFactoryMock() {
|
|||
|
||||
return RuntimeClientFactoryMock;
|
||||
}
|
||||
/* exported createRuntimeClientFactoryMock */
|
|
@ -1,6 +1,5 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
/* import-globals-from ../../../../shared/test/shared-head.js */
|
||||
|
||||
"use strict";
|
||||
|
||||
|
@ -21,6 +20,7 @@ function enableUsbRuntimesMock(mock) {
|
|||
setMockedModule(mock,
|
||||
"devtools/client/aboutdebugging-new/src/modules/usb-runtimes");
|
||||
}
|
||||
/* exported enableUsbRuntimesMock */
|
||||
|
||||
/**
|
||||
* Update the loader to clear the mock entry for the usb-runtimes module.
|
||||
|
@ -30,6 +30,7 @@ function disableUsbRuntimesMock() {
|
|||
removeMockedModule(
|
||||
"devtools/client/aboutdebugging-new/src/modules/usb-runtimes");
|
||||
}
|
||||
/* exported disableUsbRuntimesMock */
|
||||
|
||||
/**
|
||||
* Creates a simple mock version for usb-runtimes, implementing all the expected methods
|
||||
|
@ -63,6 +64,7 @@ function createUsbRuntimesMock() {
|
|||
|
||||
return usbRuntimesMock;
|
||||
}
|
||||
/* exported createUsbRuntimesMock */
|
||||
|
||||
/**
|
||||
* The usb-runtimes module allows to observer runtime updates. To simulate this behaviour
|
||||
|
@ -90,3 +92,4 @@ function addObserverMock(usbRuntimesMock) {
|
|||
|
||||
return observerMock;
|
||||
}
|
||||
/* exported addObserverMock */
|
|
@ -26,7 +26,7 @@ const registerServiceWorker = async function() {
|
|||
}
|
||||
};
|
||||
|
||||
// Helper called from head-serviceworker.js to unregister the service worker.
|
||||
// Helper called from helper-serviceworker.js to unregister the service worker.
|
||||
window.getRegistration = function() {
|
||||
return registration;
|
||||
};
|
||||
|
|
Загрузка…
Ссылка в новой задаче