dom/events/test/test_bug415498.xul

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

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

mercurial