1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/docshell/test/chrome/bug298622_window.xul Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,154 @@ 1.4 +<?xml version="1.0"?> 1.5 +<?xml-stylesheet href="chrome://global/skin" type="text/css"?> 1.6 + 1.7 +<window id="298622Test" 1.8 + xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" 1.9 + width="600" 1.10 + height="600" 1.11 + onload="setTimeout(nextTest,0);" 1.12 + title="bug 298622 test"> 1.13 + 1.14 + <script type="text/javascript" 1.15 + src="chrome://mochikit/content/tests/SimpleTest/specialpowersAPI.js"/> 1.16 + <script type="text/javascript" 1.17 + src="chrome://mochikit/content/tests/SimpleTest/SpecialPowersObserverAPI.js"/> 1.18 + <script type="text/javascript" 1.19 + src="chrome://mochikit/content/tests/SimpleTest/ChromePowers.js"/> 1.20 + <script type="application/javascript" src= "chrome://mochikit/content/chrome-harness.js" /> 1.21 + <script type="application/javascript" src= "docshell_helpers.js" /> 1.22 + <script type="application/javascript"><![CDATA[ 1.23 + // Global variable that holds a reference to the find bar. 1.24 + var gFindBar; 1.25 + 1.26 + // Define the generator-iterator for the tests. 1.27 + var tests = testIterator(); 1.28 + 1.29 + //// 1.30 + // Execute the next test in the generator function. 1.31 + // 1.32 + function nextTest() { 1.33 + tests.next(); 1.34 + } 1.35 + 1.36 + //// 1.37 + // Generator function for test steps for bug 298622: 1.38 + // Find should work correctly on a page loaded from the 1.39 + // bfcache. 1.40 + // 1.41 + function testIterator() 1.42 + { 1.43 + // Make sure bfcache is on. 1.44 + enableBFCache(true); 1.45 + 1.46 + // Load a test page which contains some text to be found. 1.47 + doPageNavigation({ 1.48 + uri: "data:text/html,<html><head><title>test1</title></head>" + 1.49 + "<body>find this!</body></html>", 1.50 + onNavComplete: nextTest 1.51 + }); 1.52 + yield undefined; 1.53 + 1.54 + // Load a second, dummy page, verifying that the original 1.55 + // page gets stored in the bfcache. 1.56 + doPageNavigation({ 1.57 + uri: getHttpUrl("generic.html"), 1.58 + eventsToListenFor: ["pageshow", "pagehide"], 1.59 + expectedEvents: [ { type: "pagehide", 1.60 + title: "test1", 1.61 + persisted: true }, 1.62 + { type: "pageshow", 1.63 + title: "generic page" } ], 1.64 + onNavComplete: nextTest 1.65 + }); 1.66 + yield undefined; 1.67 + 1.68 + // Make sure we unsuppress painting before continuing 1.69 + SimpleTest.executeSoon(nextTest); 1.70 + yield undefined; 1.71 + 1.72 + // Search for some text that's on the second page (but not on 1.73 + // the first page), and verify that it can be found. 1.74 + gFindBar = document.getElementById("FindToolbar"); 1.75 + document.getElementById("cmd_find").doCommand(); 1.76 + ok(!gFindBar.hidden, "failed to open findbar"); 1.77 + gFindBar._findField.value = "A generic page"; 1.78 + gFindBar._find(); 1.79 + SimpleTest.executeSoon(nextTest); 1.80 + yield undefined; 1.81 + 1.82 + // Make sure Find bar's internal status is not 'notfound' 1.83 + isnot(gFindBar._findField.getAttribute("status"), "notfound", 1.84 + "Findfield status attribute should not have been 'notfound'" + 1.85 + " after Find"); 1.86 + 1.87 + // Make sure the key events above have time to be processed 1.88 + // before continuing 1.89 + waitForTrue(function() { 1.90 + return ( 1.91 + TestWindow.getWindow().getSelection().toString().toLowerCase() == 1.92 + "a generic page"); 1.93 + }, nextTest, 20); 1.94 + yield undefined; 1.95 + 1.96 + is(gFindBar._findField.inputField.value, "A generic page", 1.97 + "expected text not present in find input field"); 1.98 + is(TestWindow.getWindow().getSelection().toString().toLowerCase(), 1.99 + "a generic page", 1.100 + "find failed on second page loaded"); 1.101 + 1.102 + // Go back to the original page and verify it's loaded from the 1.103 + // bfcache. 1.104 + doPageNavigation({ 1.105 + back: true, 1.106 + eventsToListenFor: ["pageshow"], 1.107 + expectedEvents: [ { type: "pageshow", 1.108 + title: "test1", 1.109 + persisted: true } ], 1.110 + onNavComplete: nextTest 1.111 + }); 1.112 + yield undefined; 1.113 + 1.114 + // Search for some text that's on the original page (but not 1.115 + // the dummy page loaded above), and verify that it can 1.116 + // be found. 1.117 + gFindBar = document.getElementById("FindToolbar"); 1.118 + document.getElementById("cmd_find").doCommand(); 1.119 + ok(!gFindBar.hidden, "failed to open findbar"); 1.120 + gFindBar._findField.value = "find this"; 1.121 + gFindBar._find(); 1.122 + SimpleTest.executeSoon(nextTest); 1.123 + yield undefined; 1.124 + 1.125 + // Make sure Find bar's internal status is not 'notfound' 1.126 + isnot(gFindBar._findField.getAttribute("status"), "notfound", 1.127 + "Findfield status attribute should not have been 'notfound'" + 1.128 + " after Find"); 1.129 + 1.130 + // Make sure the key events above have time to be processed 1.131 + // before continuing 1.132 + waitForTrue(function() { 1.133 + return ( 1.134 + TestWindow.getWindow().getSelection().toString().toLowerCase() == 1.135 + "find this"); 1.136 + }, nextTest, 20); 1.137 + yield undefined; 1.138 + 1.139 + is(TestWindow.getWindow().getSelection().toString().toLowerCase(), 1.140 + "find this", 1.141 + "find failed on page loaded from bfcache"); 1.142 + 1.143 + // Tell the framework the test is finished. Include the final 'yield' 1.144 + // statement to prevent a StopIteration exception from being thrown. 1.145 + finish(); 1.146 + yield undefined; 1.147 + } 1.148 + 1.149 + ]]></script> 1.150 + 1.151 + <commandset> 1.152 + <command id="cmd_find" 1.153 + oncommand="document.getElementById('FindToolbar').onFindCommand();"/> 1.154 + </commandset> 1.155 + <browser type="content-primary" flex="1" id="content" src="about:blank"/> 1.156 + <findbar id="FindToolbar" browserid="content"/> 1.157 +</window>