Backed out changeset f6c028e4f604 (bug 1253233) for test failures in test_bug263683.xul

This commit is contained in:
Carsten "Tomcat" Book 2016-03-23 09:09:40 +01:00
Родитель 208d8ce23d
Коммит 48831d9b1f
2 изменённых файлов: 36 добавлений и 104 удалений

Просмотреть файл

@ -5,9 +5,6 @@
- file, You can obtain one at http://mozilla.org/MPL/2.0/. --> - 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://global/skin" type="text/css"?>
<?xml-stylesheet
href="chrome://mochikit/content/tests/SimpleTest/test.css"
type="text/css"?>
<window id="263683test" <window id="263683test"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
@ -17,63 +14,31 @@
title="263683 test"> title="263683 test">
<script type="application/javascript"><![CDATA[ <script type="application/javascript"><![CDATA[
const {interfaces: Ci, classes: Cc, results: Cr, utils: Cu} = Components; const Ci = Components.interfaces;
Cu.import("resource://gre/modules/Task.jsm"); const Cc = Components.classes;
Cu.import("resource://testing-common/ContentTask.jsm"); const Cr = Components.results;
ContentTask.setTestScope(window.opener.wrappedJSObject);
var gFindBar = null; var gFindBar = null;
var gBrowser; var gBrowser;
var imports = ["SimpleTest", "ok", "info"]; var imports = ["SimpleTest", "ok"];
for (var name of imports) { for (var name of imports) {
window[name] = window.opener.wrappedJSObject[name]; window[name] = window.opener.wrappedJSObject[name];
} }
function finish() {
window.close();
SimpleTest.finish();
}
function startTest() { function startTest() {
Task.spawn(function* () { gFindBar = document.getElementById("FindToolbar");
gFindBar = document.getElementById("FindToolbar"); gBrowser = document.getElementById("content");
for (let browserId of ["content", "content-remote"]) { gBrowser.addEventListener("pageshow", onPageShow, false);
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();
});
});
});
gBrowser.loadURI('data:text/html,<h2>Text mozilla</h2><input id="inp" type="text" />'); gBrowser.loadURI('data:text/html,<h2>Text mozilla</h2><input id="inp" type="text" />');
yield promise;
yield onDocumentLoaded();
} }
function toggleHighlightAndWait(highlight) { function onPageShow() {
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() {
gFindBar.open(); gFindBar.open();
var search = "mozilla"; var search = "mozilla";
gFindBar._findField.value = search; gFindBar._findField.value = search;
@ -82,60 +47,37 @@
matchCase.doCommand(); matchCase.doCommand();
gFindBar._find(); gFindBar._find();
yield toggleHighlightAndWait(true); var highlightButton = gFindBar.getElement("highlight");
if (!highlightButton.checked)
highlightButton.click();
yield ContentTask.spawn(gBrowser, { search }, function* (args) { var controller = gFindBar.browser.docShell.QueryInterface(Ci.nsIInterfaceRequestor)
let controller = docShell.QueryInterface(Ci.nsIInterfaceRequestor) .getInterface(Ci.nsISelectionDisplay)
.getInterface(Ci.nsISelectionDisplay) .QueryInterface(Ci.nsISelectionController);
.QueryInterface(Ci.nsISelectionController); ok('SELECTION_FIND' in controller, "Correctly detects new selection type");
Assert.ok("SELECTION_FIND" in controller, "Correctly detects new selection type"); var selection = controller.getSelection(controller.SELECTION_FIND);
let selection = controller.getSelection(controller.SELECTION_FIND);
ok(selection.rangeCount == 1, "Correctly added a match to the selection type");
Assert.equal(selection.rangeCount, 1, ok(selection.getRangeAt(0).toString().toLowerCase() == search, "Added the correct match");
"Correctly added a match to the selection type"); highlightButton.click();
Assert.equal(selection.getRangeAt(0).toString().toLowerCase(), ok(selection.rangeCount == 0, "Correctly removed the range");
args.search, "Added the correct match");
});
yield toggleHighlightAndWait(false); var input = gBrowser.contentDocument.getElementById("inp");
input.value = search;
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;
});
yield toggleHighlightAndWait(true); highlightButton.click();
yield ContentTask.spawn(gBrowser, { search }, function* (args) { var inputController = input.editor.selectionController;
let input = content.document.getElementById("inp"); var inputSelection = inputController.getSelection(inputController.SELECTION_FIND);
let inputController = input.editor.selectionController;
let inputSelection = inputController.getSelection(inputController.SELECTION_FIND);
Assert.equal(inputSelection.rangeCount, 1, ok(inputSelection.rangeCount == 1, "Correctly added a match from input to the selection type");
"Correctly added a match from input to the selection type"); ok(inputSelection.getRangeAt(0).toString().toLowerCase() == search, "Added the correct match");
Assert.equal(inputSelection.getRangeAt(0).toString().toLowerCase(), highlightButton.click();
args.search, "Added the correct match"); ok(inputSelection.rangeCount == 0, "Correctly removed the range");
}); finish();
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");
});
} }
]]></script> ]]></script>
<browser type="content-primary" flex="1" id="content" src="about:blank"/> <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"/> <findbar id="FindToolbar" browserid="content"/>
</window> </window>

Просмотреть файл

@ -29,7 +29,6 @@ RemoteFinder.prototype = {
this._messageManager.removeMessageListener("Finder:Result", this); this._messageManager.removeMessageListener("Finder:Result", this);
this._messageManager.removeMessageListener("Finder:MatchesResult", this); this._messageManager.removeMessageListener("Finder:MatchesResult", this);
this._messageManager.removeMessageListener("Finder:CurrentSelectionResult",this); this._messageManager.removeMessageListener("Finder:CurrentSelectionResult",this);
this._messageManager.removeMessageListener("Finder:HighlightFinished",this);
} }
else { else {
aBrowser.messageManager.sendAsyncMessage("Finder:Initialize"); aBrowser.messageManager.sendAsyncMessage("Finder:Initialize");
@ -40,7 +39,6 @@ RemoteFinder.prototype = {
this._messageManager.addMessageListener("Finder:Result", this); this._messageManager.addMessageListener("Finder:Result", this);
this._messageManager.addMessageListener("Finder:MatchesResult", this); this._messageManager.addMessageListener("Finder:MatchesResult", this);
this._messageManager.addMessageListener("Finder:CurrentSelectionResult", this); this._messageManager.addMessageListener("Finder:CurrentSelectionResult", this);
this._messageManager.addMessageListener("Finder:HighlightFinished", this);
// Ideally listeners would have removed themselves but that doesn't happen // Ideally listeners would have removed themselves but that doesn't happen
// right now // right now
@ -73,10 +71,6 @@ RemoteFinder.prototype = {
callback = "onCurrentSelection"; callback = "onCurrentSelection";
params = [ aMessage.data.selection, aMessage.data.initial ]; params = [ aMessage.data.selection, aMessage.data.initial ];
break; break;
case "Finder:HighlightFinished":
callback = "onHighlightFinished";
params = [ aMessage.data ];
break;
} }
for (let l of this._listeners) { for (let l of this._listeners) {
@ -208,10 +202,6 @@ RemoteFinderListener.prototype = {
this._global.sendAsyncMessage("Finder:MatchesResult", aData); this._global.sendAsyncMessage("Finder:MatchesResult", aData);
}, },
onHighlightFinished: function(aData) {
this._global.sendAsyncMessage("Finder:HighlightFinished", aData);
},
receiveMessage: function (aMessage) { receiveMessage: function (aMessage) {
let data = aMessage.data; let data = aMessage.data;