Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | <?xml version="1.0"?> |
michael@0 | 2 | |
michael@0 | 3 | <!-- This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 4 | - License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 5 | - file, You can obtain one at http://mozilla.org/MPL/2.0/. --> |
michael@0 | 6 | |
michael@0 | 7 | <?xml-stylesheet href="chrome://global/skin" type="text/css"?> |
michael@0 | 8 | |
michael@0 | 9 | <window id="360437Test" |
michael@0 | 10 | xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" |
michael@0 | 11 | width="600" |
michael@0 | 12 | height="600" |
michael@0 | 13 | onload="onLoad();" |
michael@0 | 14 | title="360437 test"> |
michael@0 | 15 | |
michael@0 | 16 | <script type="application/javascript"><![CDATA[ |
michael@0 | 17 | const Ci = Components.interfaces; |
michael@0 | 18 | const Cc = Components.classes; |
michael@0 | 19 | const Cr = Components.results; |
michael@0 | 20 | |
michael@0 | 21 | var gFindBar = null; |
michael@0 | 22 | var gBrowser; |
michael@0 | 23 | |
michael@0 | 24 | function ok(condition, message) { |
michael@0 | 25 | window.opener.wrappedJSObject.SimpleTest.ok(condition, message); |
michael@0 | 26 | } |
michael@0 | 27 | function finish() { |
michael@0 | 28 | window.close(); |
michael@0 | 29 | window.opener.wrappedJSObject.SimpleTest.finish(); |
michael@0 | 30 | } |
michael@0 | 31 | |
michael@0 | 32 | function onLoad() { |
michael@0 | 33 | var _delayedOnLoad = function() { |
michael@0 | 34 | gFindBar = document.getElementById("FindToolbar"); |
michael@0 | 35 | gBrowser = document.getElementById("content"); |
michael@0 | 36 | gBrowser.addEventListener("pageshow", onPageShow, false); |
michael@0 | 37 | gBrowser.loadURI("data:text/html,<form><input id='input' type='text' value='text inside an input element'></form>"); |
michael@0 | 38 | } |
michael@0 | 39 | setTimeout(_delayedOnLoad, 1000); |
michael@0 | 40 | } |
michael@0 | 41 | |
michael@0 | 42 | function onPageShow() { |
michael@0 | 43 | testNormalFind(); |
michael@0 | 44 | } |
michael@0 | 45 | |
michael@0 | 46 | function enterStringIntoFindField(aString) { |
michael@0 | 47 | for (var i=0; i < aString.length; i++) { |
michael@0 | 48 | var event = document.createEvent("KeyEvents"); |
michael@0 | 49 | event.initKeyEvent("keypress", true, true, null, false, false, |
michael@0 | 50 | false, false, 0, aString.charCodeAt(i)); |
michael@0 | 51 | gFindBar._findField.inputField.dispatchEvent(event); |
michael@0 | 52 | } |
michael@0 | 53 | } |
michael@0 | 54 | |
michael@0 | 55 | function testNormalFind() { |
michael@0 | 56 | gFindBar.onFindCommand(); |
michael@0 | 57 | |
michael@0 | 58 | // Make sure the findfield is correctly focused on open |
michael@0 | 59 | var searchStr = "text inside an input element"; |
michael@0 | 60 | enterStringIntoFindField(searchStr); |
michael@0 | 61 | ok(document.commandDispatcher.focusedElement == |
michael@0 | 62 | gFindBar._findField.inputField, "Find field isn't focused"); |
michael@0 | 63 | |
michael@0 | 64 | // Make sure "find again" correctly transfers focus to the content element |
michael@0 | 65 | // when the find bar is closed. |
michael@0 | 66 | gFindBar.close(); |
michael@0 | 67 | gFindBar.onFindAgainCommand(false); |
michael@0 | 68 | ok(document.commandDispatcher.focusedElement == |
michael@0 | 69 | gBrowser.contentDocument.getElementById("input"), |
michael@0 | 70 | "Input Element isn't focused"); |
michael@0 | 71 | |
michael@0 | 72 | // Make sure "find again" doesn't focus the content element if focus |
michael@0 | 73 | // isn't in the content document. |
michael@0 | 74 | var textbox = document.getElementById("textbox"); |
michael@0 | 75 | textbox.focus(); |
michael@0 | 76 | gFindBar.close(); |
michael@0 | 77 | gFindBar.onFindAgainCommand(false); |
michael@0 | 78 | ok(textbox.hasAttribute("focused"), |
michael@0 | 79 | "Focus was stolen from a chrome element"); |
michael@0 | 80 | finish(); |
michael@0 | 81 | } |
michael@0 | 82 | ]]></script> |
michael@0 | 83 | <textbox id="textbox"/> |
michael@0 | 84 | <browser type="content-primary" flex="1" id="content" src="about:blank"/> |
michael@0 | 85 | <findbar id="FindToolbar" browserid="content"/> |
michael@0 | 86 | </window> |