Bug 678816 - web console re-attaches console to non-tab-browser contentWindows; r=msucan
This commit is contained in:
Родитель
dda9ec2bec
Коммит
708bd6913a
|
@ -2708,6 +2708,12 @@ HUD_SERVICE.prototype =
|
|||
|
||||
let _browser = gBrowser.
|
||||
getBrowserForDocument(aContentWindow.top.document);
|
||||
|
||||
// ignore newly created documents that don't belong to a tab's browser
|
||||
if (!_browser) {
|
||||
return;
|
||||
}
|
||||
|
||||
let nBox = gBrowser.getNotificationBox(_browser);
|
||||
let nBoxId = nBox.getAttribute("id");
|
||||
let hudId = "hud_" + nBoxId;
|
||||
|
|
|
@ -144,6 +144,7 @@ _BROWSER_TEST_FILES = \
|
|||
browser_webconsole_bug_651501_document_body_autocomplete.js \
|
||||
browser_webconsole_bug_653531_highlighter_console_helper.js \
|
||||
browser_webconsole_bug_659907_console_dir.js \
|
||||
browser_webconsole_bug_678816.js \
|
||||
head.js \
|
||||
$(NULL)
|
||||
|
||||
|
@ -212,6 +213,7 @@ _BROWSER_TEST_PAGES = \
|
|||
test-bug-644419-log-limits.html \
|
||||
test-bug-632275-getters.html \
|
||||
test-bug-646025-console-file-location.html \
|
||||
test-bug-678816-content.js \
|
||||
test-file-location.js \
|
||||
$(NULL)
|
||||
|
||||
|
|
|
@ -0,0 +1,62 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
const TEST_URI = "http://example.com/browser/browser/devtools/webconsole/test/browser/test-console.html";
|
||||
const FRAME_SCRIPT_URI ="chrome://mochitests/content/browser/browser/devtools/webconsole/test/browser/test-bug-678816-content.js";
|
||||
|
||||
let HUD;
|
||||
let outputItem;
|
||||
|
||||
function tabLoad1(aEvent) {
|
||||
browser.removeEventListener(aEvent.type, arguments.callee, true);
|
||||
|
||||
openConsole();
|
||||
HUD = HUDService.getHudByWindow(content);
|
||||
|
||||
browser.addEventListener("load", tabLoad2, true);
|
||||
|
||||
// Reload so we get some output in the console.
|
||||
browser.contentWindow.location.reload();
|
||||
}
|
||||
|
||||
function tabLoad2(aEvent) {
|
||||
browser.removeEventListener(aEvent.type, tabLoad2, true);
|
||||
|
||||
outputItem = HUD.outputNode.querySelector(".hud-networkinfo .hud-clickable");
|
||||
ok(outputItem, "found a network message");
|
||||
document.addEventListener("popupshown", networkPanelShown, false);
|
||||
|
||||
// Click the network message to open the network panel.
|
||||
EventUtils.synthesizeMouseAtCenter(outputItem, {});
|
||||
}
|
||||
|
||||
function networkPanelShown(aEvent) {
|
||||
document.removeEventListener(aEvent.type, networkPanelShown, false);
|
||||
|
||||
executeSoon(function() {
|
||||
aEvent.target.addEventListener("popuphidden", networkPanelHidden, false);
|
||||
aEvent.target.hidePopup();
|
||||
});
|
||||
}
|
||||
|
||||
function networkPanelHidden(aEvent) {
|
||||
this.removeEventListener(aEvent.type, networkPanelHidden, false);
|
||||
|
||||
is(HUD.contentWindow, browser.contentWindow,
|
||||
"console has not been re-attached to the wrong window");
|
||||
|
||||
finishTest();
|
||||
}
|
||||
|
||||
function test() {
|
||||
messageManager.loadFrameScript(FRAME_SCRIPT_URI, true);
|
||||
|
||||
registerCleanupFunction(function () {
|
||||
// There's no way to unload a frameScript so send a kill signal to
|
||||
// unregister the frame script's webProgressListener
|
||||
messageManager.sendAsyncMessage("bug-678816-kill-webProgressListener");
|
||||
});
|
||||
|
||||
addTab(TEST_URI);
|
||||
browser.addEventListener("load", tabLoad1, true);
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
(function () {
|
||||
let ifaceReq = docShell.QueryInterface(Ci.nsIInterfaceRequestor);
|
||||
let webProgress = ifaceReq.getInterface(Ci.nsIWebProgress);
|
||||
|
||||
let WebProgressListener = {
|
||||
onStateChange: function WebProgressListener_onStateChange(
|
||||
webProgress, request, flag, status) {
|
||||
|
||||
if (flag & Ci.nsIWebProgressListener.STATE_START &&
|
||||
flag & Ci.nsIWebProgressListener.STATE_IS_WINDOW) {
|
||||
// ensure the dom window is the top one
|
||||
return (webProgress.DOMWindow.parent == webProgress.DOMWindow);
|
||||
}
|
||||
},
|
||||
|
||||
// ----------
|
||||
// Implements progress listener interface.
|
||||
QueryInterface: XPCOMUtils.generateQI([Ci.nsIWebProgressListener,
|
||||
Ci.nsISupportsWeakReference])
|
||||
};
|
||||
|
||||
// add web progress listener
|
||||
webProgress.addProgressListener(WebProgressListener, Ci.nsIWebProgress.NOTIFY_STATE_ALL);
|
||||
|
||||
addMessageListener("bug-678816-kill-webProgressListener", function () {
|
||||
webProgress.removeProgressListener(WebProgressListener);
|
||||
});
|
||||
})();
|
Загрузка…
Ссылка в новой задаче