toolkit/content/tests/chrome/bug331215_window.xul

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 <?xml version="1.0"?>
     3 <!-- This Source Code Form is subject to the terms of the Mozilla Public
     4    - License, v. 2.0. If a copy of the MPL was not distributed with this
     5    - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
     7 <?xml-stylesheet href="chrome://global/skin" type="text/css"?>
     9 <window id="331215test"
    10         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
    11         width="600"
    12         height="600"
    13         onload="SimpleTest.executeSoon(startTest);"
    14         title="331215 test">
    16   <script type="application/javascript"><![CDATA[
    17     const Ci = Components.interfaces;
    18     const Cc = Components.classes;
    19     const Cr = Components.results;
    21     var gFindBar = null;
    22     var gBrowser;
    24     var imports = ["SimpleTest", "ok"];
    25     for each (var name in imports) {
    26       window[name] = window.opener.wrappedJSObject[name];
    27     }
    29     function finish() {
    30       window.close();
    31       SimpleTest.finish();
    32     }
    34     function startTest() {
    35       gFindBar = document.getElementById("FindToolbar");
    36       gBrowser = document.getElementById("content");
    37       gBrowser.addEventListener("pageshow", onPageShow, false);
    38       gBrowser.loadURI("data:text/plain,latest");
    39     }
    41     function onPageShow() {
    42       document.getElementById("cmd_find").doCommand();
    43       enterStringIntoFindField("test");
    44       document.commandDispatcher
    45               .getControllerForCommand("cmd_moveTop")
    46               .doCommand("cmd_moveTop");
    47       enterStringIntoFindField("l");
    48       ok(gFindBar._findField.getAttribute("status") == "notfound",
    49          "Findfield status attribute should have been 'notfound'" +
    50          " after entering ltest");              
    51       enterStringIntoFindField("a");
    52       ok(gFindBar._findField.getAttribute("status") != "notfound",
    53          "Findfield status attribute should not have been 'notfound'" +
    54          " after entering latest");
    55       finish();
    56     }
    58     function enterStringIntoFindField(aString) {
    59       for (var i=0; i < aString.length; i++) {
    60         var event = document.createEvent("KeyEvents");
    61         event.initKeyEvent("keypress", true, true, null, false, false,
    62                            false, false, 0, aString.charCodeAt(i));
    63         gFindBar._findField.inputField.dispatchEvent(event);
    64       }
    65     }
    66   ]]></script>
    68   <commandset>
    69     <command id="cmd_find" oncommand="document.getElementById('FindToolbar').onFindCommand();"/>
    70   </commandset>
    71   <browser type="content-primary" flex="1" id="content" src="about:blank"/>
    72   <findbar id="FindToolbar" browserid="content"/>
    73 </window>

mercurial