зеркало из https://github.com/mozilla/gecko-dev.git
Bug 618311 - Inspect Network Request window persists on close of Web Console - PB data leak; f=rcampbell r=sdwilsh
This commit is contained in:
Родитель
aca1d650f4
Коммит
e34f7694e6
|
@ -1764,6 +1764,12 @@ HUD_SERVICE.prototype =
|
|||
|
||||
this.unregisterActiveContext(id);
|
||||
|
||||
let popupset = outputNode.ownerDocument.getElementById("mainPopupSet");
|
||||
let panels = popupset.querySelectorAll("panel[hudId=" + id + "]");
|
||||
for (let i = 0; i < panels.length; i++) {
|
||||
panels[i].hidePopup();
|
||||
}
|
||||
|
||||
let id = ConsoleUtils.supString(id);
|
||||
Services.obs.notifyObservers(id, "web-console-destroyed", null);
|
||||
|
||||
|
@ -2131,6 +2137,7 @@ HUD_SERVICE.prototype =
|
|||
let panel = netPanel.panel;
|
||||
panel.openPopup(aNode, "after_pointer", 0, 0, false, false);
|
||||
panel.sizeTo(450, 500);
|
||||
panel.setAttribute("hudId", aHttpActivity.hudId);
|
||||
aHttpActivity.panels.push(Cu.getWeakReference(netPanel));
|
||||
return netPanel;
|
||||
},
|
||||
|
@ -3917,7 +3924,8 @@ function JSTermHelper(aJSTerm)
|
|||
aJSTerm.sandbox.inspect = function JSTH_inspect(aObject)
|
||||
{
|
||||
aJSTerm.helperEvaluated = true;
|
||||
aJSTerm.openPropertyPanel(null, unwrap(aObject));
|
||||
let propPanel = aJSTerm.openPropertyPanel(null, unwrap(aObject));
|
||||
propPanel.panel.setAttribute("hudId", aJSTerm.hudId);
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -4242,7 +4250,8 @@ JSTerm.prototype = {
|
|||
}
|
||||
|
||||
if (!this._panelOpen) {
|
||||
self.openPropertyPanel(aEvalString, aOutputObject, this);
|
||||
let propPanel = self.openPropertyPanel(aEvalString, aOutputObject, this);
|
||||
propPanel.panel.setAttribute("hudId", self.hudId);
|
||||
this._panelOpen = true;
|
||||
}
|
||||
}, false);
|
||||
|
|
|
@ -126,6 +126,8 @@ _BROWSER_TEST_FILES = \
|
|||
browser_webconsole_bug_621644_jsterm_dollar.js \
|
||||
browser_webconsole_bug_632817.js \
|
||||
browser_webconsole_bug_611795.js \
|
||||
browser_webconsole_bug_618311_close_panels.js \
|
||||
browser_webconsole_bug_618311_private_browsing.js \
|
||||
head.js \
|
||||
$(NULL)
|
||||
|
||||
|
|
|
@ -32,13 +32,15 @@ function testCloseButton() {
|
|||
|
||||
// XXX: ASSERTION: ###!!! ASSERTION: XPConnect is being called on a scope without a 'Components' property!: 'Error', file /home/ddahl/code/moz/mozilla-central/mozilla-central/js/src/xpconnect/src/xpcwrappednativescope.cpp, line 795
|
||||
|
||||
EventUtils.synthesizeMouse(closeButton, 0, 0, {});
|
||||
closeButton.addEventListener("command", function() {
|
||||
closeButton.removeEventListener("command", arguments.callee, false);
|
||||
|
||||
executeSoon(function (){
|
||||
ok(!(hudId in HUDService.hudReferences), "the console is closed when " +
|
||||
"the close button is pressed");
|
||||
closeButton = null;
|
||||
finishTest();
|
||||
});
|
||||
}, false);
|
||||
|
||||
EventUtils.synthesizeMouse(closeButton, 2, 2, {});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -0,0 +1,123 @@
|
|||
/* vim:set ts=2 sw=2 sts=2 et: */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Web Console test suite.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Mozilla Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2011
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Mihai Sucan <mihai.sucan@gmail.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
const TEST_URI = "http://example.com/browser/toolkit/components/console/hudservice/tests/browser/test-console.html";
|
||||
|
||||
function test() {
|
||||
addTab(TEST_URI);
|
||||
browser.addEventListener("load", function() {
|
||||
browser.removeEventListener("load", arguments.callee, true);
|
||||
|
||||
openConsole();
|
||||
content.location.reload();
|
||||
browser.addEventListener("load", tabLoaded, true);
|
||||
}, true);
|
||||
}
|
||||
|
||||
function tabLoaded() {
|
||||
browser.removeEventListener("load", tabLoaded, true);
|
||||
|
||||
let hudId = HUDService.getHudIdByWindow(content);
|
||||
let HUD = HUDService.hudReferences[hudId];
|
||||
|
||||
HUD.jsterm.execute("document");
|
||||
|
||||
let networkMessage = HUD.outputNode.querySelector(".webconsole-msg-network");
|
||||
ok(networkMessage, "found network message");
|
||||
|
||||
let networkLink = networkMessage.querySelector(".webconsole-msg-link");
|
||||
ok(networkLink, "found network message link");
|
||||
|
||||
let jstermMessage = HUD.outputNode.querySelector(".webconsole-msg-output");
|
||||
ok(jstermMessage, "found output message");
|
||||
|
||||
let popupset = document.getElementById("mainPopupSet");
|
||||
ok(popupset, "found #mainPopupSet");
|
||||
|
||||
let popupsShown = 0;
|
||||
let hiddenPopups = 0;
|
||||
|
||||
let onpopupshown = function() {
|
||||
popupsShown++;
|
||||
if (popupsShown == 2) {
|
||||
document.removeEventListener("popupshown", onpopupshown, false);
|
||||
|
||||
executeSoon(function() {
|
||||
let popups = popupset.querySelectorAll("panel[hudId=" + hudId + "]");
|
||||
is(popups.length, 2, "found two popups");
|
||||
|
||||
document.addEventListener("popuphidden", onpopuphidden, false);
|
||||
|
||||
registerCleanupFunction(function() {
|
||||
is(hiddenPopups, 2, "correct number of popups hidden");
|
||||
if (hiddenPopups != 2) {
|
||||
document.removeEventListener("popuphidden", onpopuphidden, false);
|
||||
}
|
||||
});
|
||||
|
||||
executeSoon(closeConsole);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
let onpopuphidden = function() {
|
||||
hiddenPopups++;
|
||||
if (hiddenPopups == 2) {
|
||||
document.removeEventListener("popuphidden", onpopuphidden, false);
|
||||
|
||||
executeSoon(function() {
|
||||
let popups = popupset.querySelectorAll("panel[hudId=" + hudId + "]");
|
||||
is(popups.length, 0, "no popups found");
|
||||
|
||||
executeSoon(finishTest);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
document.addEventListener("popupshown", onpopupshown, false);
|
||||
|
||||
registerCleanupFunction(function() {
|
||||
is(popupsShown, 2, "correct number of popups shown");
|
||||
if (popupsShown != 2) {
|
||||
document.removeEventListener("popupshown", onpopupshown, false);
|
||||
}
|
||||
});
|
||||
|
||||
EventUtils.synthesizeMouse(networkLink, 2, 2, {});
|
||||
EventUtils.synthesizeMouse(jstermMessage, 2, 2, {});
|
||||
}
|
|
@ -0,0 +1,162 @@
|
|||
/* vim:set ts=2 sw=2 sts=2 et: */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is Web Console test suite.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Mozilla Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2011
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Mihai Sucan <mihai.sucan@gmail.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
const TEST_URI = "http://example.com/browser/toolkit/components/console/hudservice/tests/browser/test-console.html";
|
||||
|
||||
let pb = Cc["@mozilla.org/privatebrowsing;1"].
|
||||
getService(Ci.nsIPrivateBrowsingService);
|
||||
|
||||
function test() {
|
||||
addTab("data:text/html,Web Console test for bug 618311 (private browsing)");
|
||||
|
||||
browser.addEventListener("load", function() {
|
||||
browser.removeEventListener("load", arguments.callee, true);
|
||||
|
||||
registerCleanupFunction(function() {
|
||||
pb.privateBrowsingEnabled = false;
|
||||
pb = null;
|
||||
});
|
||||
|
||||
ok(!pb.privateBrowsingEnabled, "private browsing is not enabled");
|
||||
|
||||
togglePBAndThen(function() {
|
||||
ok(pb.privateBrowsingEnabled, "private browsing is enabled");
|
||||
|
||||
HUDService.activateHUDForContext(gBrowser.selectedTab);
|
||||
content.location = TEST_URI;
|
||||
gBrowser.selectedBrowser.addEventListener("load", tabLoaded, true);
|
||||
});
|
||||
}, true);
|
||||
}
|
||||
|
||||
function tabLoaded() {
|
||||
gBrowser.selectedBrowser.removeEventListener("load", tabLoaded, true);
|
||||
|
||||
let hudId = HUDService.getHudIdByWindow(content);
|
||||
let HUD = HUDService.hudReferences[hudId];
|
||||
|
||||
HUD.jsterm.execute("document");
|
||||
|
||||
let networkMessage = HUD.outputNode.querySelector(".webconsole-msg-network");
|
||||
ok(networkMessage, "found network message");
|
||||
|
||||
let networkLink = networkMessage.querySelector(".webconsole-msg-link");
|
||||
ok(networkLink, "found network message link");
|
||||
|
||||
let jstermMessage = HUD.outputNode.querySelector(".webconsole-msg-output");
|
||||
ok(jstermMessage, "found output message");
|
||||
|
||||
let popupset = document.getElementById("mainPopupSet");
|
||||
ok(popupset, "found #mainPopupSet");
|
||||
|
||||
let popupsShown = 0;
|
||||
let hiddenPopups = 0;
|
||||
|
||||
let onpopupshown = function() {
|
||||
popupsShown++;
|
||||
if (popupsShown == 2) {
|
||||
document.removeEventListener("popupshown", onpopupshown, false);
|
||||
|
||||
executeSoon(function() {
|
||||
// Make sure the two panels are open.
|
||||
let popups = popupset.querySelectorAll("panel[hudId=" + hudId + "]");
|
||||
is(popups.length, 2, "found two popups");
|
||||
|
||||
document.addEventListener("popuphidden", onpopuphidden, false);
|
||||
|
||||
registerCleanupFunction(function() {
|
||||
is(hiddenPopups, 2, "correct number of popups hidden");
|
||||
if (hiddenPopups != 2) {
|
||||
document.removeEventListener("popuphidden", onpopuphidden, false);
|
||||
}
|
||||
});
|
||||
|
||||
// Now toggle private browsing off. We expect the panels to close.
|
||||
pb.privateBrowsingEnabled = !pb.privateBrowsingEnabled;
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
let onpopuphidden = function(aEvent) {
|
||||
// Skip popups that are not opened by the Web Console.
|
||||
if (!aEvent.target.hasAttribute("hudId")) {
|
||||
return;
|
||||
}
|
||||
|
||||
hiddenPopups++;
|
||||
if (hiddenPopups == 2) {
|
||||
document.removeEventListener("popuphidden", onpopuphidden, false);
|
||||
|
||||
executeSoon(function() {
|
||||
let popups = popupset.querySelectorAll("panel[hudId=" + hudId + "]");
|
||||
is(popups.length, 0, "no popups found");
|
||||
|
||||
ok(!pb.privateBrowsingEnabled, "private browsing is not enabled");
|
||||
|
||||
executeSoon(finishTest);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
document.addEventListener("popupshown", onpopupshown, false);
|
||||
|
||||
registerCleanupFunction(function() {
|
||||
is(popupsShown, 2, "correct number of popups shown");
|
||||
if (popupsShown != 2) {
|
||||
document.removeEventListener("popupshown", onpopupshown, false);
|
||||
}
|
||||
});
|
||||
|
||||
// Show the network and object inspector panels.
|
||||
EventUtils.synthesizeMouse(networkLink, 2, 2, {});
|
||||
EventUtils.synthesizeMouse(jstermMessage, 2, 2, {});
|
||||
}
|
||||
|
||||
function togglePBAndThen(callback) {
|
||||
function pbObserver(aSubject, aTopic, aData) {
|
||||
if (aTopic != "private-browsing-transition-complete") {
|
||||
return;
|
||||
}
|
||||
|
||||
Services.obs.removeObserver(pbObserver, "private-browsing-transition-complete");
|
||||
afterAllTabsLoaded(callback);
|
||||
}
|
||||
|
||||
Services.obs.addObserver(pbObserver, "private-browsing-transition-complete", false);
|
||||
pb.privateBrowsingEnabled = !pb.privateBrowsingEnabled;
|
||||
}
|
|
@ -82,6 +82,30 @@ function addTab(aURL)
|
|||
browser = gBrowser.getBrowserForTab(tab);
|
||||
}
|
||||
|
||||
function afterAllTabsLoaded(callback, win) {
|
||||
win = win || window;
|
||||
|
||||
let stillToLoad = 0;
|
||||
|
||||
function onLoad() {
|
||||
this.removeEventListener("load", onLoad, true);
|
||||
stillToLoad--;
|
||||
if (!stillToLoad)
|
||||
callback();
|
||||
}
|
||||
|
||||
for (let a = 0; a < win.gBrowser.tabs.length; a++) {
|
||||
let browser = win.gBrowser.tabs[a].linkedBrowser;
|
||||
if (browser.contentDocument.readyState != "complete") {
|
||||
stillToLoad++;
|
||||
browser.addEventListener("load", onLoad, true);
|
||||
}
|
||||
}
|
||||
|
||||
if (!stillToLoad)
|
||||
callback();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a log entry exists in the HUD output node.
|
||||
*
|
||||
|
|
Загрузка…
Ссылка в новой задаче