summaryrefslogtreecommitdiffstats
path: root/devtools/client/aboutdebugging/test/browser_addons_debug_webextension_inspector.js
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /devtools/client/aboutdebugging/test/browser_addons_debug_webextension_inspector.js
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'devtools/client/aboutdebugging/test/browser_addons_debug_webextension_inspector.js')
-rw-r--r--devtools/client/aboutdebugging/test/browser_addons_debug_webextension_inspector.js82
1 files changed, 82 insertions, 0 deletions
diff --git a/devtools/client/aboutdebugging/test/browser_addons_debug_webextension_inspector.js b/devtools/client/aboutdebugging/test/browser_addons_debug_webextension_inspector.js
new file mode 100644
index 000000000..3adc918d8
--- /dev/null
+++ b/devtools/client/aboutdebugging/test/browser_addons_debug_webextension_inspector.js
@@ -0,0 +1,82 @@
+/* Any copyright is dedicated to the Public Domain.
+ http://creativecommons.org/publicdomain/zero/1.0/ */
+"use strict";
+
+// Avoid test timeouts that can occur while waiting for the "addon-console-works" message.
+requestLongerTimeout(2);
+
+const ADDON_ID = "test-devtools-webextension@mozilla.org";
+const ADDON_NAME = "test-devtools-webextension";
+const ADDON_PATH = "addons/test-devtools-webextension/manifest.json";
+
+const {
+ BrowserToolboxProcess
+} = Cu.import("resource://devtools/client/framework/ToolboxProcess.jsm", {});
+
+/**
+ * This test file ensures that the webextension addon developer toolbox:
+ * - the webextension developer toolbox has a working Inspector panel, with the
+ * background page as default target;
+ */
+add_task(function* testWebExtensionsToolboxInspector() {
+ let {
+ tab, document, debugBtn,
+ } = yield setupTestAboutDebuggingWebExtension(ADDON_NAME, ADDON_PATH);
+
+ // 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!
+ let env = Cc["@mozilla.org/process/environment;1"]
+ .getService(Ci.nsIEnvironment);
+ let testScript = function () {
+ /* eslint-disable no-undef */
+ toolbox.selectTool("inspector")
+ .then(inspector => {
+ return inspector.walker.querySelector(inspector.walker.rootNode, "body");
+ })
+ .then((nodeActor) => {
+ if (!nodeActor) {
+ throw new Error("nodeActor not found");
+ }
+
+ dump("Got a nodeActor\n");
+
+ if (!(nodeActor.inlineTextChild)) {
+ throw new Error("inlineTextChild not found");
+ }
+
+ dump("Got a nodeActor with an inline text child\n");
+
+ let expectedValue = "Background Page Body Test Content";
+ let actualValue = nodeActor.inlineTextChild._form.nodeValue;
+
+ if (String(actualValue).trim() !== String(expectedValue).trim()) {
+ throw new Error(
+ `mismatched inlineTextchild value: "${actualValue}" !== "${expectedValue}"`
+ );
+ }
+
+ dump("Got the expected inline text content in the selected node\n");
+ return Promise.resolve();
+ })
+ .then(() => toolbox.destroy())
+ .catch((error) => {
+ dump("Error while running code in the browser toolbox process:\n");
+ dump(error + "\n");
+ dump("stack:\n" + error.stack + "\n");
+ });
+ /* eslint-enable no-undef */
+ };
+ env.set("MOZ_TOOLBOX_TEST_SCRIPT", "new " + testScript);
+ registerCleanupFunction(() => {
+ env.set("MOZ_TOOLBOX_TEST_SCRIPT", "");
+ });
+
+ let onToolboxClose = BrowserToolboxProcess.once("close");
+ debugBtn.click();
+ yield onToolboxClose;
+
+ ok(true, "Addon toolbox closed");
+
+ yield uninstallAddon({document, id: ADDON_ID, name: ADDON_NAME});
+ yield closeAboutDebugging(tab);
+});