Bug 1414597 Part 2: Add a test that nodes in XUL documents can be inspected, including after reload. r=jdescottes
authorBrad Werth <bwerth@mozilla.com>
Mon, 10 Sep 2018 19:16:13 +0000
changeset 435546 a08e6206cd972abb5a2569842d71291d220abc7d
parent 435545 8b1229ed285023b775f076caf9213424a9590e80
child 435547 fea371cafd2c73be689184ca6670e33c3fd1636c
child 435548 531a559d65bc60080de96074903f713473e9cab2
push id34614
push userapavel@mozilla.com
push dateMon, 10 Sep 2018 21:59:18 +0000
treeherdermozilla-central@fea371cafd2c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjdescottes
bugs1414597
milestone64.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1414597 Part 2: Add a test that nodes in XUL documents can be inspected, including after reload. r=jdescottes Depends on D4495 Differential Revision: https://phabricator.services.mozilla.com/D4799
devtools/client/inspector/test/browser.ini
devtools/client/inspector/test/browser_inspector_reload_xul.js
devtools/client/inspector/test/doc_inspector_reload_xul.xul
--- a/devtools/client/inspector/test/browser.ini
+++ b/devtools/client/inspector/test/browser.ini
@@ -26,16 +26,17 @@ support-files =
   doc_inspector_highlighter_xbl.xul
   doc_inspector_infobar_01.html
   doc_inspector_infobar_02.html
   doc_inspector_infobar_03.html
   doc_inspector_infobar_textnode.html
   doc_inspector_long-divs.html
   doc_inspector_menu.html
   doc_inspector_outerhtml.html
+  doc_inspector_reload_xul.xul
   doc_inspector_remove-iframe-during-load.html
   doc_inspector_search.html
   doc_inspector_search-reserved.html
   doc_inspector_search-suggestions.html
   doc_inspector_search-svg.html
   doc_inspector_select-last-selected-01.html
   doc_inspector_select-last-selected-02.html
   doc_inspector_svg.svg
@@ -164,16 +165,17 @@ skip-if = (os == 'linux' && bits == 32 &
 [browser_inspector_pane-toggle-04.js]
 [browser_inspector_picker-stop-on-destroy.js]
 [browser_inspector_picker-stop-on-tool-change.js]
 [browser_inspector_portrait_mode.js]
 [browser_inspector_pseudoclass-lock.js]
 [browser_inspector_pseudoclass-menu.js]
 [browser_inspector_reload-01.js]
 [browser_inspector_reload-02.js]
+[browser_inspector_reload_xul.js]
 [browser_inspector_remove-iframe-during-load.js]
 [browser_inspector_search-01.js]
 [browser_inspector_search-02.js]
 [browser_inspector_search-03.js]
 [browser_inspector_search-04.js]
 [browser_inspector_search-05.js]
 [browser_inspector_search-06.js]
 [browser_inspector_search-07.js]
new file mode 100644
--- /dev/null
+++ b/devtools/client/inspector/test/browser_inspector_reload_xul.js
@@ -0,0 +1,60 @@
+/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
+/* vim: set ts=2 et sw=2 tw=80: */
+/* 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/. */
+/* globals getTestActorWithoutToolbox */
+"use strict";
+
+// Tests for inspecting a node on a XUL document, spanning a tab reload.
+
+const TEST_URI = URL_ROOT + "doc_inspector_reload_xul.xul";
+
+add_task(async function() {
+  await pushPref("dom.allow_XUL_XBL_for_file", false);
+
+  const { tab, inspector, toolbox } = await openInspectorForURL(TEST_URI);
+  await testToolboxInitialization(tab, inspector, toolbox);
+});
+
+async function testToolboxInitialization(tab, inspector, toolbox) {
+  const target = TargetFactory.forTab(tab);
+
+  ok(true, "Inspector started, and notification received.");
+  ok(inspector, "Inspector instance is accessible.");
+  ok(inspector.isReady, "Inspector instance is ready.");
+  is(inspector.target.tab, tab, "Valid target.");
+
+  await selectNode("#p", inspector);
+  await testMarkupView("#p", inspector);
+
+  info("Reloading the page.");
+  const markuploaded = inspector.once("markuploaded");
+  const onNewRoot = inspector.once("new-root");
+  const onUpdated = inspector.once("inspector-updated");
+  await toolbox.target.activeTab.reload();
+  info("Waiting for inspector to be ready.");
+  await markuploaded;
+  await onNewRoot;
+  await onUpdated;
+
+  await selectNode("#q", inspector);
+  await testMarkupView("#q", inspector);
+
+  info("Destroying toolbox.");
+  await toolbox.destroy();
+
+  ok("true", "'destroyed' notification received.");
+  ok(!gDevTools.getToolbox(target), "Toolbox destroyed.");
+}
+
+async function testMarkupView(selector, inspector) {
+  const nodeFront = await getNodeFront(selector, inspector);
+  try {
+    is(inspector.selection.nodeFront, nodeFront,
+       "Right node is selected in the markup view");
+  } catch (ex) {
+    ok(false, "Got exception while resolving selected node of markup view.");
+    console.error(ex);
+  }
+}
new file mode 100644
--- /dev/null
+++ b/devtools/client/inspector/test/doc_inspector_reload_xul.xul
@@ -0,0 +1,9 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin/xul.css" type="text/css"?>
+<!DOCTYPE window>
+<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+  <body xmlns="http://www.w3.org/1999/xhtml">
+  <div id="p">a node inspected before reload</div>
+  <div id="q">a node inspected after reload</div>
+  </body>
+</window>