Merge m-c to inbound.

This commit is contained in:
Ryan VanderMeulen 2013-04-17 22:30:20 -04:00
commit 9f0bdeec0a
3 changed files with 67 additions and 38 deletions

View File

@ -320,6 +320,7 @@ TabTarget.prototype = {
let event = Object.create(null);
event.url = aPacket.url;
event.title = aPacket.title;
event.nativeConsoleAPI = aPacket.nativeConsoleAPI;
// Send any stored event payload (DOMWindow or nsIRequest) for backwards
// compatibility with non-remotable tools.
if (aPacket.state == "start") {

View File

@ -4,45 +4,72 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
const TEST_REPLACED_API_URI = "http://example.com/browser/browser/devtools/webconsole/test/test-console-replaced-api.html";
const TEST_URI = "http://example.com/browser/browser/devtools/webconsole/test/testscript.js";
function test() {
waitForExplicitFinish();
// First test that the warning does not appear on a normal page (about:blank)
addTab("about:blank");
// First test that the warning does not appear on a page that doesn't override
// the window.console object.
addTab(TEST_URI);
browser.addEventListener("load", function onLoad() {
browser.removeEventListener("load", onLoad, true);
testOpenWebConsole(false);
openConsole(null, testWarningNotPresent);
}, true);
}
function testWarningPresent() {
// Then test that the warning does appear on a page that replaces the API
browser.addEventListener("load", function onLoad() {
browser.removeEventListener("load", onLoad, true);
testOpenWebConsole(true);
}, true);
browser.contentWindow.location = TEST_REPLACED_API_URI;
}
function testWarningNotPresent(hud)
{
is(hud.outputNode.textContent.indexOf("logging API"), -1,
"no warning displayed");
function testOpenWebConsole(shouldWarn) {
openConsole(null, function(hud) {
waitForSuccess({
name: (shouldWarn ? "no " : "") + "API replacement warning",
validatorFn: function()
{
let pos = hud.outputNode.textContent.indexOf("disabled by");
return shouldWarn ? pos > -1 : pos == -1;
},
successFn: function() {
if (shouldWarn) {
finishTest();
}
else {
closeConsole(null, testWarningPresent);
}
},
failureFn: finishTest,
// Bug 862024: make sure the warning doesn't show after page reload.
info("reload " + TEST_URI);
executeSoon(() => content.location.reload());
waitForMessages({
webconsole: hud,
messages: [{
text: "testscript.js",
category: CATEGORY_NETWORK,
}],
}).then(() => executeSoon(() => {
is(hud.outputNode.textContent.indexOf("logging API"), -1,
"no warning displayed");
closeConsole(null, loadTestPage);
}));
}
function loadTestPage()
{
info("load test " + TEST_REPLACED_API_URI);
browser.addEventListener("load", function onLoad() {
browser.removeEventListener("load", onLoad, true);
openConsole(null, testWarningPresent);
}, true);
content.location = TEST_REPLACED_API_URI;
}
function testWarningPresent(hud)
{
info("wait for the warning to show");
let warning = {
webconsole: hud,
messages: [{
text: /logging API .+ disabled by a script/,
category: CATEGORY_JS,
severity: SEVERITY_WARNING,
}],
};
waitForMessages(warning).then(() => {
hud.jsterm.clearOutput();
executeSoon(() => {
info("reload the test page and wait for the warning to show");
waitForMessages(warning).then(finishTest);
content.location.reload();
});
});
});
}
}

View File

@ -4714,16 +4714,16 @@ WebConsoleConnectionProxy.prototype = {
},
/**
* The "tabNavigated" message type handler. We redirect any message to
* the UI for displaying.
* The "will-navigate" and "navigate" event handlers. We redirect any message
* to the UI for displaying.
*
* @private
* @param string aType
* Message type.
* @param string aEvent
* Event type.
* @param object aPacket
* The message received from the server.
*/
_onTabNavigated: function WCCP__onTabNavigated(aType, aPacket)
_onTabNavigated: function WCCP__onTabNavigated(aEvent, aPacket)
{
if (!this.owner) {
return;
@ -4733,7 +4733,7 @@ WebConsoleConnectionProxy.prototype = {
this.owner.onLocationChange(aPacket.url, aPacket.title);
}
if (aType == "navigate" && !aPacket.nativeConsoleAPI) {
if (aEvent == "navigate" && !aPacket.nativeConsoleAPI) {
this.owner.logWarningAboutReplacedAPI();
}
},
@ -4775,7 +4775,8 @@ WebConsoleConnectionProxy.prototype = {
this.client.removeListener("networkEvent", this._onNetworkEvent);
this.client.removeListener("networkEventUpdate", this._onNetworkEventUpdate);
this.client.removeListener("fileActivity", this._onFileActivity);
this.client.removeListener("tabNavigated", this._onTabNavigated);
this.target.off("will-navigate", this._onTabNavigated);
this.target.off("navigate", this._onTabNavigated);
this.client = null;
this.webConsoleClient = null;