toolkit/content/tests/chrome/bug263683_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="263683test"
    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="263683 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/html,<h2>Text mozilla</h2><input id="inp" type="text" />');
    39     }
    41     function onPageShow() {
    42       gFindBar.open();
    43       var search = "mozilla";
    44       gFindBar._findField.value = search;
    45       var matchCase = gFindBar.getElement("find-case-sensitive");
    46       if (matchCase.checked)
    47         matchCase.doCommand();
    49       gFindBar._find();
    50       var highlightButton = gFindBar.getElement("highlight");
    51       if (!highlightButton.checked)
    52         highlightButton.click();
    54       var controller = gFindBar.browser.docShell.QueryInterface(Ci.nsIInterfaceRequestor)
    55                                        .getInterface(Ci.nsISelectionDisplay)
    56                                        .QueryInterface(Ci.nsISelectionController);
    57       ok('SELECTION_FIND' in controller, "Correctly detects new selection type");
    58       var selection = controller.getSelection(controller.SELECTION_FIND);
    60       ok(selection.rangeCount == 1, "Correctly added a match to the selection type");
    61       ok(selection.getRangeAt(0).toString().toLowerCase() == search, "Added the correct match");
    62       highlightButton.click();
    63       ok(selection.rangeCount == 0, "Correctly removed the range");
    65       var input = gBrowser.contentDocument.getElementById("inp");
    66       input.value = search;
    68       highlightButton.click();
    70       var inputController = input.editor.selectionController;
    71       var inputSelection = inputController.getSelection(inputController.SELECTION_FIND);
    73       ok(inputSelection.rangeCount == 1, "Correctly added a match from input to the selection type");
    74       ok(inputSelection.getRangeAt(0).toString().toLowerCase() == search, "Added the correct match");
    75       highlightButton.click();
    76       ok(inputSelection.rangeCount == 0, "Correctly removed the range");
    77       finish();
    78     }
    79   ]]></script>
    81   <browser type="content-primary" flex="1" id="content" src="about:blank"/>
    82   <findbar id="FindToolbar" browserid="content"/>
    83 </window>

mercurial