toolkit/content/tests/chrome/bug263683_window.xul

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/toolkit/content/tests/chrome/bug263683_window.xul	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,83 @@
     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="263683test"
    1.13 +        xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
    1.14 +        width="600"
    1.15 +        height="600"
    1.16 +        onload="SimpleTest.executeSoon(startTest);"
    1.17 +        title="263683 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 +    var imports = ["SimpleTest", "ok"];
    1.28 +    for each (var name in imports) {
    1.29 +      window[name] = window.opener.wrappedJSObject[name];
    1.30 +    }
    1.31 +
    1.32 +    function finish() {
    1.33 +      window.close();
    1.34 +      SimpleTest.finish();
    1.35 +    }
    1.36 +
    1.37 +    function startTest() {
    1.38 +      gFindBar = document.getElementById("FindToolbar");
    1.39 +      gBrowser = document.getElementById("content");
    1.40 +      gBrowser.addEventListener("pageshow", onPageShow, false);
    1.41 +      gBrowser.loadURI('data:text/html,<h2>Text mozilla</h2><input id="inp" type="text" />');
    1.42 +    }
    1.43 +
    1.44 +    function onPageShow() {
    1.45 +      gFindBar.open();
    1.46 +      var search = "mozilla";
    1.47 +      gFindBar._findField.value = search;
    1.48 +      var matchCase = gFindBar.getElement("find-case-sensitive");
    1.49 +      if (matchCase.checked)
    1.50 +        matchCase.doCommand();
    1.51 +
    1.52 +      gFindBar._find();
    1.53 +      var highlightButton = gFindBar.getElement("highlight");
    1.54 +      if (!highlightButton.checked)
    1.55 +        highlightButton.click();
    1.56 +
    1.57 +      var controller = gFindBar.browser.docShell.QueryInterface(Ci.nsIInterfaceRequestor)
    1.58 +                                       .getInterface(Ci.nsISelectionDisplay)
    1.59 +                                       .QueryInterface(Ci.nsISelectionController);
    1.60 +      ok('SELECTION_FIND' in controller, "Correctly detects new selection type");
    1.61 +      var selection = controller.getSelection(controller.SELECTION_FIND);
    1.62 +      
    1.63 +      ok(selection.rangeCount == 1, "Correctly added a match to the selection type");
    1.64 +      ok(selection.getRangeAt(0).toString().toLowerCase() == search, "Added the correct match");
    1.65 +      highlightButton.click();
    1.66 +      ok(selection.rangeCount == 0, "Correctly removed the range");
    1.67 +
    1.68 +      var input = gBrowser.contentDocument.getElementById("inp");
    1.69 +      input.value = search;
    1.70 + 
    1.71 +      highlightButton.click();
    1.72 +
    1.73 +      var inputController = input.editor.selectionController;
    1.74 +      var inputSelection = inputController.getSelection(inputController.SELECTION_FIND);
    1.75 +
    1.76 +      ok(inputSelection.rangeCount == 1, "Correctly added a match from input to the selection type");
    1.77 +      ok(inputSelection.getRangeAt(0).toString().toLowerCase() == search, "Added the correct match");
    1.78 +      highlightButton.click();
    1.79 +      ok(inputSelection.rangeCount == 0, "Correctly removed the range");
    1.80 +      finish();
    1.81 +    }
    1.82 +  ]]></script>
    1.83 +
    1.84 +  <browser type="content-primary" flex="1" id="content" src="about:blank"/>
    1.85 +  <findbar id="FindToolbar" browserid="content"/>
    1.86 +</window>

mercurial