docshell/test/test_bug640387_1.html

Wed, 31 Dec 2014 13:27:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 13:27:57 +0100
branch
TOR_BUG_3246
changeset 6
8bccb770b82d
permissions
-rw-r--r--

Ignore runtime configuration files generated during quality assurance.

michael@0 1 <!DOCTYPE HTML>
michael@0 2 <html>
michael@0 3 <!--
michael@0 4 https://bugzilla.mozilla.org/show_bug.cgi?id=640387
michael@0 5 -->
michael@0 6 <head>
michael@0 7 <title>Test for Bug 640387</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>
michael@0 13 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=640387">Mozilla Bug 640387</a>
michael@0 14
michael@0 15 <script type='application/javascript;version=1.7'>
michael@0 16 SimpleTest.waitForExplicitFinish();
michael@0 17
michael@0 18 function test() {
michael@0 19 /* Spin the event loop so we get out of the onload handler. */
michael@0 20 SimpleTest.executeSoon(function() { gGen.next() });
michael@0 21 yield undefined;
michael@0 22
michael@0 23 popup.history.pushState('', '', '#hash1');
michael@0 24 popup.history.pushState('', '', '#hash2');
michael@0 25
michael@0 26 // Now the history looks like:
michael@0 27 // file_bug640387.html
michael@0 28 // file_bug640387.html#hash1
michael@0 29 // file_bug640387.html#hash2 <-- current
michael@0 30
michael@0 31 // Going back should trigger a hashchange, which will wake us up from the
michael@0 32 // yield.
michael@0 33 popup.history.back();
michael@0 34 yield undefined;
michael@0 35 ok(true, 'Got first hashchange.');
michael@0 36
michael@0 37 // Going back should wake us up again.
michael@0 38 popup.history.back();
michael@0 39 yield undefined;
michael@0 40 ok(true, 'Got second hashchange.');
michael@0 41
michael@0 42 // Now the history looks like:
michael@0 43 // file_bug640387.html <-- current
michael@0 44 // file_bug640387.html#hash1
michael@0 45 // file_bug640387.html#hash2
michael@0 46
michael@0 47 // Going forward should trigger a hashchange.
michael@0 48 popup.history.forward();
michael@0 49 yield undefined;
michael@0 50 ok(true, 'Got third hashchange.');
michael@0 51
michael@0 52 // Now modify the history so it looks like:
michael@0 53 // file_bug640387.html
michael@0 54 // file_bug640387.html#hash1
michael@0 55 // file_bug640387.html#hash1 <-- current
michael@0 56 popup.history.pushState('', '', '#hash1');
michael@0 57
michael@0 58 // Now when we go back, we should not get a hashchange. Instead, wait for a
michael@0 59 // popstate. We need to asynchronously go back because popstate is fired
michael@0 60 // sync.
michael@0 61 gHashchangeExpected = false;
michael@0 62 gCallbackOnPopstate = true;
michael@0 63 SimpleTest.executeSoon(function() { popup.history.back() });
michael@0 64 yield undefined;
michael@0 65 ok(true, 'Got popstate.');
michael@0 66 gCallbackOnPopstate = false;
michael@0 67
michael@0 68 // Spin the event loop so hashchange has a chance to fire, if it's going to.
michael@0 69 SimpleTest.executeSoon(function() { gGen.next() });
michael@0 70 yield undefined;
michael@0 71
michael@0 72 popup.close();
michael@0 73 SimpleTest.finish();
michael@0 74 yield undefined;
michael@0 75 }
michael@0 76
michael@0 77 gGen = null;
michael@0 78 function childLoad() {
michael@0 79 gGen = test();
michael@0 80 gGen.next();
michael@0 81 }
michael@0 82
michael@0 83 gHashchangeExpected = true;
michael@0 84 function childHashchange() {
michael@0 85 if (gHashchangeExpected) {
michael@0 86 gGen.next();
michael@0 87 }
michael@0 88 else {
michael@0 89 ok(false, "Got hashchange when we weren't expecting one.");
michael@0 90 }
michael@0 91 }
michael@0 92
michael@0 93 gCallbackOnPopstate = false;
michael@0 94 function childPopstate() {
michael@0 95 if (gCallbackOnPopstate) {
michael@0 96 gGen.next();
michael@0 97 }
michael@0 98 }
michael@0 99
michael@0 100 /* We need to run this test in a popup, because navigating an iframe
michael@0 101 * back/forwards tends to cause intermittent orange. */
michael@0 102 popup = window.open('file_bug640387.html');
michael@0 103
michael@0 104 /* Control now flows up to childLoad(), called once the popup loads. */
michael@0 105
michael@0 106 </script>
michael@0 107
michael@0 108 </body>
michael@0 109 </html>

mercurial