2 <?xml-stylesheet href=
"chrome://global/skin" type=
"text/css"?>
4 <window id=
"298622Test"
5 xmlns=
"http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
8 onload=
"setTimeout(nextTest,0);"
9 title=
"bug 298622 test">
11 <script type=
"text/javascript"
12 src=
"chrome://mochikit/content/tests/SimpleTest/specialpowersAPI.js"/>
13 <script type=
"text/javascript"
14 src=
"chrome://mochikit/content/tests/SimpleTest/SpecialPowersObserverAPI.js"/>
15 <script type=
"text/javascript"
16 src=
"chrome://mochikit/content/tests/SimpleTest/ChromePowers.js"/>
17 <script type=
"application/javascript" src=
"chrome://mochikit/content/chrome-harness.js" />
18 <script type=
"application/javascript" src=
"docshell_helpers.js" />
19 <script type=
"application/javascript"><![CDATA[
20 // Global variable that holds a reference to the find bar.
23 // Define the generator-iterator for the tests.
24 var tests = testIterator();
27 // Execute the next test in the generator function.
34 // Generator function for test steps for bug
298622:
35 // Find should work correctly on a page loaded from the
38 function testIterator()
40 // Make sure bfcache is on.
43 // Load a test page which contains some text to be found.
45 uri:
"data:text/html,<html><head><title>test1</title></head>" +
46 "<body>find this!</body></html>",
47 onNavComplete: nextTest
51 // Load a second, dummy page, verifying that the original
52 // page gets stored in the bfcache.
54 uri: getHttpUrl(
"generic.html"),
55 eventsToListenFor: [
"pageshow",
"pagehide"],
56 expectedEvents: [ { type:
"pagehide",
60 title:
"generic page" } ],
61 onNavComplete: nextTest
65 // Make sure we unsuppress painting before continuing
66 SimpleTest.executeSoon(nextTest);
69 // Search for some text that's on the second page (but not on
70 // the first page), and verify that it can be found.
71 gFindBar = document.getElementById(
"FindToolbar");
72 document.getElementById(
"cmd_find").doCommand();
73 ok(!gFindBar.hidden,
"failed to open findbar");
74 gFindBar._findField.value =
"A generic page";
76 SimpleTest.executeSoon(nextTest);
79 // Make sure Find bar's internal status is not 'notfound'
80 isnot(gFindBar._findField.getAttribute(
"status"),
"notfound",
81 "Findfield status attribute should not have been 'notfound'" +
84 // Make sure the key events above have time to be processed
86 waitForTrue(function() {
88 TestWindow.getWindow().getSelection().toString().toLowerCase() ==
93 is(gFindBar._findField.inputField.value,
"A generic page",
94 "expected text not present in find input field");
95 is(TestWindow.getWindow().getSelection().toString().toLowerCase(),
97 "find failed on second page loaded");
99 // Go back to the original page and verify it's loaded from the
103 eventsToListenFor: [
"pageshow"],
104 expectedEvents: [ { type:
"pageshow",
107 onNavComplete: nextTest
111 // Search for some text that's on the original page (but not
112 // the dummy page loaded above), and verify that it can
114 gFindBar = document.getElementById(
"FindToolbar");
115 document.getElementById(
"cmd_find").doCommand();
116 ok(!gFindBar.hidden,
"failed to open findbar");
117 gFindBar._findField.value =
"find this";
119 SimpleTest.executeSoon(nextTest);
122 // Make sure Find bar's internal status is not 'notfound'
123 isnot(gFindBar._findField.getAttribute(
"status"),
"notfound",
124 "Findfield status attribute should not have been 'notfound'" +
127 // Make sure the key events above have time to be processed
129 waitForTrue(function() {
131 TestWindow.getWindow().getSelection().toString().toLowerCase() ==
136 is(TestWindow.getWindow().getSelection().toString().toLowerCase(),
138 "find failed on page loaded from bfcache");
140 // Tell the framework the test is finished. Include the final 'yield'
141 // statement to prevent a StopIteration exception from being thrown.
149 <command id=
"cmd_find"
150 oncommand=
"document.getElementById('FindToolbar').onFindCommand();"/>
152 <browser type=
"content-primary" flex=
"1" id=
"content" src=
"about:blank"/>
153 <findbar id=
"FindToolbar" browserid=
"content"/>