Loading devtools/client/aboutdebugging/test/browser/helper-addons.js +2 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,8 @@ function _getSupportsFile(path) { async function enableExtensionDebugging() { // Disable security prompt await pushPref("devtools.debugger.prompt-connection", false); // Enable Browser toolbox test script execution via env variable await pushPref("devtools.browser-toolbox.allow-unsafe-script", true); } /* exported enableExtensionDebugging */ Loading devtools/client/framework/moz.build +1 −0 Original line number Diff line number Diff line Loading @@ -6,6 +6,7 @@ BROWSER_CHROME_MANIFESTS += [ 'test/allocations/browser_allocations_target.ini', 'test/browser-rtl.ini', 'test/browser-telemetry-startup.ini', 'test/browser.ini', 'test/metrics/browser_metrics_debugger.ini', Loading devtools/client/framework/test/browser-rtl.ini 0 → 100644 +14 −0 Original line number Diff line number Diff line [DEFAULT] tags = devtools subsuite = devtools prefs = # This test suite is dedicated to tests that need to run with the browser in RTL mode. # This mode cannot be dynamically changed between tests reusing the browser instance and # window. intl.uidirection=1 support-files = head.js !/devtools/client/shared/test/shared-head.js !/devtools/client/shared/test/telemetry-test-helpers.js [browser_browser_toolbox_rtl.js] devtools/client/framework/test/browser.ini +1 −1 Original line number Diff line number Diff line Loading @@ -42,6 +42,7 @@ support-files = serviceworker.js sjs_code_reload.sjs sjs_code_bundle_reload_map.sjs test_browser_toolbox_debugger.js test_chrome_page.html !/devtools/client/debugger/test/mochitest/head.js !/devtools/client/debugger/test/mochitest/helpers.js Loading @@ -63,7 +64,6 @@ skip-if = coverage # Bug 1387827 skip-if = os == 'win' || debug || (bits == 64 && !debug && (os == 'mac' || os == 'linux')) # Bug 1282269, 1448084, Bug 1270731 [browser_browser_toolbox_fission_inspector.js] skip-if = coverage # Bug 1387827 [browser_browser_toolbox_rtl.js] [browser_devtools_api_destroy.js] [browser_dynamic_tool_enabling.js] [browser_front_parentFront.js] Loading devtools/client/framework/test/browser_browser_toolbox.js +76 −12 Original line number Diff line number Diff line /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ /* import-globals-from helpers.js */ Services.scriptloader.loadSubScript( "chrome://mochitests/content/browser/devtools/client/framework/test/helpers.js", this ); // There are shutdown issues for which multiple rejections are left uncaught. // See bug 1018184 for resolving these issues. const { PromiseTestUtils } = ChromeUtils.import( Loading @@ -18,14 +12,84 @@ PromiseTestUtils.whitelistRejectionsGlobally(/File closed/); requestLongerTimeout(4); add_task(async function() { const ToolboxTask = await initBrowserToolboxTask(); await ToolboxTask.importFunctions({}); await setupPreferencesForBrowserToolbox(); // Wait for a notification sent by a script evaluated in the webconsole // of the browser toolbox. const onCustomMessage = new Promise(done => { Services.obs.addObserver(function listener(target, aTop, data) { Services.obs.removeObserver(listener, "browser-toolbox-console-works"); done(data === "true"); }, "browser-toolbox-console-works"); }); const hasCloseButton = await ToolboxTask.spawn(null, async () => { /* global gToolbox */ return !!gToolbox.doc.getElementById("toolbox-close"); // Be careful, this JS function is going to be executed in the addon toolbox, // which lives in another process. So do not try to use any scope variable! const env = Cc["@mozilla.org/process/environment;1"].getService( Ci.nsIEnvironment ); /* global toolbox */ const testScript = function() { toolbox .selectTool("webconsole") .then(console => { // This is for checking Browser Toolbox doesn't have a close button. const hasCloseButton = !!toolbox.doc.getElementById("toolbox-close"); const { wrapper } = console.hud.ui; const js = `Services.obs.notifyObservers(null, 'browser-toolbox-console-works', ${hasCloseButton} )`; const onResult = new Promise(resolve => { const onNewMessages = messages => { for (const message of messages) { if (message.node.classList.contains("result")) { console.hud.ui.off("new-messages", onNewMessages); resolve(); } } }; console.hud.ui.on("new-messages", onNewMessages); }); wrapper.dispatchEvaluateExpression(js); return onResult; }) .then(() => toolbox.destroy()); }; env.set("MOZ_TOOLBOX_TEST_SCRIPT", "new " + testScript); registerCleanupFunction(() => { env.set("MOZ_TOOLBOX_TEST_SCRIPT", ""); }); const { BrowserToolboxProcess } = ChromeUtils.import( "resource://devtools/client/framework/ToolboxProcess.jsm" ); is( BrowserToolboxProcess.getBrowserToolboxSessionState(), false, "No session state initially" ); let closePromise; await new Promise(onRun => { closePromise = new Promise(onClose => { info("Opening the browser toolbox\n"); BrowserToolboxProcess.init(onClose, onRun); }); }); ok(true, "Browser toolbox started\n"); is( BrowserToolboxProcess.getBrowserToolboxSessionState(), true, "Has session state" ); const hasCloseButton = await onCustomMessage; ok(true, "Received the custom message"); ok(!hasCloseButton, "Browser toolbox doesn't have a close button"); await ToolboxTask.destroy(); await closePromise; ok(true, "Browser toolbox process just closed"); is( BrowserToolboxProcess.getBrowserToolboxSessionState(), false, "No session state after closing" ); }); Loading
devtools/client/aboutdebugging/test/browser/helper-addons.js +2 −0 Original line number Diff line number Diff line Loading @@ -17,6 +17,8 @@ function _getSupportsFile(path) { async function enableExtensionDebugging() { // Disable security prompt await pushPref("devtools.debugger.prompt-connection", false); // Enable Browser toolbox test script execution via env variable await pushPref("devtools.browser-toolbox.allow-unsafe-script", true); } /* exported enableExtensionDebugging */ Loading
devtools/client/framework/moz.build +1 −0 Original line number Diff line number Diff line Loading @@ -6,6 +6,7 @@ BROWSER_CHROME_MANIFESTS += [ 'test/allocations/browser_allocations_target.ini', 'test/browser-rtl.ini', 'test/browser-telemetry-startup.ini', 'test/browser.ini', 'test/metrics/browser_metrics_debugger.ini', Loading
devtools/client/framework/test/browser-rtl.ini 0 → 100644 +14 −0 Original line number Diff line number Diff line [DEFAULT] tags = devtools subsuite = devtools prefs = # This test suite is dedicated to tests that need to run with the browser in RTL mode. # This mode cannot be dynamically changed between tests reusing the browser instance and # window. intl.uidirection=1 support-files = head.js !/devtools/client/shared/test/shared-head.js !/devtools/client/shared/test/telemetry-test-helpers.js [browser_browser_toolbox_rtl.js]
devtools/client/framework/test/browser.ini +1 −1 Original line number Diff line number Diff line Loading @@ -42,6 +42,7 @@ support-files = serviceworker.js sjs_code_reload.sjs sjs_code_bundle_reload_map.sjs test_browser_toolbox_debugger.js test_chrome_page.html !/devtools/client/debugger/test/mochitest/head.js !/devtools/client/debugger/test/mochitest/helpers.js Loading @@ -63,7 +64,6 @@ skip-if = coverage # Bug 1387827 skip-if = os == 'win' || debug || (bits == 64 && !debug && (os == 'mac' || os == 'linux')) # Bug 1282269, 1448084, Bug 1270731 [browser_browser_toolbox_fission_inspector.js] skip-if = coverage # Bug 1387827 [browser_browser_toolbox_rtl.js] [browser_devtools_api_destroy.js] [browser_dynamic_tool_enabling.js] [browser_front_parentFront.js] Loading
devtools/client/framework/test/browser_browser_toolbox.js +76 −12 Original line number Diff line number Diff line /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ /* import-globals-from helpers.js */ Services.scriptloader.loadSubScript( "chrome://mochitests/content/browser/devtools/client/framework/test/helpers.js", this ); // There are shutdown issues for which multiple rejections are left uncaught. // See bug 1018184 for resolving these issues. const { PromiseTestUtils } = ChromeUtils.import( Loading @@ -18,14 +12,84 @@ PromiseTestUtils.whitelistRejectionsGlobally(/File closed/); requestLongerTimeout(4); add_task(async function() { const ToolboxTask = await initBrowserToolboxTask(); await ToolboxTask.importFunctions({}); await setupPreferencesForBrowserToolbox(); // Wait for a notification sent by a script evaluated in the webconsole // of the browser toolbox. const onCustomMessage = new Promise(done => { Services.obs.addObserver(function listener(target, aTop, data) { Services.obs.removeObserver(listener, "browser-toolbox-console-works"); done(data === "true"); }, "browser-toolbox-console-works"); }); const hasCloseButton = await ToolboxTask.spawn(null, async () => { /* global gToolbox */ return !!gToolbox.doc.getElementById("toolbox-close"); // Be careful, this JS function is going to be executed in the addon toolbox, // which lives in another process. So do not try to use any scope variable! const env = Cc["@mozilla.org/process/environment;1"].getService( Ci.nsIEnvironment ); /* global toolbox */ const testScript = function() { toolbox .selectTool("webconsole") .then(console => { // This is for checking Browser Toolbox doesn't have a close button. const hasCloseButton = !!toolbox.doc.getElementById("toolbox-close"); const { wrapper } = console.hud.ui; const js = `Services.obs.notifyObservers(null, 'browser-toolbox-console-works', ${hasCloseButton} )`; const onResult = new Promise(resolve => { const onNewMessages = messages => { for (const message of messages) { if (message.node.classList.contains("result")) { console.hud.ui.off("new-messages", onNewMessages); resolve(); } } }; console.hud.ui.on("new-messages", onNewMessages); }); wrapper.dispatchEvaluateExpression(js); return onResult; }) .then(() => toolbox.destroy()); }; env.set("MOZ_TOOLBOX_TEST_SCRIPT", "new " + testScript); registerCleanupFunction(() => { env.set("MOZ_TOOLBOX_TEST_SCRIPT", ""); }); const { BrowserToolboxProcess } = ChromeUtils.import( "resource://devtools/client/framework/ToolboxProcess.jsm" ); is( BrowserToolboxProcess.getBrowserToolboxSessionState(), false, "No session state initially" ); let closePromise; await new Promise(onRun => { closePromise = new Promise(onClose => { info("Opening the browser toolbox\n"); BrowserToolboxProcess.init(onClose, onRun); }); }); ok(true, "Browser toolbox started\n"); is( BrowserToolboxProcess.getBrowserToolboxSessionState(), true, "Has session state" ); const hasCloseButton = await onCustomMessage; ok(true, "Received the custom message"); ok(!hasCloseButton, "Browser toolbox doesn't have a close button"); await ToolboxTask.destroy(); await closePromise; ok(true, "Browser toolbox process just closed"); is( BrowserToolboxProcess.getBrowserToolboxSessionState(), false, "No session state after closing" ); });