Created
November 20, 2019 17:58
-
-
Save juliandescottes/ed1f4c3e63514083b02033d79b58ea39 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# HG changeset patch | |
# User Julian Descottes <[email protected]> | |
# Date 1574272514 -3600 | |
# Wed Nov 20 18:55:14 2019 +0100 | |
# Node ID d6dbb549fa57a45a4fba92ce6ce1e6e36d34d163 | |
# Parent 7c17c8c8997ba0811bcd57dc8552da5a5275afec | |
Add fission mochitest | |
diff --git a/devtools/client/framework/moz.build b/devtools/client/framework/moz.build | |
--- a/devtools/client/framework/moz.build | |
+++ b/devtools/client/framework/moz.build | |
@@ -1,16 +1,17 @@ | |
# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*- | |
# vim: set filetype=python: | |
# This Source Code Form is subject to the terms of the Mozilla Public | |
# License, v. 2.0. If a copy of the MPL was not distributed with this | |
# file, You can obtain one at http://mozilla.org/MPL/2.0/. | |
BROWSER_CHROME_MANIFESTS += [ | |
'test/allocations/browser_allocations_target.ini', | |
+ 'test/browser-fission.ini', | |
'test/browser-rtl.ini', | |
'test/browser-telemetry-startup.ini', | |
'test/browser.ini', | |
'test/metrics/browser_metrics_debugger.ini', | |
'test/metrics/browser_metrics_inspector.ini', | |
'test/metrics/browser_metrics_netmonitor.ini', | |
'test/metrics/browser_metrics_webconsole.ini', | |
] | |
diff --git a/devtools/client/framework/test/browser-fission.ini b/devtools/client/framework/test/browser-fission.ini | |
new file mode 100644 | |
--- /dev/null | |
+++ b/devtools/client/framework/test/browser-fission.ini | |
@@ -0,0 +1,16 @@ | |
+[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. | |
+ fission.autostart=true | |
+support-files = | |
+ doc_browser_toolbox_fission_contentframe_inspector_frame.html | |
+ doc_browser_toolbox_fission_contentframe_inspector_page.html | |
+ head.js | |
+ !/devtools/client/shared/test/shared-head.js | |
+ !/devtools/client/shared/test/telemetry-test-helpers.js | |
+ | |
+[browser_browser_toolbox_fission_contentframe_inspector.js] | |
diff --git a/devtools/client/framework/test/browser_browser_toolbox_fission_contentframe_inspector.js b/devtools/client/framework/test/browser_browser_toolbox_fission_contentframe_inspector.js | |
new file mode 100644 | |
--- /dev/null | |
+++ b/devtools/client/framework/test/browser_browser_toolbox_fission_contentframe_inspector.js | |
@@ -0,0 +1,126 @@ | |
+/* Any copyright is dedicated to the Public Domain. | |
+ http://creativecommons.org/publicdomain/zero/1.0/ */ | |
+ | |
+// There are shutdown issues for which multiple rejections are left uncaught. | |
+// See bug 1018184 for resolving these issues. | |
+const { PromiseTestUtils } = ChromeUtils.import( | |
+ "resource://testing-common/PromiseTestUtils.jsm" | |
+); | |
+PromiseTestUtils.whitelistRejectionsGlobally(/File closed/); | |
+ | |
+// On debug test slave, it takes about 50s to run the test. | |
+requestLongerTimeout(4); | |
+ | |
+// This test is used to test fission-like features via the Browser Toolbox: | |
+// - computed view is correct when selecting an element in a remote frame | |
+ | |
+add_task(async function() { | |
+ await setupPreferencesForBrowserToolbox(); | |
+ | |
+ const tab = await addTab( | |
+ `http://example.com/browser/devtools/client/framework/test/doc_browser_toolbox_fission_contentframe_inspector_page.html` | |
+ ); | |
+ | |
+ // Set a custom attribute on the tab's browser, in order to easily select it in the markup view | |
+ tab.linkedBrowser.setAttribute("test-tab", "true"); | |
+ | |
+ // Be careful, this JS function is going to be executed in the browser 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() { | |
+ // Force the fission pref in order to be able to pierce through the remote browser element | |
+ // Set the pref from the toolbox process as previous test may already have created | |
+ // the browser toolbox profile folder. Then setting the pref in Firefox process | |
+ // won't be taken into account for the browser toolbox. | |
+ const { Services } = ChromeUtils.import( | |
+ "resource://gre/modules/Services.jsm" | |
+ ); | |
+ Services.prefs.setBoolPref("devtools.browsertoolbox.fission", true); | |
+ | |
+ toolbox | |
+ .selectTool("inspector") | |
+ .then(async inspector => { | |
+ const onSidebarSelect = inspector.sidebar.once("select"); | |
+ inspector.sidebar.select("computedview"); | |
+ await onSidebarSelect; | |
+ | |
+ async function select(walker, selector) { | |
+ const nodeFront = await walker.querySelector( | |
+ walker.rootNode, | |
+ selector | |
+ ); | |
+ const updated = inspector.once("inspector-updated"); | |
+ inspector.selection.setNodeFront(nodeFront); | |
+ await updated; | |
+ return nodeFront; | |
+ } | |
+ const browser = await select( | |
+ inspector.walker, | |
+ 'browser[remote="true"][test-tab]' | |
+ ); | |
+ const browserTarget = await browser.connectToRemoteFrame(); | |
+ const walker = (await browserTarget.getFront("inspector")).walker; | |
+ await select(walker, "#my-div"); | |
+ | |
+ const view = inspector.getPanel("computedview").computedView; | |
+ function getProperty(name) { | |
+ const propertyViews = view.propertyViews; | |
+ for (const propView of propertyViews) { | |
+ if (propView.name == name) { | |
+ return propView; | |
+ } | |
+ } | |
+ return null; | |
+ } | |
+ const prop = getProperty("color"); | |
+ const color = prop.valueNode.textContent; | |
+ if (color != "rgb(255, 0, 0)") { | |
+ throw new Error( | |
+ "The color property of the <div> within a tab isn't red, got: " + | |
+ color | |
+ ); | |
+ } | |
+ | |
+ Services.prefs.setBoolPref("devtools.browsertoolbox.fission", false); | |
+ }) | |
+ .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" | |
+ ); | |
+ | |
+ await closePromise; | |
+ ok(true, "Browser toolbox process just closed"); | |
+ is( | |
+ BrowserToolboxProcess.getBrowserToolboxSessionState(), | |
+ false, | |
+ "No session state after closing" | |
+ ); | |
+}); | |
diff --git a/devtools/client/framework/test/doc_browser_toolbox_fission_contentframe_inspector_frame.html b/devtools/client/framework/test/doc_browser_toolbox_fission_contentframe_inspector_frame.html | |
new file mode 100644 | |
--- /dev/null | |
+++ b/devtools/client/framework/test/doc_browser_toolbox_fission_contentframe_inspector_frame.html | |
@@ -0,0 +1,14 @@ | |
+<!-- Any copyright is dedicated to the Public Domain. | |
+ http://creativecommons.org/publicdomain/zero/1.0/ --> | |
+<!doctype html> | |
+ | |
+<html> | |
+ <head> | |
+ <meta charset="utf-8"/> | |
+ <title>Frame for browser_browser_toolbox_fission_contentframe_inspector.js</title> | |
+ </head> | |
+ | |
+ <body> | |
+ <div id="inside-iframe"></div> | |
+ </body> | |
+</html> | |
diff --git a/devtools/client/framework/test/doc_browser_toolbox_fission_contentframe_inspector_page.html b/devtools/client/framework/test/doc_browser_toolbox_fission_contentframe_inspector_page.html | |
new file mode 100644 | |
--- /dev/null | |
+++ b/devtools/client/framework/test/doc_browser_toolbox_fission_contentframe_inspector_page.html | |
@@ -0,0 +1,15 @@ | |
+<!-- Any copyright is dedicated to the Public Domain. | |
+ http://creativecommons.org/publicdomain/zero/1.0/ --> | |
+<!doctype html> | |
+ | |
+<html> | |
+ <head> | |
+ <meta charset="utf-8"/> | |
+ <title>Frame for browser_browser_toolbox_fission_contentframe_inspector.js</title> | |
+ </head> | |
+ | |
+ <body> | |
+ <iframe src="http://example.org/browser/devtools/client/framework/test/doc_browser_toolbox_fission_contentframe_inspector_frame.html"></iframe> | |
+ <div id="inside-iframe"></div> | |
+ </body> | |
+</html> | |
\ No newline at end of file |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment