Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | <?xml version="1.0"?> |
michael@0 | 2 | <?xml-stylesheet href="chrome://global/skin" type="text/css"?> |
michael@0 | 3 | |
michael@0 | 4 | <window id="303267Test" |
michael@0 | 5 | xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" |
michael@0 | 6 | width="600" |
michael@0 | 7 | height="600" |
michael@0 | 8 | onload="setTimeout(nextTest,0);" |
michael@0 | 9 | title="bug 662200 test"> |
michael@0 | 10 | |
michael@0 | 11 | <script type="application/javascript" |
michael@0 | 12 | src="docshell_helpers.js"> |
michael@0 | 13 | </script> |
michael@0 | 14 | <script type="application/javascript" src= "chrome://mochikit/content/chrome-harness.js" /> |
michael@0 | 15 | <script type="application/javascript"><![CDATA[ |
michael@0 | 16 | |
michael@0 | 17 | // Define the generator-iterator for the tests. |
michael@0 | 18 | var tests = testIterator(); |
michael@0 | 19 | |
michael@0 | 20 | //// |
michael@0 | 21 | // Execute the next test in the generator function. |
michael@0 | 22 | // |
michael@0 | 23 | function nextTest() { |
michael@0 | 24 | tests.next(); |
michael@0 | 25 | } |
michael@0 | 26 | |
michael@0 | 27 | //// |
michael@0 | 28 | // Generator function for test steps for bug 662200: |
michael@0 | 29 | // Description goes here. |
michael@0 | 30 | // |
michael@0 | 31 | function testIterator() |
michael@0 | 32 | { |
michael@0 | 33 | // Load the first test page |
michael@0 | 34 | var navData = { |
michael@0 | 35 | uri: getHttpUrl("662200a.html"), |
michael@0 | 36 | eventsToListenFor: ["pageshow"], |
michael@0 | 37 | expectedEvents: [ {type: "pageshow", title: "A"} ], |
michael@0 | 38 | onNavComplete: nextTest |
michael@0 | 39 | }; |
michael@0 | 40 | doPageNavigation(navData); |
michael@0 | 41 | yield undefined; |
michael@0 | 42 | |
michael@0 | 43 | // Load the second test page. |
michael@0 | 44 | navData = { |
michael@0 | 45 | eventsToListenFor: ["pageshow", "pagehide"], |
michael@0 | 46 | expectedEvents: [ {type: "pagehide", |
michael@0 | 47 | title: "A"}, |
michael@0 | 48 | {type: "pageshow", |
michael@0 | 49 | title: "B"} ], |
michael@0 | 50 | onNavComplete: nextTest |
michael@0 | 51 | } |
michael@0 | 52 | waitForPageEvents(navData); |
michael@0 | 53 | var link = TestWindow.getDocument().getElementById("link"); |
michael@0 | 54 | var event = TestWindow.getDocument().createEvent("MouseEvents"); |
michael@0 | 55 | event.initMouseEvent("click", true, true, TestWindow.getWindow(), |
michael@0 | 56 | 0, 0, 0, 0, 0, false, false, false, false, 0, null); |
michael@0 | 57 | link.dispatchEvent(event); |
michael@0 | 58 | yield undefined; |
michael@0 | 59 | |
michael@0 | 60 | // Load the third test page. |
michael@0 | 61 | navData = { |
michael@0 | 62 | eventsToListenFor: ["pageshow", "pagehide"], |
michael@0 | 63 | expectedEvents: [ {type: "pagehide", |
michael@0 | 64 | title: "B"}, |
michael@0 | 65 | {type: "pageshow", |
michael@0 | 66 | title: "C"} ], |
michael@0 | 67 | onNavComplete: nextTest |
michael@0 | 68 | }; |
michael@0 | 69 | waitForPageEvents(navData); |
michael@0 | 70 | var link = TestWindow.getDocument().getElementById("link"); |
michael@0 | 71 | var event = TestWindow.getDocument().createEvent("MouseEvents"); |
michael@0 | 72 | event.initMouseEvent("click", true, true, TestWindow.getWindow(), |
michael@0 | 73 | 0, 0, 0, 0, 0, false, false, false, false, 0, null); |
michael@0 | 74 | link.dispatchEvent(event); |
michael@0 | 75 | yield undefined; |
michael@0 | 76 | |
michael@0 | 77 | // Go back. |
michael@0 | 78 | navData = { |
michael@0 | 79 | back: true, |
michael@0 | 80 | eventsToListenFor: ["pageshow", "pagehide"], |
michael@0 | 81 | expectedEvents: [ {type: "pagehide", |
michael@0 | 82 | title: "C"}, |
michael@0 | 83 | {type: "pageshow", |
michael@0 | 84 | title: "B"} ], |
michael@0 | 85 | onNavComplete: nextTest |
michael@0 | 86 | }; |
michael@0 | 87 | doPageNavigation(navData); |
michael@0 | 88 | yield undefined; |
michael@0 | 89 | |
michael@0 | 90 | var Ci = Components.interfaces; |
michael@0 | 91 | var docshell = TestWindow.getWindow() |
michael@0 | 92 | .QueryInterface(Ci.nsIInterfaceRequestor) |
michael@0 | 93 | .getInterface(Ci.nsIWebNavigation) |
michael@0 | 94 | .QueryInterface(Ci.nsIDocShell); |
michael@0 | 95 | var shistory = docshell.QueryInterface(Ci.nsIInterfaceRequestor) |
michael@0 | 96 | .getInterface(Ci.nsISHistory) |
michael@0 | 97 | .QueryInterface(Ci.nsIWebNavigation); |
michael@0 | 98 | |
michael@0 | 99 | // Reload. |
michael@0 | 100 | navData = { |
michael@0 | 101 | eventsToListenFor: ["pageshow", "pagehide"], |
michael@0 | 102 | expectedEvents: [ {type: "pagehide", |
michael@0 | 103 | title: "B"}, |
michael@0 | 104 | {type: "pageshow", |
michael@0 | 105 | title: "B"} ], |
michael@0 | 106 | onNavComplete: nextTest |
michael@0 | 107 | }; |
michael@0 | 108 | // Asking the docshell harness to reload for us will call reload on |
michael@0 | 109 | // nsDocShell which has different behavior than the reload on nsSHistory |
michael@0 | 110 | // so we call reload explicitly here |
michael@0 | 111 | waitForPageEvents(navData); |
michael@0 | 112 | shistory.reload(0); |
michael@0 | 113 | yield undefined; |
michael@0 | 114 | |
michael@0 | 115 | // After this sequence of events, we should be able to go back and forward |
michael@0 | 116 | is(TestWindow.getBrowser().canGoBack, true, "Should be able to go back!"); |
michael@0 | 117 | is(TestWindow.getBrowser().canGoForward, true, "Should be able to go forward!"); |
michael@0 | 118 | is(shistory.requestedIndex, -1, "Requested index should be cleared!"); |
michael@0 | 119 | |
michael@0 | 120 | // Tell the framework the test is finished. Include the final 'yield' |
michael@0 | 121 | // statement to prevent a StopIteration exception from being thrown. |
michael@0 | 122 | finish(); |
michael@0 | 123 | yield undefined; |
michael@0 | 124 | } |
michael@0 | 125 | |
michael@0 | 126 | ]]></script> |
michael@0 | 127 | |
michael@0 | 128 | <browser type="content-primary" flex="1" id="content" src="about:blank"/> |
michael@0 | 129 | </window> |