Bug 1326626 - Open rule link in new tab also when devtools is in separate window. r=jdescottes

This commit is contained in:
Michael Brennan 2017-03-10 22:53:33 +01:00
Родитель ddfb294c2a
Коммит 390377b549
3 изменённых файлов: 32 добавлений и 1 удалений

Просмотреть файл

@ -231,6 +231,7 @@ skip-if = (os == 'linux' && bits == 32 && debug) # bug 1328915, disable linux32
[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]

Просмотреть файл

@ -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");
});

Просмотреть файл

@ -280,7 +280,8 @@ TextPropertyEditor.prototype = {
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");
}
});