dom/tests/mochitest/general/test_bug504220.html

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 <!DOCTYPE HTML>
michael@0 2 <html>
michael@0 3 <!--
michael@0 4 https://bugzilla.mozilla.org/show_bug.cgi?id=504220
michael@0 5 -->
michael@0 6 <head>
michael@0 7 <title>Test for Bug 504220</title>
michael@0 8 <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
michael@0 9 <script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
michael@0 10 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
michael@0 11 </head>
michael@0 12 <body onload="run_test();">
michael@0 13 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=504220">Mozilla Bug 504220</a>
michael@0 14 <p id="display"></p>
michael@0 15 <div id="content">
michael@0 16 <iframe id="frame" style="height:100px; width:100px; border:0"></iframe>
michael@0 17 <div id="status" style="display: none"></div>
michael@0 18 </div>
michael@0 19 <pre id="test">
michael@0 20 <script type="application/javascript;version=1.7">
michael@0 21
michael@0 22 /** Test for Bug 504220 **/
michael@0 23
michael@0 24 function run_test() {
michael@0 25 ok("onhashchange" in document.body,
michael@0 26 "document.body should contain 'onhashchange'.");
michael@0 27
michael@0 28 ok("onhashchange" in window, "window should contain 'onhashchange'.");
michael@0 29
michael@0 30 // window.onhashchange should mirror document.body.onhashchange.
michael@0 31 var func = function() { return 42; };
michael@0 32 document.body.onhashchange = func;
michael@0 33 is(window.onhashchange, func);
michael@0 34
michael@0 35 // Likewise, document.body.hashchange should mirror window.onhashchange
michael@0 36 numEvents = 0;
michael@0 37 var func2 = function() { numEvents++; gGen.next() };
michael@0 38 window.onhashchange = func2;
michael@0 39 is(document.body.onhashchange, func2);
michael@0 40
michael@0 41 SimpleTest.waitForExplicitFinish();
michael@0 42
michael@0 43 function waitForHashchange() {
michael@0 44 // Change the document's hash. If we've been running this test manually,
michael@0 45 // the hash might already be "#foo", so we need to check in order to be
michael@0 46 // sure we trigger a hashchange.
michael@0 47 if (location.hash != "#foo")
michael@0 48 location.hash = "#foo";
michael@0 49 else
michael@0 50 location.hash = "#bar";
michael@0 51
michael@0 52 yield undefined;
michael@0 53
michael@0 54 is(numEvents, 1, "Exactly one hashchange should have been fired.");
michael@0 55 SimpleTest.finish();
michael@0 56 yield undefined;
michael@0 57 }
michael@0 58
michael@0 59 var gGen = waitForHashchange();
michael@0 60 gGen.next();
michael@0 61 }
michael@0 62
michael@0 63 </script>
michael@0 64 </pre>
michael@0 65 </body>
michael@0 66 </html>

mercurial