bug 580030 - the error handler fails silently after a page reload, r=gavin

This commit is contained in:
Mihai Sucan 2010-07-26 13:35:12 -03:00
parent 0ab719f773
commit c83a2ddfc2
4 changed files with 74 additions and 5 deletions

View File

@ -1733,15 +1733,19 @@ HeadsUpDisplay.prototype = {
makeHTMLNode:
function HUD_makeHTMLNode(aTag)
{
try {
return this.HTMLFactory(aTag);
var element;
if (this.HTMLFactory) {
element = this.HTMLFactory(aTag);
}
catch (ex) {
else {
var ns = ELEMENT_NS;
var nsUri = ELEMENT_NS_URI;
var tag = ns + aTag;
return this.chromeDocument.createElementNS(nsUri, tag);
element = this.chromeDocument.createElementNS(nsUri, tag);
}
return element;
},
/**

View File

@ -56,6 +56,7 @@ _BROWSER_TEST_PAGES = \
test-observe-http-ajax.html \
test-data.json \
test-property-provider.html \
test-error.html \
$(NULL)
libs:: $(_BROWSER_TEST_FILES)

View File

@ -66,6 +66,8 @@ const TEST_FILTER_URI = "http://example.com/browser/toolkit/components/console/h
const TEST_PROPERTY_PROVIDER_URI = "http://example.com/browser/toolkit/components/console/hudservice/tests/browser/test-property-provider.html";
const TEST_ERROR_URI = "http://example.com/browser/toolkit/components/console/hudservice/tests/browser/test-error.html";
function noCacheUriSpec(aUriSpec) {
return aUriSpec + "?_=" + Date.now();
}
@ -591,12 +593,55 @@ function testPageReload() {
is(typeof console.error, "function", "console.error is a function");
is(typeof console.exception, "function", "console.exception is a function");
testEnd();
testErrorOnPageReload();
}, false);
content.location.reload();
}
function testErrorOnPageReload() {
// see bug 580030: the error handler fails silently after page reload.
// https://bugzilla.mozilla.org/show_bug.cgi?id=580030
var pageReloaded = false;
browser.addEventListener("DOMContentLoaded", function onDOMLoad() {
if (!pageReloaded) {
pageReloaded = true;
content.location.reload();
return;
}
browser.removeEventListener("DOMContentLoaded", onDOMLoad, false);
// dispatch a click event to the button in the test page.
var contentDocument = browser.contentDocument.wrappedJSObject;
var button = contentDocument.getElementsByTagName("button")[0];
var clickEvent = contentDocument.createEvent("MouseEvents");
clickEvent.initMouseEvent("click", true, true,
browser.contentWindow.wrappedJSObject, 0, 0, 0, 0, 0, false, false,
false, false, 0, null);
var successMsg = "Found the error message after page reload";
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 });
testEnd();
}, false);
button.dispatchEvent(clickEvent);
}, false);
content.location.href = TEST_ERROR_URI;
}
function testEnd() {
// testUnregister();
executeSoon(function () {

View File

@ -0,0 +1,19 @@
<!DOCTYPE HTML>
<html dir="ltr" xml:lang="en-US" lang="en-US">
<head>
<title>Console error test</title>
</head>
<body>
<h1>Heads Up Display - error test</h1>
<p><button>generate error</button></p>
<script type="text/javascript"><!--
var button = document.getElementsByTagName("button")[0];
button.addEventListener("click", function () {
fooBazBaz.bar();
}, false);
// --></script>
</body>
</html>