1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/events/test/test_bug415498.xul Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,106 @@ 1.4 +<?xml version="1.0"?> 1.5 +<?xml-stylesheet href="chrome://global/skin" type="text/css"?> 1.6 +<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" 1.7 + type="text/css"?> 1.8 +<!-- 1.9 +https://bugzilla.mozilla.org/show_bug.cgi?id=415498 1.10 +--> 1.11 +<window title="Mozilla Bug 415498" 1.12 + xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" 1.13 + onload="init()"> 1.14 + 1.15 + <script type="application/javascript" 1.16 + src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> 1.17 + <script type="application/javascript" 1.18 + src="chrome://mochikit/content/chrome-harness.js"></script> 1.19 +<body xmlns="http://www.w3.org/1999/xhtml"> 1.20 + <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=415498">Mozilla Bug 415498</a> 1.21 + 1.22 + <p id="display"></p> 1.23 + 1.24 + <pre id="test"> 1.25 + <script class="testbody" type="application/javascript"><![CDATA[ 1.26 + 1.27 + /** Test for Bug 415498 **/ 1.28 + if (Cc === undefined) { 1.29 + var Cc = Components.classes; 1.30 + var Ci = Components.interfaces; 1.31 + } 1.32 + var Cr = Components.results; 1.33 + 1.34 + SimpleTest.waitForExplicitFinish(); 1.35 + 1.36 + var gTestsIterator; 1.37 + var gConsole; 1.38 + var gConsoleListener; 1.39 + var gMessages = []; 1.40 + 1.41 + function init() { 1.42 + gTestsIterator = testsIterator(); 1.43 + 1.44 + gConsole = Cc["@mozilla.org/consoleservice;1"]. 1.45 + getService(Ci.nsIConsoleService); 1.46 + 1.47 + gConsoleListener = { 1.48 + observe: function(aObject) { 1.49 + gMessages.push(aObject); 1.50 + } 1.51 + }; 1.52 + gConsole.registerListener(gConsoleListener); 1.53 + 1.54 + nextTest(); 1.55 + } 1.56 + 1.57 + function nextTest() { 1.58 + try { 1.59 + gTestsIterator.next(); 1.60 + } catch (err) { 1.61 + ok(err instanceof StopIteration, 1.62 + "Some other exception was thrown than what we expected!"); 1.63 + 1.64 + if (gConsole && gConsoleListener) { 1.65 + gConsole.unregisterListener(gConsoleListener); 1.66 + } 1.67 + SimpleTest.finish(); 1.68 + } 1.69 + } 1.70 + 1.71 + function testsIterator() { 1.72 + 1.73 + var browser = $("browser"); 1.74 + browser.addEventListener("load", function() { 1.75 + setTimeout(nextTest, 0) 1.76 + }, false); 1.77 + 1.78 + // 1) This document uses addEventListener to register a method throwing an exception 1.79 + var chromeDir = getRootDirectory(window.location.href); 1.80 + browser.loadURI(chromeDir + "bug415498-doc1.html"); 1.81 + yield undefined; 1.82 + 1.83 + ok(verifyErrorReceived("HierarchyRequestError"), 1.84 + "Error message not reported in event listener callback!"); 1.85 + gMessages = []; 1.86 + 1.87 + // 2) This document sets window.onload to register a method throwing an exception 1.88 + var chromeDir = getRootDirectory(window.location.href); 1.89 + browser.loadURI(chromeDir + "bug415498-doc2.html"); 1.90 + yield undefined; 1.91 + 1.92 + ok(verifyErrorReceived("HierarchyRequestError"), 1.93 + "Error message not reported in window.onload!"); 1.94 + } 1.95 + 1.96 + function verifyErrorReceived(errorString) { 1.97 + for (var i = 0; i < gMessages.length; i++) { 1.98 + if (gMessages[i].message.indexOf(errorString) != -1) 1.99 + return true; 1.100 + } 1.101 + return false; 1.102 + } 1.103 + ]]></script> 1.104 + </pre> 1.105 +</body> 1.106 + 1.107 +<browser id="browser" type="content" flex="1" src="about:blank"/> 1.108 + 1.109 +</window>