mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-08 12:37:37 +00:00
84 lines
3.0 KiB
XML
84 lines
3.0 KiB
XML
<?xml version="1.0"?>
|
|
|
|
<!-- This Source Code Form is subject to the terms of the Mozilla Public
|
|
- License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
|
|
|
|
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
|
|
|
|
<window id="263683test"
|
|
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
|
width="600"
|
|
height="600"
|
|
onload="SimpleTest.executeSoon(startTest);"
|
|
title="263683 test">
|
|
|
|
<script type="application/javascript"><![CDATA[
|
|
const Ci = Components.interfaces;
|
|
const Cc = Components.classes;
|
|
const Cr = Components.results;
|
|
|
|
var gFindBar = null;
|
|
var gBrowser;
|
|
|
|
var imports = ["SimpleTest", "ok"];
|
|
for each (var name in imports) {
|
|
window[name] = window.opener.wrappedJSObject[name];
|
|
}
|
|
|
|
function finish() {
|
|
window.close();
|
|
SimpleTest.finish();
|
|
}
|
|
|
|
function startTest() {
|
|
gFindBar = document.getElementById("FindToolbar");
|
|
gBrowser = document.getElementById("content");
|
|
gBrowser.addEventListener("pageshow", onPageShow, false);
|
|
gBrowser.loadURI('data:text/html,<h2>Text mozilla</h2><input id="inp" type="text" />');
|
|
}
|
|
|
|
function onPageShow() {
|
|
gFindBar.open();
|
|
var search = "mozilla";
|
|
gFindBar._findField.value = search;
|
|
var matchCase = gFindBar.getElement("find-case-sensitive");
|
|
if (matchCase.checked)
|
|
matchCase.doCommand();
|
|
|
|
gFindBar._find();
|
|
var highlightButton = gFindBar.getElement("highlight");
|
|
if (!highlightButton.checked)
|
|
highlightButton.click();
|
|
|
|
var controller = gFindBar.browser.docShell.QueryInterface(Ci.nsIInterfaceRequestor)
|
|
.getInterface(Ci.nsISelectionDisplay)
|
|
.QueryInterface(Ci.nsISelectionController);
|
|
ok('SELECTION_FIND' in controller, "Correctly detects new selection type");
|
|
var selection = controller.getSelection(controller.SELECTION_FIND);
|
|
|
|
ok(selection.rangeCount == 1, "Correctly added a match to the selection type");
|
|
ok(selection.getRangeAt(0).toString().toLowerCase() == search, "Added the correct match");
|
|
highlightButton.click();
|
|
ok(selection.rangeCount == 0, "Correctly removed the range");
|
|
|
|
var input = gBrowser.contentDocument.getElementById("inp");
|
|
input.value = search;
|
|
|
|
highlightButton.click();
|
|
|
|
var inputController = input.editor.selectionController;
|
|
var inputSelection = inputController.getSelection(inputController.SELECTION_FIND);
|
|
|
|
ok(inputSelection.rangeCount == 1, "Correctly added a match from input to the selection type");
|
|
ok(inputSelection.getRangeAt(0).toString().toLowerCase() == search, "Added the correct match");
|
|
highlightButton.click();
|
|
ok(inputSelection.rangeCount == 0, "Correctly removed the range");
|
|
finish();
|
|
}
|
|
]]></script>
|
|
|
|
<browser type="content-primary" flex="1" id="content" src="about:blank"/>
|
|
<findbar id="FindToolbar" browserid="content"/>
|
|
</window>
|