1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/toolkit/content/tests/chrome/bug360437_window.xul Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,86 @@ 1.4 +<?xml version="1.0"?> 1.5 + 1.6 +<!-- This Source Code Form is subject to the terms of the Mozilla Public 1.7 + - License, v. 2.0. If a copy of the MPL was not distributed with this 1.8 + - file, You can obtain one at http://mozilla.org/MPL/2.0/. --> 1.9 + 1.10 +<?xml-stylesheet href="chrome://global/skin" type="text/css"?> 1.11 + 1.12 +<window id="360437Test" 1.13 + xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" 1.14 + width="600" 1.15 + height="600" 1.16 + onload="onLoad();" 1.17 + title="360437 test"> 1.18 + 1.19 + <script type="application/javascript"><![CDATA[ 1.20 + const Ci = Components.interfaces; 1.21 + const Cc = Components.classes; 1.22 + const Cr = Components.results; 1.23 + 1.24 + var gFindBar = null; 1.25 + var gBrowser; 1.26 + 1.27 + function ok(condition, message) { 1.28 + window.opener.wrappedJSObject.SimpleTest.ok(condition, message); 1.29 + } 1.30 + function finish() { 1.31 + window.close(); 1.32 + window.opener.wrappedJSObject.SimpleTest.finish(); 1.33 + } 1.34 + 1.35 + function onLoad() { 1.36 + var _delayedOnLoad = function() { 1.37 + gFindBar = document.getElementById("FindToolbar"); 1.38 + gBrowser = document.getElementById("content"); 1.39 + gBrowser.addEventListener("pageshow", onPageShow, false); 1.40 + gBrowser.loadURI("data:text/html,<form><input id='input' type='text' value='text inside an input element'></form>"); 1.41 + } 1.42 + setTimeout(_delayedOnLoad, 1000); 1.43 + } 1.44 + 1.45 + function onPageShow() { 1.46 + testNormalFind(); 1.47 + } 1.48 + 1.49 + function enterStringIntoFindField(aString) { 1.50 + for (var i=0; i < aString.length; i++) { 1.51 + var event = document.createEvent("KeyEvents"); 1.52 + event.initKeyEvent("keypress", true, true, null, false, false, 1.53 + false, false, 0, aString.charCodeAt(i)); 1.54 + gFindBar._findField.inputField.dispatchEvent(event); 1.55 + } 1.56 + } 1.57 + 1.58 + function testNormalFind() { 1.59 + gFindBar.onFindCommand(); 1.60 + 1.61 + // Make sure the findfield is correctly focused on open 1.62 + var searchStr = "text inside an input element"; 1.63 + enterStringIntoFindField(searchStr); 1.64 + ok(document.commandDispatcher.focusedElement == 1.65 + gFindBar._findField.inputField, "Find field isn't focused"); 1.66 + 1.67 + // Make sure "find again" correctly transfers focus to the content element 1.68 + // when the find bar is closed. 1.69 + gFindBar.close(); 1.70 + gFindBar.onFindAgainCommand(false); 1.71 + ok(document.commandDispatcher.focusedElement == 1.72 + gBrowser.contentDocument.getElementById("input"), 1.73 + "Input Element isn't focused"); 1.74 + 1.75 + // Make sure "find again" doesn't focus the content element if focus 1.76 + // isn't in the content document. 1.77 + var textbox = document.getElementById("textbox"); 1.78 + textbox.focus(); 1.79 + gFindBar.close(); 1.80 + gFindBar.onFindAgainCommand(false); 1.81 + ok(textbox.hasAttribute("focused"), 1.82 + "Focus was stolen from a chrome element"); 1.83 + finish(); 1.84 + } 1.85 + ]]></script> 1.86 + <textbox id="textbox"/> 1.87 + <browser type="content-primary" flex="1" id="content" src="about:blank"/> 1.88 + <findbar id="FindToolbar" browserid="content"/> 1.89 +</window>