browser_bug567306.js (1859B)
1 /* Any copyright is dedicated to the Public Domain. 2 * http://creativecommons.org/publicdomain/zero/1.0/ 3 */ 4 5 var HasFindClipboard = Services.clipboard.isClipboardTypeSupported( 6 Services.clipboard.kFindClipboard 7 ); 8 9 add_task(async function () { 10 let newwindow = await BrowserTestUtils.openNewBrowserWindow(); 11 12 let selectedBrowser = newwindow.gBrowser.selectedBrowser; 13 await new Promise(resolve => { 14 BrowserTestUtils.waitForContentEvent( 15 selectedBrowser, 16 "pageshow", 17 true, 18 event => { 19 return event.target.location != "about:blank"; 20 } 21 ).then(function pageshowListener() { 22 ok( 23 true, 24 "pageshow listener called: " + newwindow.gBrowser.currentURI.spec 25 ); 26 resolve(); 27 }); 28 selectedBrowser.loadURI( 29 Services.io.newURI("data:text/html,<h1 id='h1'>Select Me</h1>"), 30 { 31 triggeringPrincipal: 32 Services.scriptSecurityManager.getSystemPrincipal(), 33 } 34 ); 35 }); 36 37 await SimpleTest.promiseFocus(newwindow); 38 39 ok(!newwindow.gFindBarInitialized, "find bar is not yet initialized"); 40 let findBar = await newwindow.gFindBarPromise; 41 42 await SpecialPowers.spawn(selectedBrowser, [], async function () { 43 let elt = content.document.getElementById("h1"); 44 let selection = content.getSelection(); 45 let range = content.document.createRange(); 46 range.setStart(elt, 0); 47 range.setEnd(elt, 1); 48 selection.removeAllRanges(); 49 selection.addRange(range); 50 }); 51 52 await findBar.onFindCommand(); 53 54 // When the OS supports the Find Clipboard (OSX), the find field value is 55 // persisted across Fx sessions, thus not useful to test. 56 if (!HasFindClipboard) { 57 is( 58 findBar._findField.value, 59 "Select Me", 60 "Findbar is initialized with selection" 61 ); 62 } 63 findBar.close(); 64 await promiseWindowClosed(newwindow); 65 });