зеркало из https://github.com/mozilla/gecko-dev.git
Backed out changeset f6c028e4f604 (bug 1253233) for test failures in test_bug263683.xul
This commit is contained in:
Родитель
208d8ce23d
Коммит
48831d9b1f
|
@ -5,9 +5,6 @@
|
|||
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
|
||||
|
||||
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
|
||||
<?xml-stylesheet
|
||||
href="chrome://mochikit/content/tests/SimpleTest/test.css"
|
||||
type="text/css"?>
|
||||
|
||||
<window id="263683test"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
|
@ -17,63 +14,31 @@
|
|||
title="263683 test">
|
||||
|
||||
<script type="application/javascript"><![CDATA[
|
||||
const {interfaces: Ci, classes: Cc, results: Cr, utils: Cu} = Components;
|
||||
Cu.import("resource://gre/modules/Task.jsm");
|
||||
Cu.import("resource://testing-common/ContentTask.jsm");
|
||||
ContentTask.setTestScope(window.opener.wrappedJSObject);
|
||||
const Ci = Components.interfaces;
|
||||
const Cc = Components.classes;
|
||||
const Cr = Components.results;
|
||||
|
||||
var gFindBar = null;
|
||||
var gBrowser;
|
||||
|
||||
var imports = ["SimpleTest", "ok", "info"];
|
||||
var imports = ["SimpleTest", "ok"];
|
||||
for (var name of imports) {
|
||||
window[name] = window.opener.wrappedJSObject[name];
|
||||
}
|
||||
|
||||
function finish() {
|
||||
window.close();
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
function startTest() {
|
||||
Task.spawn(function* () {
|
||||
gFindBar = document.getElementById("FindToolbar");
|
||||
for (let browserId of ["content", "content-remote"]) {
|
||||
yield startTestWithBrowser(browserId);
|
||||
}
|
||||
}).then(() => {
|
||||
window.close();
|
||||
SimpleTest.finish();
|
||||
});
|
||||
}
|
||||
|
||||
function* startTestWithBrowser(browserId) {
|
||||
info("Starting test with browser '" + browserId + "'");
|
||||
gBrowser = document.getElementById(browserId);
|
||||
gFindBar.browser = gBrowser;
|
||||
let promise = ContentTask.spawn(gBrowser, null, function* () {
|
||||
return new Promise(resolve => {
|
||||
addEventListener("DOMContentLoaded", function listener() {
|
||||
removeEventListener("DOMContentLoaded", listener);
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
});
|
||||
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" />');
|
||||
yield promise;
|
||||
yield onDocumentLoaded();
|
||||
}
|
||||
|
||||
function toggleHighlightAndWait(highlight) {
|
||||
return new Promise(resolve => {
|
||||
let listener = {
|
||||
onHighlightFinished: function() {
|
||||
dump("HIGHLIGHT FINISHED!\n");
|
||||
gFindBar.browser.finder.removeResultListener(listener);
|
||||
resolve();
|
||||
}
|
||||
};
|
||||
gFindBar.browser.finder.addResultListener(listener);
|
||||
gFindBar.toggleHighlight(highlight);
|
||||
});
|
||||
}
|
||||
|
||||
function* onDocumentLoaded() {
|
||||
function onPageShow() {
|
||||
gFindBar.open();
|
||||
var search = "mozilla";
|
||||
gFindBar._findField.value = search;
|
||||
|
@ -82,60 +47,37 @@
|
|||
matchCase.doCommand();
|
||||
|
||||
gFindBar._find();
|
||||
yield toggleHighlightAndWait(true);
|
||||
var highlightButton = gFindBar.getElement("highlight");
|
||||
if (!highlightButton.checked)
|
||||
highlightButton.click();
|
||||
|
||||
yield ContentTask.spawn(gBrowser, { search }, function* (args) {
|
||||
let controller = docShell.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||
.getInterface(Ci.nsISelectionDisplay)
|
||||
.QueryInterface(Ci.nsISelectionController);
|
||||
Assert.ok("SELECTION_FIND" in controller, "Correctly detects new selection type");
|
||||
let selection = controller.getSelection(controller.SELECTION_FIND);
|
||||
|
||||
Assert.equal(selection.rangeCount, 1,
|
||||
"Correctly added a match to the selection type");
|
||||
Assert.equal(selection.getRangeAt(0).toString().toLowerCase(),
|
||||
args.search, "Added the correct match");
|
||||
});
|
||||
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");
|
||||
|
||||
yield toggleHighlightAndWait(false);
|
||||
|
||||
yield ContentTask.spawn(gBrowser, { search }, function* (args) {
|
||||
let controller = docShell.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||
.getInterface(Ci.nsISelectionDisplay)
|
||||
.QueryInterface(Ci.nsISelectionController);
|
||||
let selection = controller.getSelection(controller.SELECTION_FIND);
|
||||
Assert.equal(selection.rangeCount, 0, "Correctly removed the range");
|
||||
|
||||
let input = content.document.getElementById("inp");
|
||||
input.value = args.search;
|
||||
});
|
||||
var input = gBrowser.contentDocument.getElementById("inp");
|
||||
input.value = search;
|
||||
|
||||
yield toggleHighlightAndWait(true);
|
||||
highlightButton.click();
|
||||
|
||||
yield ContentTask.spawn(gBrowser, { search }, function* (args) {
|
||||
let input = content.document.getElementById("inp");
|
||||
let inputController = input.editor.selectionController;
|
||||
let inputSelection = inputController.getSelection(inputController.SELECTION_FIND);
|
||||
var inputController = input.editor.selectionController;
|
||||
var inputSelection = inputController.getSelection(inputController.SELECTION_FIND);
|
||||
|
||||
Assert.equal(inputSelection.rangeCount, 1,
|
||||
"Correctly added a match from input to the selection type");
|
||||
Assert.equal(inputSelection.getRangeAt(0).toString().toLowerCase(),
|
||||
args.search, "Added the correct match");
|
||||
});
|
||||
|
||||
yield toggleHighlightAndWait(false);
|
||||
|
||||
yield ContentTask.spawn(gBrowser, null, function* () {
|
||||
let input = content.document.getElementById("inp");
|
||||
let inputController = input.editor.selectionController;
|
||||
let inputSelection = inputController.getSelection(inputController.SELECTION_FIND);
|
||||
|
||||
Assert.equal(inputSelection.rangeCount, 0, "Correctly removed the range");
|
||||
});
|
||||
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"/>
|
||||
<browser type="content-primary" flex="1" id="content-remote" remote="true" src="about:blank"/>
|
||||
<findbar id="FindToolbar" browserid="content"/>
|
||||
</window>
|
||||
|
|
|
@ -29,7 +29,6 @@ RemoteFinder.prototype = {
|
|||
this._messageManager.removeMessageListener("Finder:Result", this);
|
||||
this._messageManager.removeMessageListener("Finder:MatchesResult", this);
|
||||
this._messageManager.removeMessageListener("Finder:CurrentSelectionResult",this);
|
||||
this._messageManager.removeMessageListener("Finder:HighlightFinished",this);
|
||||
}
|
||||
else {
|
||||
aBrowser.messageManager.sendAsyncMessage("Finder:Initialize");
|
||||
|
@ -40,7 +39,6 @@ RemoteFinder.prototype = {
|
|||
this._messageManager.addMessageListener("Finder:Result", this);
|
||||
this._messageManager.addMessageListener("Finder:MatchesResult", this);
|
||||
this._messageManager.addMessageListener("Finder:CurrentSelectionResult", this);
|
||||
this._messageManager.addMessageListener("Finder:HighlightFinished", this);
|
||||
|
||||
// Ideally listeners would have removed themselves but that doesn't happen
|
||||
// right now
|
||||
|
@ -73,10 +71,6 @@ RemoteFinder.prototype = {
|
|||
callback = "onCurrentSelection";
|
||||
params = [ aMessage.data.selection, aMessage.data.initial ];
|
||||
break;
|
||||
case "Finder:HighlightFinished":
|
||||
callback = "onHighlightFinished";
|
||||
params = [ aMessage.data ];
|
||||
break;
|
||||
}
|
||||
|
||||
for (let l of this._listeners) {
|
||||
|
@ -208,10 +202,6 @@ RemoteFinderListener.prototype = {
|
|||
this._global.sendAsyncMessage("Finder:MatchesResult", aData);
|
||||
},
|
||||
|
||||
onHighlightFinished: function(aData) {
|
||||
this._global.sendAsyncMessage("Finder:HighlightFinished", aData);
|
||||
},
|
||||
|
||||
receiveMessage: function (aMessage) {
|
||||
let data = aMessage.data;
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче