зеркало из https://github.com/mozilla/gecko-dev.git
Backed out changeset 7f987505ac94 (bug 1051187) for test failures
This commit is contained in:
Родитель
6568594f93
Коммит
0c25e87cfe
|
@ -21,7 +21,7 @@
|
|||
var gFindBar = null;
|
||||
var gBrowser;
|
||||
|
||||
var imports = ["SimpleTest", "ok", "is"];
|
||||
var imports = ["SimpleTest", "ok"];
|
||||
for each (var name in imports) {
|
||||
window[name] = window.opener.wrappedJSObject[name];
|
||||
}
|
||||
|
@ -71,28 +71,21 @@
|
|||
function checkSelection(done) {
|
||||
SimpleTest.executeSoon(function() {
|
||||
var selected = gBrowser.contentWindow.getSelection();
|
||||
is(selected, "", "No text is selected");
|
||||
ok(selected == "", "No text is selected");
|
||||
|
||||
var controller = gFindBar.browser.docShell.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||
.getInterface(Ci.nsISelectionDisplay)
|
||||
.QueryInterface(Ci.nsISelectionController);
|
||||
var selection = controller.getSelection(controller.SELECTION_FIND);
|
||||
is(selection.rangeCount, 0, "No text is highlighted");
|
||||
ok(selection.rangeCount == 0, "No text is highlighted");
|
||||
done();
|
||||
});
|
||||
}
|
||||
|
||||
function once(node, eventName, callback) {
|
||||
node.addEventListener(eventName, function clb(e) {
|
||||
node.removeEventListener(eventName, clb);
|
||||
callback(e);
|
||||
})
|
||||
}
|
||||
|
||||
function testFind(done) {
|
||||
var eventTriggered = false;
|
||||
var findTriggered = false;
|
||||
var query = "t";
|
||||
once(gFindBar, "find", function(e) {
|
||||
gFindBar.addEventListener("find", function(e) {
|
||||
eventTriggered = true;
|
||||
ok(e.detail.query === query, "find event query should match '" + query + "'");
|
||||
e.preventDefault();
|
||||
|
@ -110,7 +103,7 @@
|
|||
|
||||
function testFindAgain(done) {
|
||||
var eventTriggered = false;
|
||||
once(gFindBar, "findagain", function(e) {
|
||||
gFindBar.addEventListener("findagain", function(e) {
|
||||
eventTriggered = true;
|
||||
e.preventDefault();
|
||||
// Since we're preventing the default make sure nothing was selected.
|
||||
|
@ -123,7 +116,7 @@
|
|||
|
||||
function testCaseSensitivity() {
|
||||
var eventTriggered = false;
|
||||
once(gFindBar, "findcasesensitivitychange", function(e) {
|
||||
gFindBar.addEventListener("findcasesensitivitychange", function(e) {
|
||||
eventTriggered = true;
|
||||
ok(e.detail.caseSensitive, "find should be case sensitive");
|
||||
});
|
||||
|
@ -131,17 +124,13 @@
|
|||
var matchCaseCheckbox = gFindBar.getElement("find-case-sensitive");
|
||||
matchCaseCheckbox.click();
|
||||
ok(eventTriggered, "findcasesensitivitychange should be triggered");
|
||||
|
||||
// Changing case sensitivity does the search so clear the selected text
|
||||
// before the next test.
|
||||
gBrowser.contentWindow.getSelection().removeAllRanges();
|
||||
}
|
||||
|
||||
function testHighlight(done) {
|
||||
// Update the find state so the highlight button is clickable.
|
||||
gFindBar.updateControlState(Ci.nsITypeAheadFind.FIND_FOUND, false);
|
||||
var eventTriggered = false;
|
||||
once(gFindBar, "findhighlightallchange", function(e) {
|
||||
gFindBar.addEventListener("findhighlightallchange", function(e) {
|
||||
eventTriggered = true;
|
||||
ok(e.detail.highlightAll, "find event should have highlight all set");
|
||||
e.preventDefault();
|
||||
|
|
|
@ -22,9 +22,6 @@
|
|||
const Ci = Components.interfaces;
|
||||
const Cc = Components.classes;
|
||||
const Cr = Components.results;
|
||||
const Cu = Components.utils;
|
||||
const { Task } = Cu.import("resource://gre/modules/Task.jsm", {});
|
||||
const { Promise } = Cu.import("resource://gre/modules/Promise.jsm", {});
|
||||
|
||||
const SAMPLE_URL = "http://www.mozilla.org/";
|
||||
const SAMPLE_TEXT = "Some text in a text field.";
|
||||
|
@ -58,9 +55,6 @@
|
|||
function ok(condition, message) {
|
||||
window.opener.wrappedJSObject.SimpleTest.ok(condition, message);
|
||||
}
|
||||
function is(a, b, message) {
|
||||
window.opener.wrappedJSObject.SimpleTest.is(a, b, message);
|
||||
}
|
||||
function finish() {
|
||||
window.close();
|
||||
window.opener.wrappedJSObject.SimpleTest.finish();
|
||||
|
@ -89,7 +83,7 @@
|
|||
setTimeout(onPageShow, 0);
|
||||
}
|
||||
|
||||
let onPageShow = Task.async(function* () {
|
||||
function onPageShow() {
|
||||
testNormalFind();
|
||||
gFindBar.close();
|
||||
ok(gFindBar.hidden, "Failed to close findbar after testNormalFind");
|
||||
|
@ -106,19 +100,19 @@
|
|||
testFindbarSelection();
|
||||
testDrop();
|
||||
testQuickFindLink();
|
||||
if (gHasFindClipboard) {
|
||||
yield testStatusText();
|
||||
if (gHasFindClipboard)
|
||||
testStatusText(afterStatusText);
|
||||
else
|
||||
afterStatusText();
|
||||
|
||||
function afterStatusText() {
|
||||
testFindCountUI(function() {
|
||||
gFindBar.close();
|
||||
ok(gFindBar.hidden, "Failed to close findbar after testFindCountUI");
|
||||
testQuickFindClose();
|
||||
});
|
||||
}
|
||||
yield testFindCountUI();
|
||||
gFindBar.close();
|
||||
ok(gFindBar.hidden, "Failed to close findbar after testFindCountUI");
|
||||
yield testFindAfterCaseChanged();
|
||||
gFindBar.close();
|
||||
yield testFailedStringReset();
|
||||
gFindBar.close();
|
||||
yield testQuickFindClose();
|
||||
finish();
|
||||
});
|
||||
}
|
||||
|
||||
function testFindbarSelection() {
|
||||
function checkFindbarState(aTestName, aExpSelection) {
|
||||
|
@ -164,30 +158,26 @@
|
|||
// use an dummy image to start the drag so it doesn't get interrupted by a selection
|
||||
var img = gBrowser.contentDocument.getElementById("img");
|
||||
synthesizeDrop(img, gFindBar._findField, [[ {type: "text/plain", data: "Rabbits" } ]], "copy", window);
|
||||
is(gFindBar._findField.inputField.value, "Rabbits", "drop on findbar");
|
||||
window.opener.wrappedJSObject.SimpleTest.is(gFindBar._findField.inputField.value, "Rabbits", "drop on findbar");
|
||||
gFindBar.close();
|
||||
}
|
||||
|
||||
function testQuickFindClose() {
|
||||
let deferred = Promise.defer();
|
||||
var _isClosedCallback = function() {
|
||||
ok(gFindBar.hidden,
|
||||
"_isClosedCallback: Failed to auto-close quick find bar after " +
|
||||
gFindBar._quickFindTimeoutLength + "ms");
|
||||
deferred.resolve();
|
||||
finish();
|
||||
};
|
||||
setTimeout(_isClosedCallback, gFindBar._quickFindTimeoutLength + 100);
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
function testStatusText() {
|
||||
let deferred = Promise.defer();
|
||||
function testStatusText(aCallback) {
|
||||
var _delayedCheckStatusText = function() {
|
||||
ok(gStatusText == SAMPLE_URL, "testStatusText: Failed to set status text of found link");
|
||||
deferred.resolve();
|
||||
aCallback();
|
||||
};
|
||||
setTimeout(_delayedCheckStatusText, 100);
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
function enterStringIntoFindField(aString) {
|
||||
|
@ -403,8 +393,6 @@
|
|||
}
|
||||
|
||||
function testFindCountUI(callback) {
|
||||
let deferred = Promise.defer();
|
||||
|
||||
clearFocus();
|
||||
document.getElementById("cmd_find").doCommand();
|
||||
|
||||
|
@ -438,9 +426,9 @@
|
|||
let timeout = gFindBar._matchesCountTimeoutLength + 20;
|
||||
|
||||
function assertMatches(aTest, aMatches) {
|
||||
is(aMatches[1], aTest.current,
|
||||
window.opener.wrappedJSObject.SimpleTest.is(aMatches[1], aTest.current,
|
||||
"Currently highlighted match should be at " + aTest.current);
|
||||
is(aMatches[2], aTest.total,
|
||||
window.opener.wrappedJSObject.SimpleTest.is(aMatches[2], aTest.total,
|
||||
"Total amount of matches should be " + aTest.total);
|
||||
}
|
||||
|
||||
|
@ -467,7 +455,7 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
deferred.resolve();
|
||||
callback();
|
||||
}
|
||||
let test = generatorTest();
|
||||
let resultListener = {
|
||||
|
@ -477,54 +465,6 @@
|
|||
};
|
||||
gFindBar.browser.finder.addResultListener(resultListener);
|
||||
test.next();
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
// See bug 1051187.
|
||||
function testFindAfterCaseChanged() {
|
||||
let deferred = Promise.defer();
|
||||
document.getElementById("cmd_find").doCommand();
|
||||
|
||||
// Search to set focus on "Text Test" so that searching for "t" selects first
|
||||
// (upper case!) "T".
|
||||
enterStringIntoFindField(SEARCH_TEXT);
|
||||
gFindBar.clear();
|
||||
|
||||
let prefsvc = Cc["@mozilla.org/preferences-service;1"]
|
||||
.getService(Ci.nsIPrefBranch);
|
||||
prefsvc.setIntPref("accessibility.typeaheadfind.casesensitive", 0);
|
||||
|
||||
enterStringIntoFindField("t");
|
||||
is(gBrowser.contentWindow.getSelection(), "T", "First T should be selected.");
|
||||
|
||||
prefsvc.setIntPref("accessibility.typeaheadfind.casesensitive", 1);
|
||||
setTimeout(function() {
|
||||
is(gBrowser.contentWindow.getSelection(), "t", "First t should be selected.");
|
||||
deferred.resolve();
|
||||
}, 0);
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
// Make sure that _findFailedString is cleared:
|
||||
// 1. Do a search that fails with case sensitivity but matches with no case sensitivity.
|
||||
// 2. Uncheck case sensitivity button to match the string.
|
||||
function testFailedStringReset(aCallback) {
|
||||
let deferred = Promise.defer();
|
||||
document.getElementById("cmd_find").doCommand();
|
||||
|
||||
var prefsvc = Cc["@mozilla.org/preferences-service;1"].
|
||||
getService(Components.interfaces.nsIPrefBranch);
|
||||
prefsvc.setIntPref("accessibility.typeaheadfind.casesensitive", 1);
|
||||
|
||||
enterStringIntoFindField(SEARCH_TEXT.toUpperCase());
|
||||
is(gBrowser.contentWindow.getSelection(), "", "Not found.");
|
||||
|
||||
prefsvc.setIntPref("accessibility.typeaheadfind.casesensitive", 0);
|
||||
setTimeout(function() {
|
||||
is(gBrowser.contentWindow.getSelection(), SEARCH_TEXT, "Search text should be selected.");
|
||||
deferred.resolve();
|
||||
}, 0);
|
||||
return deferred.resolve();
|
||||
}
|
||||
|
||||
function testClipboardSearchString(aExpected) {
|
||||
|
|
|
@ -538,8 +538,6 @@
|
|||
<body><![CDATA[
|
||||
this._typeAheadCaseSensitive = aCaseSensitivity;
|
||||
this._updateCaseSensitivity();
|
||||
this._findFailedString = null;
|
||||
this._find();
|
||||
if (this.getElement("highlight").checked)
|
||||
this._setHighlightTimeout();
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче