|
1 <?xml version="1.0"?> |
|
2 <?xml-stylesheet href="chrome://global/skin" type="text/css"?> |
|
3 <?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css" |
|
4 type="text/css"?> |
|
5 <!-- |
|
6 https://bugzilla.mozilla.org/show_bug.cgi?id=415498 |
|
7 --> |
|
8 <window title="Mozilla Bug 415498" |
|
9 xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" |
|
10 onload="init()"> |
|
11 |
|
12 <script type="application/javascript" |
|
13 src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> |
|
14 <script type="application/javascript" |
|
15 src="chrome://mochikit/content/chrome-harness.js"></script> |
|
16 <body xmlns="http://www.w3.org/1999/xhtml"> |
|
17 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=415498">Mozilla Bug 415498</a> |
|
18 |
|
19 <p id="display"></p> |
|
20 |
|
21 <pre id="test"> |
|
22 <script class="testbody" type="application/javascript"><![CDATA[ |
|
23 |
|
24 /** Test for Bug 415498 **/ |
|
25 if (Cc === undefined) { |
|
26 var Cc = Components.classes; |
|
27 var Ci = Components.interfaces; |
|
28 } |
|
29 var Cr = Components.results; |
|
30 |
|
31 SimpleTest.waitForExplicitFinish(); |
|
32 |
|
33 var gTestsIterator; |
|
34 var gConsole; |
|
35 var gConsoleListener; |
|
36 var gMessages = []; |
|
37 |
|
38 function init() { |
|
39 gTestsIterator = testsIterator(); |
|
40 |
|
41 gConsole = Cc["@mozilla.org/consoleservice;1"]. |
|
42 getService(Ci.nsIConsoleService); |
|
43 |
|
44 gConsoleListener = { |
|
45 observe: function(aObject) { |
|
46 gMessages.push(aObject); |
|
47 } |
|
48 }; |
|
49 gConsole.registerListener(gConsoleListener); |
|
50 |
|
51 nextTest(); |
|
52 } |
|
53 |
|
54 function nextTest() { |
|
55 try { |
|
56 gTestsIterator.next(); |
|
57 } catch (err) { |
|
58 ok(err instanceof StopIteration, |
|
59 "Some other exception was thrown than what we expected!"); |
|
60 |
|
61 if (gConsole && gConsoleListener) { |
|
62 gConsole.unregisterListener(gConsoleListener); |
|
63 } |
|
64 SimpleTest.finish(); |
|
65 } |
|
66 } |
|
67 |
|
68 function testsIterator() { |
|
69 |
|
70 var browser = $("browser"); |
|
71 browser.addEventListener("load", function() { |
|
72 setTimeout(nextTest, 0) |
|
73 }, false); |
|
74 |
|
75 // 1) This document uses addEventListener to register a method throwing an exception |
|
76 var chromeDir = getRootDirectory(window.location.href); |
|
77 browser.loadURI(chromeDir + "bug415498-doc1.html"); |
|
78 yield undefined; |
|
79 |
|
80 ok(verifyErrorReceived("HierarchyRequestError"), |
|
81 "Error message not reported in event listener callback!"); |
|
82 gMessages = []; |
|
83 |
|
84 // 2) This document sets window.onload to register a method throwing an exception |
|
85 var chromeDir = getRootDirectory(window.location.href); |
|
86 browser.loadURI(chromeDir + "bug415498-doc2.html"); |
|
87 yield undefined; |
|
88 |
|
89 ok(verifyErrorReceived("HierarchyRequestError"), |
|
90 "Error message not reported in window.onload!"); |
|
91 } |
|
92 |
|
93 function verifyErrorReceived(errorString) { |
|
94 for (var i = 0; i < gMessages.length; i++) { |
|
95 if (gMessages[i].message.indexOf(errorString) != -1) |
|
96 return true; |
|
97 } |
|
98 return false; |
|
99 } |
|
100 ]]></script> |
|
101 </pre> |
|
102 </body> |
|
103 |
|
104 <browser id="browser" type="content" flex="1" src="about:blank"/> |
|
105 |
|
106 </window> |