Bug 1839316: part 5) Guard the "fetchpriority" attribute behind a pref. r=kershaw...
[gecko.git] / docshell / test / chrome / bug298622_window.xhtml
blob38abf3510703988a3afe40a03fd8d9b9b93afb79
1 <?xml version="1.0"?>
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"
6 width="600"
7 height="600"
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.
15 var gFindBar;
17 ////
18 // Test for bug 298622:
19 // Find should work correctly on a page loaded from the
20 // bfcache.
22 async function runTest()
24 // Make sure bfcache is on.
25 enableBFCache(true);
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>",
31 });
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",
39 title: "test1",
40 persisted: true },
41 { type: "pageshow",
42 title: "generic page" } ],
43 });
45 // Make sure we unsuppress painting before continuing
46 await new Promise(resolve => {
47 SimpleTest.executeSoon(resolve);
48 });
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";
56 gFindBar._find();
57 await new Promise(resolve => {
58 SimpleTest.executeSoon(resolve);
59 });
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'" +
64 " after Find");
66 // Make sure the key events above have time to be processed
67 // before continuing
68 await promiseTrue(() =>
69 SpecialPowers.spawn(document.getElementById("content"), [], function() {
70 return content.document.getSelection().toString().toLowerCase() == "a generic page";
71 }), 20
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();
78 }),
79 "a generic page",
80 "find failed on second page loaded");
82 // Go back to the original page and verify it's loaded from the
83 // bfcache.
84 await promisePageNavigation({
85 back: true,
86 eventsToListenFor: ["pageshow"],
87 expectedEvents: [ { type: "pageshow",
88 title: "test1",
89 persisted: true } ],
90 });
92 // Search for some text that's on the original page (but not
93 // the dummy page loaded above), and verify that it can
94 // be found.
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";
99 gFindBar._find();
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'" +
107 " after Find");
109 // Make sure the key events above have time to be processed
110 // before continuing
111 await promiseTrue(() =>
112 SpecialPowers.spawn(document.getElementById("content"), [], function() {
113 return content.document.getSelection().toString().toLowerCase() == "find this";
114 }), 20
117 is(await SpecialPowers.spawn(document.getElementById("content"), [], async function() {
118 return content.document.getSelection().toString().toLowerCase();
120 "find this",
121 "find failed on page loaded from bfcache");
123 // Tell the framework the test is finished.
124 finish();
127 ]]></script>
129 <commandset>
130 <command id="cmd_find"
131 oncommand="document.getElementById('FindToolbar').onFindCommand();"/>
132 </commandset>
133 <browser type="content" primary="true" flex="1" id="content" messagemanagergroup="test" remote="true" maychangeremoteness="true" />
134 <findbar id="FindToolbar" browserid="content"/>
135 </window>