docshell/test/chrome/bug298622_window.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
-rwxr-xr-x

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
michael@0 4 <window id="298622Test"
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 298622 test">
michael@0 10
michael@0 11 <script type="text/javascript"
michael@0 12 src="chrome://mochikit/content/tests/SimpleTest/specialpowersAPI.js"/>
michael@0 13 <script type="text/javascript"
michael@0 14 src="chrome://mochikit/content/tests/SimpleTest/SpecialPowersObserverAPI.js"/>
michael@0 15 <script type="text/javascript"
michael@0 16 src="chrome://mochikit/content/tests/SimpleTest/ChromePowers.js"/>
michael@0 17 <script type="application/javascript" src= "chrome://mochikit/content/chrome-harness.js" />
michael@0 18 <script type="application/javascript" src= "docshell_helpers.js" />
michael@0 19 <script type="application/javascript"><![CDATA[
michael@0 20 // Global variable that holds a reference to the find bar.
michael@0 21 var gFindBar;
michael@0 22
michael@0 23 // Define the generator-iterator for the tests.
michael@0 24 var tests = testIterator();
michael@0 25
michael@0 26 ////
michael@0 27 // Execute the next test in the generator function.
michael@0 28 //
michael@0 29 function nextTest() {
michael@0 30 tests.next();
michael@0 31 }
michael@0 32
michael@0 33 ////
michael@0 34 // Generator function for test steps for bug 298622:
michael@0 35 // Find should work correctly on a page loaded from the
michael@0 36 // bfcache.
michael@0 37 //
michael@0 38 function testIterator()
michael@0 39 {
michael@0 40 // Make sure bfcache is on.
michael@0 41 enableBFCache(true);
michael@0 42
michael@0 43 // Load a test page which contains some text to be found.
michael@0 44 doPageNavigation({
michael@0 45 uri: "data:text/html,<html><head><title>test1</title></head>" +
michael@0 46 "<body>find this!</body></html>",
michael@0 47 onNavComplete: nextTest
michael@0 48 });
michael@0 49 yield undefined;
michael@0 50
michael@0 51 // Load a second, dummy page, verifying that the original
michael@0 52 // page gets stored in the bfcache.
michael@0 53 doPageNavigation({
michael@0 54 uri: getHttpUrl("generic.html"),
michael@0 55 eventsToListenFor: ["pageshow", "pagehide"],
michael@0 56 expectedEvents: [ { type: "pagehide",
michael@0 57 title: "test1",
michael@0 58 persisted: true },
michael@0 59 { type: "pageshow",
michael@0 60 title: "generic page" } ],
michael@0 61 onNavComplete: nextTest
michael@0 62 });
michael@0 63 yield undefined;
michael@0 64
michael@0 65 // Make sure we unsuppress painting before continuing
michael@0 66 SimpleTest.executeSoon(nextTest);
michael@0 67 yield undefined;
michael@0 68
michael@0 69 // Search for some text that's on the second page (but not on
michael@0 70 // the first page), and verify that it can be found.
michael@0 71 gFindBar = document.getElementById("FindToolbar");
michael@0 72 document.getElementById("cmd_find").doCommand();
michael@0 73 ok(!gFindBar.hidden, "failed to open findbar");
michael@0 74 gFindBar._findField.value = "A generic page";
michael@0 75 gFindBar._find();
michael@0 76 SimpleTest.executeSoon(nextTest);
michael@0 77 yield undefined;
michael@0 78
michael@0 79 // Make sure Find bar's internal status is not 'notfound'
michael@0 80 isnot(gFindBar._findField.getAttribute("status"), "notfound",
michael@0 81 "Findfield status attribute should not have been 'notfound'" +
michael@0 82 " after Find");
michael@0 83
michael@0 84 // Make sure the key events above have time to be processed
michael@0 85 // before continuing
michael@0 86 waitForTrue(function() {
michael@0 87 return (
michael@0 88 TestWindow.getWindow().getSelection().toString().toLowerCase() ==
michael@0 89 "a generic page");
michael@0 90 }, nextTest, 20);
michael@0 91 yield undefined;
michael@0 92
michael@0 93 is(gFindBar._findField.inputField.value, "A generic page",
michael@0 94 "expected text not present in find input field");
michael@0 95 is(TestWindow.getWindow().getSelection().toString().toLowerCase(),
michael@0 96 "a generic page",
michael@0 97 "find failed on second page loaded");
michael@0 98
michael@0 99 // Go back to the original page and verify it's loaded from the
michael@0 100 // bfcache.
michael@0 101 doPageNavigation({
michael@0 102 back: true,
michael@0 103 eventsToListenFor: ["pageshow"],
michael@0 104 expectedEvents: [ { type: "pageshow",
michael@0 105 title: "test1",
michael@0 106 persisted: true } ],
michael@0 107 onNavComplete: nextTest
michael@0 108 });
michael@0 109 yield undefined;
michael@0 110
michael@0 111 // Search for some text that's on the original page (but not
michael@0 112 // the dummy page loaded above), and verify that it can
michael@0 113 // be found.
michael@0 114 gFindBar = document.getElementById("FindToolbar");
michael@0 115 document.getElementById("cmd_find").doCommand();
michael@0 116 ok(!gFindBar.hidden, "failed to open findbar");
michael@0 117 gFindBar._findField.value = "find this";
michael@0 118 gFindBar._find();
michael@0 119 SimpleTest.executeSoon(nextTest);
michael@0 120 yield undefined;
michael@0 121
michael@0 122 // Make sure Find bar's internal status is not 'notfound'
michael@0 123 isnot(gFindBar._findField.getAttribute("status"), "notfound",
michael@0 124 "Findfield status attribute should not have been 'notfound'" +
michael@0 125 " after Find");
michael@0 126
michael@0 127 // Make sure the key events above have time to be processed
michael@0 128 // before continuing
michael@0 129 waitForTrue(function() {
michael@0 130 return (
michael@0 131 TestWindow.getWindow().getSelection().toString().toLowerCase() ==
michael@0 132 "find this");
michael@0 133 }, nextTest, 20);
michael@0 134 yield undefined;
michael@0 135
michael@0 136 is(TestWindow.getWindow().getSelection().toString().toLowerCase(),
michael@0 137 "find this",
michael@0 138 "find failed on page loaded from bfcache");
michael@0 139
michael@0 140 // Tell the framework the test is finished. Include the final 'yield'
michael@0 141 // statement to prevent a StopIteration exception from being thrown.
michael@0 142 finish();
michael@0 143 yield undefined;
michael@0 144 }
michael@0 145
michael@0 146 ]]></script>
michael@0 147
michael@0 148 <commandset>
michael@0 149 <command id="cmd_find"
michael@0 150 oncommand="document.getElementById('FindToolbar').onFindCommand();"/>
michael@0 151 </commandset>
michael@0 152 <browser type="content-primary" flex="1" id="content" src="about:blank"/>
michael@0 153 <findbar id="FindToolbar" browserid="content"/>
michael@0 154 </window>

mercurial