mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 582201 - exceptions show twice in WebConsole, r=sdwilsh
This commit is contained in:
parent
ae5fb1827b
commit
6e97217b40
@ -26,6 +26,7 @@
|
|||||||
* Johnathan Nightingale <jnightingale@mozilla.com>
|
* Johnathan Nightingale <jnightingale@mozilla.com>
|
||||||
* Patrick Walton <pcwalton@mozilla.com>
|
* Patrick Walton <pcwalton@mozilla.com>
|
||||||
* Julian Viereck <jviereck@mozilla.com>
|
* Julian Viereck <jviereck@mozilla.com>
|
||||||
|
* Mihai Șucan <mihai.sucan@gmail.com>
|
||||||
*
|
*
|
||||||
* Alternatively, the contents of this file may be used under the terms of
|
* 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
|
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||||
@ -204,14 +205,18 @@ HUD_SERVICE.prototype =
|
|||||||
var origOnerrorFunc = window.onerror;
|
var origOnerrorFunc = window.onerror;
|
||||||
window.onerror = function windowOnError(aErrorMsg, aURL, aLineNumber)
|
window.onerror = function windowOnError(aErrorMsg, aURL, aLineNumber)
|
||||||
{
|
{
|
||||||
var lineNum = "";
|
if (aURL && !(aURL in self.uriRegistry)) {
|
||||||
if (aLineNumber) {
|
var lineNum = "";
|
||||||
lineNum = self.getFormatStr("errLine", [aLineNumber]);
|
if (aLineNumber) {
|
||||||
|
lineNum = self.getFormatStr("errLine", [aLineNumber]);
|
||||||
|
}
|
||||||
|
console.error(aErrorMsg + " @ " + aURL + " " + lineNum);
|
||||||
}
|
}
|
||||||
console.error(aErrorMsg + " @ " + aURL + " " + lineNum);
|
|
||||||
if (origOnerrorFunc) {
|
if (origOnerrorFunc) {
|
||||||
origOnerrorFunc(aErrorMsg, aURL, aLineNumber);
|
origOnerrorFunc(aErrorMsg, aURL, aLineNumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
@ -57,6 +57,7 @@ _BROWSER_TEST_PAGES = \
|
|||||||
test-data.json \
|
test-data.json \
|
||||||
test-property-provider.html \
|
test-property-provider.html \
|
||||||
test-error.html \
|
test-error.html \
|
||||||
|
test-duplicate-error.html \
|
||||||
$(NULL)
|
$(NULL)
|
||||||
|
|
||||||
libs:: $(_BROWSER_TEST_FILES)
|
libs:: $(_BROWSER_TEST_FILES)
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
* David Dahl <ddahl@mozilla.com>
|
* David Dahl <ddahl@mozilla.com>
|
||||||
* Patrick Walton <pcwalton@mozilla.com>
|
* Patrick Walton <pcwalton@mozilla.com>
|
||||||
* Julian Viereck <jviereck@mozilla.com>
|
* Julian Viereck <jviereck@mozilla.com>
|
||||||
|
* Mihai Șucan <mihai.sucan@gmail.com>
|
||||||
*
|
*
|
||||||
* Alternatively, the contents of this file may be used under the terms of
|
* 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
|
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||||
@ -69,6 +70,8 @@ const TEST_PROPERTY_PROVIDER_URI = "http://example.com/browser/toolkit/component
|
|||||||
|
|
||||||
const TEST_ERROR_URI = "http://example.com/browser/toolkit/components/console/hudservice/tests/browser/test-error.html";
|
const TEST_ERROR_URI = "http://example.com/browser/toolkit/components/console/hudservice/tests/browser/test-error.html";
|
||||||
|
|
||||||
|
const TEST_DUPLICATE_ERROR_URI = "http://example.com/browser/toolkit/components/console/hudservice/tests/browser/test-duplicate-error.html";
|
||||||
|
|
||||||
function noCacheUriSpec(aUriSpec) {
|
function noCacheUriSpec(aUriSpec) {
|
||||||
return aUriSpec + "?_=" + Date.now();
|
return aUriSpec + "?_=" + Date.now();
|
||||||
}
|
}
|
||||||
@ -656,17 +659,47 @@ function testErrorOnPageReload() {
|
|||||||
// see bug 580030: the error handler fails silently after page reload.
|
// see bug 580030: the error handler fails silently after page reload.
|
||||||
// https://bugzilla.mozilla.org/show_bug.cgi?id=580030
|
// https://bugzilla.mozilla.org/show_bug.cgi?id=580030
|
||||||
|
|
||||||
|
var consoleObserver = {
|
||||||
|
QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver]),
|
||||||
|
|
||||||
|
observe: function (aMessage)
|
||||||
|
{
|
||||||
|
// we ignore errors we don't care about
|
||||||
|
if (!(aMessage instanceof Ci.nsIScriptError) ||
|
||||||
|
aMessage.category != "content javascript") {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Services.console.unregisterListener(this);
|
||||||
|
|
||||||
|
const successMsg = "Found the error message after page reload";
|
||||||
|
const errMsg = "Could not get the error message after page reload";
|
||||||
|
|
||||||
|
var display = HUDService.getDisplayByURISpec(content.location.href);
|
||||||
|
var outputNode = display.querySelectorAll(".hud-output-node")[0];
|
||||||
|
|
||||||
|
executeSoon(function () {
|
||||||
|
testLogEntry(outputNode, "fooBazBaz",
|
||||||
|
{ success: successMsg, err: errMsg });
|
||||||
|
|
||||||
|
testDuplicateError();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
var pageReloaded = false;
|
var pageReloaded = false;
|
||||||
browser.addEventListener("DOMContentLoaded", function onDOMLoad() {
|
browser.addEventListener("load", function() {
|
||||||
if (!pageReloaded) {
|
if (!pageReloaded) {
|
||||||
pageReloaded = true;
|
pageReloaded = true;
|
||||||
content.location.reload();
|
content.location.reload();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
browser.removeEventListener("DOMContentLoaded", onDOMLoad, false);
|
browser.removeEventListener("load", arguments.callee, true);
|
||||||
|
|
||||||
|
// dispatch a click event to the button in the test page and listen for
|
||||||
|
// errors.
|
||||||
|
|
||||||
// dispatch a click event to the button in the test page.
|
|
||||||
var contentDocument = browser.contentDocument.wrappedJSObject;
|
var contentDocument = browser.contentDocument.wrappedJSObject;
|
||||||
var button = contentDocument.getElementsByTagName("button")[0];
|
var button = contentDocument.getElementsByTagName("button")[0];
|
||||||
var clickEvent = contentDocument.createEvent("MouseEvents");
|
var clickEvent = contentDocument.createEvent("MouseEvents");
|
||||||
@ -674,25 +707,53 @@ function testErrorOnPageReload() {
|
|||||||
browser.contentWindow.wrappedJSObject, 0, 0, 0, 0, 0, false, false,
|
browser.contentWindow.wrappedJSObject, 0, 0, 0, 0, 0, false, false,
|
||||||
false, false, 0, null);
|
false, false, 0, null);
|
||||||
|
|
||||||
var successMsg = "Found the error message after page reload";
|
Services.console.registerListener(consoleObserver);
|
||||||
var errMsg = "Could not get the error message after page reload";
|
|
||||||
|
|
||||||
var display = HUDService.getDisplayByURISpec(content.location.href);
|
|
||||||
var outputNode = display.querySelectorAll(".hud-output-node")[0];
|
|
||||||
|
|
||||||
button.addEventListener("click", function onClickHandler() {
|
|
||||||
button.removeEventListener("click", onClickHandler, false);
|
|
||||||
|
|
||||||
testLogEntry(outputNode, "fooBazBaz",
|
|
||||||
{ success: successMsg, err: errMsg });
|
|
||||||
|
|
||||||
testWebConsoleClose();
|
|
||||||
}, false);
|
|
||||||
|
|
||||||
button.dispatchEvent(clickEvent);
|
button.dispatchEvent(clickEvent);
|
||||||
}, false);
|
}, true);
|
||||||
|
|
||||||
content.location.href = TEST_ERROR_URI;
|
content.location = TEST_ERROR_URI;
|
||||||
|
}
|
||||||
|
|
||||||
|
function testDuplicateError() {
|
||||||
|
// see bug 582201 - exceptions show twice in WebConsole
|
||||||
|
// https://bugzilla.mozilla.org/show_bug.cgi?id=582201
|
||||||
|
|
||||||
|
var consoleObserver = {
|
||||||
|
QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver]),
|
||||||
|
|
||||||
|
observe: function (aMessage)
|
||||||
|
{
|
||||||
|
// we ignore errors we don't care about
|
||||||
|
if (!(aMessage instanceof Ci.nsIScriptError) ||
|
||||||
|
aMessage.category != "content javascript") {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Services.console.unregisterListener(this);
|
||||||
|
|
||||||
|
var display = HUDService.getDisplayByURISpec(content.location.href);
|
||||||
|
var outputNode = display.querySelectorAll(".hud-output-node")[0];
|
||||||
|
|
||||||
|
executeSoon(function () {
|
||||||
|
var text = outputNode.textContent;
|
||||||
|
var error1pos = text.indexOf("fooDuplicateError1");
|
||||||
|
ok(error1pos > -1, "found fooDuplicateError1");
|
||||||
|
if (error1pos > -1) {
|
||||||
|
ok(text.indexOf("fooDuplicateError1", error1pos + 1) == -1,
|
||||||
|
"no duplicate for fooDuplicateError1");
|
||||||
|
}
|
||||||
|
|
||||||
|
ok(text.indexOf("test-duplicate-error.html") > -1,
|
||||||
|
"found test-duplicate-error.html");
|
||||||
|
|
||||||
|
text = null;
|
||||||
|
testWebConsoleClose();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
Services.console.registerListener(consoleObserver);
|
||||||
|
content.location = TEST_DUPLICATE_ERROR_URI;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -0,0 +1,20 @@
|
|||||||
|
<!DOCTYPE HTML>
|
||||||
|
<html dir="ltr" xml:lang="en-US" lang="en-US">
|
||||||
|
<head>
|
||||||
|
<title>Console duplicate error test</title>
|
||||||
|
<!--
|
||||||
|
Any copyright is dedicated to the Public Domain.
|
||||||
|
http://creativecommons.org/publicdomain/zero/1.0/
|
||||||
|
|
||||||
|
See https://bugzilla.mozilla.org/show_bug.cgi?id=582201
|
||||||
|
-->
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>Heads Up Display - duplicate error test</h1>
|
||||||
|
|
||||||
|
<script type="text/javascript"><!--
|
||||||
|
fooDuplicateError1.bar();
|
||||||
|
// --></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user