Wed, 31 Dec 2014 13:27:57 +0100
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=602256 |
michael@0 | 5 | --> |
michael@0 | 6 | <head> |
michael@0 | 7 | <title>Test for Bug 602256</title> |
michael@0 | 8 | </head> |
michael@0 | 9 | <body onload="SimpleTest.executeSoon(run_test)"> |
michael@0 | 10 | <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=602256">Mozilla Bug 602256</a> |
michael@0 | 11 | <div id="content"> |
michael@0 | 12 | <iframe id="iframe" src="data:text/html,<p%20id='text'>Start</p>"></iframe> |
michael@0 | 13 | </div> |
michael@0 | 14 | <pre id="test"> |
michael@0 | 15 | <script type="application/javascript"> |
michael@0 | 16 | |
michael@0 | 17 | /** Test for Bug 602256 **/ |
michael@0 | 18 | |
michael@0 | 19 | var testWin = window.opener ? window.opener : window.parent; |
michael@0 | 20 | |
michael@0 | 21 | var SimpleTest = testWin.SimpleTest; |
michael@0 | 22 | function is() { testWin.is.apply(testWin, arguments); } |
michael@0 | 23 | |
michael@0 | 24 | var gFrame = null; |
michael@0 | 25 | |
michael@0 | 26 | function gState() { |
michael@0 | 27 | return location.hash.replace(/^#/, ""); |
michael@0 | 28 | } |
michael@0 | 29 | |
michael@0 | 30 | function waitForLoad(aCallback) { |
michael@0 | 31 | function listener() { |
michael@0 | 32 | gFrame.removeEventListener("load", listener, false); |
michael@0 | 33 | SimpleTest.executeSoon(aCallback); |
michael@0 | 34 | } |
michael@0 | 35 | |
michael@0 | 36 | gFrame.addEventListener("load", listener, false); |
michael@0 | 37 | } |
michael@0 | 38 | |
michael@0 | 39 | function loadContent(aURL, aCallback) { |
michael@0 | 40 | waitForLoad(aCallback); |
michael@0 | 41 | |
michael@0 | 42 | gFrame.src = aURL; |
michael@0 | 43 | } |
michael@0 | 44 | |
michael@0 | 45 | function getURL() { |
michael@0 | 46 | return gFrame.contentDocument.documentURI; |
michael@0 | 47 | } |
michael@0 | 48 | |
michael@0 | 49 | function getContent() { |
michael@0 | 50 | return gFrame.contentDocument.getElementById("text").textContent; |
michael@0 | 51 | } |
michael@0 | 52 | |
michael@0 | 53 | var START = "data:text/html,<p%20id='text'>Start</p>"; |
michael@0 | 54 | var URL1 = "data:text/html,<p%20id='text'>Test1</p>"; |
michael@0 | 55 | var URL2 = "data:text/html,<p%20id='text'>Test2</p>"; |
michael@0 | 56 | |
michael@0 | 57 | function run_test() { |
michael@0 | 58 | window.location.hash = "START"; |
michael@0 | 59 | |
michael@0 | 60 | gFrame = document.getElementById("iframe"); |
michael@0 | 61 | |
michael@0 | 62 | test_basic_inner_navigation(); |
michael@0 | 63 | } |
michael@0 | 64 | |
michael@0 | 65 | function end_test() { |
michael@0 | 66 | testWin.done(); |
michael@0 | 67 | } |
michael@0 | 68 | |
michael@0 | 69 | function test_basic_inner_navigation() { |
michael@0 | 70 | // Navigate the inner frame a few times |
michael@0 | 71 | loadContent(URL1, function() { |
michael@0 | 72 | is(getURL(), URL1, "URL should be correct"); |
michael@0 | 73 | is(getContent(), "Test1", "Page should be correct"); |
michael@0 | 74 | |
michael@0 | 75 | loadContent(URL2, function() { |
michael@0 | 76 | is(getURL(), URL2, "URL should be correct"); |
michael@0 | 77 | is(getContent(), "Test2", "Page should be correct"); |
michael@0 | 78 | |
michael@0 | 79 | // Test that history is working |
michael@0 | 80 | waitForLoad(function() { |
michael@0 | 81 | is(getURL(), URL1, "URL should be correct"); |
michael@0 | 82 | is(getContent(), "Test1", "Page should be correct"); |
michael@0 | 83 | |
michael@0 | 84 | waitForLoad(function() { |
michael@0 | 85 | is(getURL(), URL2, "URL should be correct"); |
michael@0 | 86 | is(getContent(), "Test2", "Page should be correct"); |
michael@0 | 87 | |
michael@0 | 88 | test_state_navigation(); |
michael@0 | 89 | }); |
michael@0 | 90 | window.history.forward(); |
michael@0 | 91 | }); |
michael@0 | 92 | window.history.back(); |
michael@0 | 93 | }); |
michael@0 | 94 | }); |
michael@0 | 95 | } |
michael@0 | 96 | |
michael@0 | 97 | function test_state_navigation() { |
michael@0 | 98 | window.location.hash = "STATE1"; |
michael@0 | 99 | |
michael@0 | 100 | is(getURL(), URL2, "URL should be correct"); |
michael@0 | 101 | is(getContent(), "Test2", "Page should be correct"); |
michael@0 | 102 | |
michael@0 | 103 | window.location.hash = "STATE2"; |
michael@0 | 104 | |
michael@0 | 105 | is(getURL(), URL2, "URL should be correct"); |
michael@0 | 106 | is(getContent(), "Test2", "Page should be correct"); |
michael@0 | 107 | |
michael@0 | 108 | window.history.back(); |
michael@0 | 109 | |
michael@0 | 110 | is(gState(), "STATE1", "State should be correct after going back"); |
michael@0 | 111 | is(getURL(), URL2, "URL should be correct"); |
michael@0 | 112 | is(getContent(), "Test2", "Page should be correct"); |
michael@0 | 113 | |
michael@0 | 114 | window.history.forward(); |
michael@0 | 115 | |
michael@0 | 116 | is(gState(), "STATE2", "State should be correct after going forward"); |
michael@0 | 117 | is(getURL(), URL2, "URL should be correct"); |
michael@0 | 118 | is(getContent(), "Test2", "Page should be correct"); |
michael@0 | 119 | |
michael@0 | 120 | window.history.back(); |
michael@0 | 121 | window.history.back(); |
michael@0 | 122 | |
michael@0 | 123 | is(gState(), "START", "State should be correct"); |
michael@0 | 124 | is(getURL(), URL2, "URL should be correct"); |
michael@0 | 125 | is(getContent(), "Test2", "Page should be correct"); |
michael@0 | 126 | |
michael@0 | 127 | waitForLoad(function() { |
michael@0 | 128 | is(getURL(), URL1, "URL should be correct"); |
michael@0 | 129 | is(getContent(), "Test1", "Page should be correct"); |
michael@0 | 130 | |
michael@0 | 131 | waitForLoad(function() { |
michael@0 | 132 | is(gState(), "START", "State should be correct"); |
michael@0 | 133 | is(getURL(), START, "URL should be correct"); |
michael@0 | 134 | is(getContent(), "Start", "Page should be correct"); |
michael@0 | 135 | |
michael@0 | 136 | end_test(); |
michael@0 | 137 | }); |
michael@0 | 138 | |
michael@0 | 139 | window.history.back(); |
michael@0 | 140 | |
michael@0 | 141 | is(gState(), "START", "State should be correct after going back twice"); |
michael@0 | 142 | }); |
michael@0 | 143 | |
michael@0 | 144 | window.history.back(); |
michael@0 | 145 | is(gState(), "START", "State should be correct"); |
michael@0 | 146 | } |
michael@0 | 147 | </script> |
michael@0 | 148 | </pre> |
michael@0 | 149 | </body> |
michael@0 | 150 | </html> |