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(runTest, 0);"
9 title=
"bug 298622 test">
11 <script type=
"application/javascript" src=
"chrome://mochikit/content/chrome-harness.js" />
12 <script type=
"application/javascript" src=
"docshell_helpers.js" />
13 <script type=
"application/javascript"><![CDATA[
14 // Global variable that holds a reference to the find bar.
18 // Test for bug
298622:
19 // Find should work correctly on a page loaded from the
22 async function runTest()
24 // Make sure bfcache is on.
27 // Load a test page which contains some text to be found.
28 await promisePageNavigation({
29 uri:
"data:text/html,<html><head><title>test1</title></head>" +
30 "<body>find this!</body></html>",
33 // Load a second, dummy page, verifying that the original
34 // page gets stored in the bfcache.
35 await promisePageNavigation({
36 uri: getHttpUrl(
"generic.html"),
37 eventsToListenFor: [
"pageshow",
"pagehide"],
38 expectedEvents: [ { type:
"pagehide",
42 title:
"generic page" } ],
45 // Make sure we unsuppress painting before continuing
46 await new Promise(resolve =
> {
47 SimpleTest.executeSoon(resolve);
50 // Search for some text that's on the second page (but not on
51 // the first page), and verify that it can be found.
52 gFindBar = document.getElementById(
"FindToolbar");
53 document.getElementById(
"cmd_find").doCommand();
54 ok(!gFindBar.hidden,
"failed to open findbar");
55 gFindBar._findField.value =
"A generic page";
57 await new Promise(resolve =
> {
58 SimpleTest.executeSoon(resolve);
61 // Make sure Find bar's internal status is not 'notfound'
62 isnot(gFindBar._findField.getAttribute(
"status"),
"notfound",
63 "Findfield status attribute should not have been 'notfound'" +
66 // Make sure the key events above have time to be processed
68 await promiseTrue(() =
>
69 SpecialPowers.spawn(document.getElementById(
"content"), [], function() {
70 return content.document.getSelection().toString().toLowerCase() ==
"a generic page";
74 is(gFindBar._findField.value,
"A generic page",
75 "expected text not present in find input field");
76 is(await SpecialPowers.spawn(document.getElementById(
"content"), [], async function() {
77 return content.document.getSelection().toString().toLowerCase();
80 "find failed on second page loaded");
82 // Go back to the original page and verify it's loaded from the
84 await promisePageNavigation({
86 eventsToListenFor: [
"pageshow"],
87 expectedEvents: [ { type:
"pageshow",
92 // Search for some text that's on the original page (but not
93 // the dummy page loaded above), and verify that it can
95 gFindBar = document.getElementById(
"FindToolbar");
96 document.getElementById(
"cmd_find").doCommand();
97 ok(!gFindBar.hidden,
"failed to open findbar");
98 gFindBar._findField.value =
"find this";
100 await new Promise(resolve =
> {
101 SimpleTest.executeSoon(resolve);
104 // Make sure Find bar's internal status is not 'notfound'
105 isnot(gFindBar._findField.getAttribute(
"status"),
"notfound",
106 "Findfield status attribute should not have been 'notfound'" +
109 // Make sure the key events above have time to be processed
111 await promiseTrue(() =
>
112 SpecialPowers.spawn(document.getElementById(
"content"), [], function() {
113 return content.document.getSelection().toString().toLowerCase() ==
"find this";
117 is(await SpecialPowers.spawn(document.getElementById(
"content"), [], async function() {
118 return content.document.getSelection().toString().toLowerCase();
121 "find failed on page loaded from bfcache");
123 // Tell the framework the test is finished.
130 <command id=
"cmd_find"
131 oncommand=
"document.getElementById('FindToolbar').onFindCommand();"/>
133 <browser type=
"content" primary=
"true" flex=
"1" id=
"content" messagemanagergroup=
"test" remote=
"true" maychangeremoteness=
"true" />
134 <findbar id=
"FindToolbar" browserid=
"content"/>