Bug 1326626 - Open rule link in new tab also when devtools is in separate window. r=jdescottes a=gchang
authorMichael Brennan <brennan.brisad@gmail.com>
Fri, 10 Mar 2017 22:53:33 +0100
changeset 395360 b01f4f2ba7507d118cfbd961a823c23f01698f04
parent 395359 7c1cecebcd05b116081fb327c8d58b21ff1d00b4
child 395361 8d6bf64a18bfb6e6bfcdda811b8e73b60bf1a002
push id1468
push userasasaki@mozilla.com
push dateMon, 05 Jun 2017 19:31:07 +0000
treeherdermozilla-release@0641fc6ee9d1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjdescottes, gchang
bugs1326626
milestone54.0a2
Bug 1326626 - Open rule link in new tab also when devtools is in separate window. r=jdescottes a=gchang
devtools/client/inspector/rules/test/browser.ini
devtools/client/inspector/rules/test/browser_rules_url-click-opens-new-tab.js
devtools/client/inspector/rules/views/text-property-editor.js
--- a/devtools/client/inspector/rules/test/browser.ini
+++ b/devtools/client/inspector/rules/test/browser.ini
@@ -217,12 +217,13 @@ skip-if = (os == 'linux' && bits == 32 &
 [browser_rules_selector-highlighter_05.js]
 [browser_rules_selector_highlight.js]
 [browser_rules_shorthand-overridden-lists.js]
 [browser_rules_strict-search-filter-computed-list_01.js]
 [browser_rules_strict-search-filter_01.js]
 [browser_rules_strict-search-filter_02.js]
 [browser_rules_strict-search-filter_03.js]
 [browser_rules_style-editor-link.js]
+[browser_rules_url-click-opens-new-tab.js]
 [browser_rules_urls-clickable.js]
 [browser_rules_user-agent-styles.js]
 [browser_rules_user-agent-styles-uneditable.js]
 [browser_rules_user-property-reset.js]
new file mode 100644
--- /dev/null
+++ b/devtools/client/inspector/rules/test/browser_rules_url-click-opens-new-tab.js
@@ -0,0 +1,29 @@
+/* vim: set ft=javascript ts=2 et sw=2 tw=80: */
+/* Any copyright is dedicated to the Public Domain.
+ http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+// Bug 1326626 - Tests that clicking a background url opens a new tab
+// even when the devtools is opened in a separate window.
+
+const TEST_URL = "data:text/html,<style>body{background:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVQImWNgYGD4DwABBAEAfbLI3wAAAABJRU5ErkJggg==) no-repeat}";
+
+add_task(function* () {
+  let {inspector} = yield openInspectorForURL(TEST_URL, "window");
+  let view = selectRuleView(inspector);
+
+  yield selectNode("body", inspector);
+
+  let anchor = view.styleDocument.querySelector(".ruleview-propertyvaluecontainer a");
+  ok(anchor, "Link exists for style tag node");
+
+  let onTabOpened = waitForTab();
+  anchor.click();
+
+  info("Wait for the image to open in a new tab");
+  let tab = yield onTabOpened;
+  ok(tab, "A new tab opened");
+
+  is(tab.linkedBrowser.currentURI.spec, anchor.href, "The new tab has the expected URL");
+});
--- a/devtools/client/inspector/rules/views/text-property-editor.js
+++ b/devtools/client/inspector/rules/views/text-property-editor.js
@@ -275,17 +275,18 @@ TextPropertyEditor.prototype = {
       });
 
       this.valueSpan.addEventListener("click", (event) => {
         let target = event.target;
 
         if (target.nodeName === "a") {
           event.stopPropagation();
           event.preventDefault();
-          this.browserWindow.openUILinkIn(target.href, "tab");
+          let browserWin = this.ruleView.inspector.target.tab.ownerDocument.defaultView;
+          browserWin.openUILinkIn(target.href, "tab");
         }
       });
 
       editableField({
         start: this._onStartEditing,
         element: this.valueSpan,
         done: this._onValueDone,
         destroy: this.update,