mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-01-13 07:24:47 +00:00
Backed out changeset 7f987505ac94 (bug 1051187) for test failures
This commit is contained in:
parent
6568594f93
commit
0c25e87cfe
@ -21,7 +21,7 @@
|
|||||||
var gFindBar = null;
|
var gFindBar = null;
|
||||||
var gBrowser;
|
var gBrowser;
|
||||||
|
|
||||||
var imports = ["SimpleTest", "ok", "is"];
|
var imports = ["SimpleTest", "ok"];
|
||||||
for each (var name in imports) {
|
for each (var name in imports) {
|
||||||
window[name] = window.opener.wrappedJSObject[name];
|
window[name] = window.opener.wrappedJSObject[name];
|
||||||
}
|
}
|
||||||
@ -71,28 +71,21 @@
|
|||||||
function checkSelection(done) {
|
function checkSelection(done) {
|
||||||
SimpleTest.executeSoon(function() {
|
SimpleTest.executeSoon(function() {
|
||||||
var selected = gBrowser.contentWindow.getSelection();
|
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)
|
var controller = gFindBar.browser.docShell.QueryInterface(Ci.nsIInterfaceRequestor)
|
||||||
.getInterface(Ci.nsISelectionDisplay)
|
.getInterface(Ci.nsISelectionDisplay)
|
||||||
.QueryInterface(Ci.nsISelectionController);
|
.QueryInterface(Ci.nsISelectionController);
|
||||||
var selection = controller.getSelection(controller.SELECTION_FIND);
|
var selection = controller.getSelection(controller.SELECTION_FIND);
|
||||||
is(selection.rangeCount, 0, "No text is highlighted");
|
ok(selection.rangeCount == 0, "No text is highlighted");
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function once(node, eventName, callback) {
|
|
||||||
node.addEventListener(eventName, function clb(e) {
|
|
||||||
node.removeEventListener(eventName, clb);
|
|
||||||
callback(e);
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
function testFind(done) {
|
function testFind(done) {
|
||||||
var eventTriggered = false;
|
var findTriggered = false;
|
||||||
var query = "t";
|
var query = "t";
|
||||||
once(gFindBar, "find", function(e) {
|
gFindBar.addEventListener("find", function(e) {
|
||||||
eventTriggered = true;
|
eventTriggered = true;
|
||||||
ok(e.detail.query === query, "find event query should match '" + query + "'");
|
ok(e.detail.query === query, "find event query should match '" + query + "'");
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
@ -110,7 +103,7 @@
|
|||||||
|
|
||||||
function testFindAgain(done) {
|
function testFindAgain(done) {
|
||||||
var eventTriggered = false;
|
var eventTriggered = false;
|
||||||
once(gFindBar, "findagain", function(e) {
|
gFindBar.addEventListener("findagain", function(e) {
|
||||||
eventTriggered = true;
|
eventTriggered = true;
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
// Since we're preventing the default make sure nothing was selected.
|
// Since we're preventing the default make sure nothing was selected.
|
||||||
@ -123,7 +116,7 @@
|
|||||||
|
|
||||||
function testCaseSensitivity() {
|
function testCaseSensitivity() {
|
||||||
var eventTriggered = false;
|
var eventTriggered = false;
|
||||||
once(gFindBar, "findcasesensitivitychange", function(e) {
|
gFindBar.addEventListener("findcasesensitivitychange", function(e) {
|
||||||
eventTriggered = true;
|
eventTriggered = true;
|
||||||
ok(e.detail.caseSensitive, "find should be case sensitive");
|
ok(e.detail.caseSensitive, "find should be case sensitive");
|
||||||
});
|
});
|
||||||
@ -131,17 +124,13 @@
|
|||||||
var matchCaseCheckbox = gFindBar.getElement("find-case-sensitive");
|
var matchCaseCheckbox = gFindBar.getElement("find-case-sensitive");
|
||||||
matchCaseCheckbox.click();
|
matchCaseCheckbox.click();
|
||||||
ok(eventTriggered, "findcasesensitivitychange should be triggered");
|
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) {
|
function testHighlight(done) {
|
||||||
// Update the find state so the highlight button is clickable.
|
// Update the find state so the highlight button is clickable.
|
||||||
gFindBar.updateControlState(Ci.nsITypeAheadFind.FIND_FOUND, false);
|
gFindBar.updateControlState(Ci.nsITypeAheadFind.FIND_FOUND, false);
|
||||||
var eventTriggered = false;
|
var eventTriggered = false;
|
||||||
once(gFindBar, "findhighlightallchange", function(e) {
|
gFindBar.addEventListener("findhighlightallchange", function(e) {
|
||||||
eventTriggered = true;
|
eventTriggered = true;
|
||||||
ok(e.detail.highlightAll, "find event should have highlight all set");
|
ok(e.detail.highlightAll, "find event should have highlight all set");
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
@ -22,9 +22,6 @@
|
|||||||
const Ci = Components.interfaces;
|
const Ci = Components.interfaces;
|
||||||
const Cc = Components.classes;
|
const Cc = Components.classes;
|
||||||
const Cr = Components.results;
|
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_URL = "http://www.mozilla.org/";
|
||||||
const SAMPLE_TEXT = "Some text in a text field.";
|
const SAMPLE_TEXT = "Some text in a text field.";
|
||||||
@ -58,9 +55,6 @@
|
|||||||
function ok(condition, message) {
|
function ok(condition, message) {
|
||||||
window.opener.wrappedJSObject.SimpleTest.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() {
|
function finish() {
|
||||||
window.close();
|
window.close();
|
||||||
window.opener.wrappedJSObject.SimpleTest.finish();
|
window.opener.wrappedJSObject.SimpleTest.finish();
|
||||||
@ -89,7 +83,7 @@
|
|||||||
setTimeout(onPageShow, 0);
|
setTimeout(onPageShow, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
let onPageShow = Task.async(function* () {
|
function onPageShow() {
|
||||||
testNormalFind();
|
testNormalFind();
|
||||||
gFindBar.close();
|
gFindBar.close();
|
||||||
ok(gFindBar.hidden, "Failed to close findbar after testNormalFind");
|
ok(gFindBar.hidden, "Failed to close findbar after testNormalFind");
|
||||||
@ -106,19 +100,19 @@
|
|||||||
testFindbarSelection();
|
testFindbarSelection();
|
||||||
testDrop();
|
testDrop();
|
||||||
testQuickFindLink();
|
testQuickFindLink();
|
||||||
if (gHasFindClipboard) {
|
if (gHasFindClipboard)
|
||||||
yield testStatusText();
|
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 testFindbarSelection() {
|
||||||
function checkFindbarState(aTestName, aExpSelection) {
|
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
|
// use an dummy image to start the drag so it doesn't get interrupted by a selection
|
||||||
var img = gBrowser.contentDocument.getElementById("img");
|
var img = gBrowser.contentDocument.getElementById("img");
|
||||||
synthesizeDrop(img, gFindBar._findField, [[ {type: "text/plain", data: "Rabbits" } ]], "copy", window);
|
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();
|
gFindBar.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
function testQuickFindClose() {
|
function testQuickFindClose() {
|
||||||
let deferred = Promise.defer();
|
|
||||||
var _isClosedCallback = function() {
|
var _isClosedCallback = function() {
|
||||||
ok(gFindBar.hidden,
|
ok(gFindBar.hidden,
|
||||||
"_isClosedCallback: Failed to auto-close quick find bar after " +
|
"_isClosedCallback: Failed to auto-close quick find bar after " +
|
||||||
gFindBar._quickFindTimeoutLength + "ms");
|
gFindBar._quickFindTimeoutLength + "ms");
|
||||||
deferred.resolve();
|
finish();
|
||||||
};
|
};
|
||||||
setTimeout(_isClosedCallback, gFindBar._quickFindTimeoutLength + 100);
|
setTimeout(_isClosedCallback, gFindBar._quickFindTimeoutLength + 100);
|
||||||
return deferred.promise;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function testStatusText() {
|
function testStatusText(aCallback) {
|
||||||
let deferred = Promise.defer();
|
|
||||||
var _delayedCheckStatusText = function() {
|
var _delayedCheckStatusText = function() {
|
||||||
ok(gStatusText == SAMPLE_URL, "testStatusText: Failed to set status text of found link");
|
ok(gStatusText == SAMPLE_URL, "testStatusText: Failed to set status text of found link");
|
||||||
deferred.resolve();
|
aCallback();
|
||||||
};
|
};
|
||||||
setTimeout(_delayedCheckStatusText, 100);
|
setTimeout(_delayedCheckStatusText, 100);
|
||||||
return deferred.promise;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function enterStringIntoFindField(aString) {
|
function enterStringIntoFindField(aString) {
|
||||||
@ -403,8 +393,6 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function testFindCountUI(callback) {
|
function testFindCountUI(callback) {
|
||||||
let deferred = Promise.defer();
|
|
||||||
|
|
||||||
clearFocus();
|
clearFocus();
|
||||||
document.getElementById("cmd_find").doCommand();
|
document.getElementById("cmd_find").doCommand();
|
||||||
|
|
||||||
@ -438,9 +426,9 @@
|
|||||||
let timeout = gFindBar._matchesCountTimeoutLength + 20;
|
let timeout = gFindBar._matchesCountTimeoutLength + 20;
|
||||||
|
|
||||||
function assertMatches(aTest, aMatches) {
|
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);
|
"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);
|
"Total amount of matches should be " + aTest.total);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -467,7 +455,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
deferred.resolve();
|
callback();
|
||||||
}
|
}
|
||||||
let test = generatorTest();
|
let test = generatorTest();
|
||||||
let resultListener = {
|
let resultListener = {
|
||||||
@ -477,54 +465,6 @@
|
|||||||
};
|
};
|
||||||
gFindBar.browser.finder.addResultListener(resultListener);
|
gFindBar.browser.finder.addResultListener(resultListener);
|
||||||
test.next();
|
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) {
|
function testClipboardSearchString(aExpected) {
|
||||||
|
@ -538,8 +538,6 @@
|
|||||||
<body><![CDATA[
|
<body><![CDATA[
|
||||||
this._typeAheadCaseSensitive = aCaseSensitivity;
|
this._typeAheadCaseSensitive = aCaseSensitivity;
|
||||||
this._updateCaseSensitivity();
|
this._updateCaseSensitivity();
|
||||||
this._findFailedString = null;
|
|
||||||
this._find();
|
|
||||||
if (this.getElement("highlight").checked)
|
if (this.getElement("highlight").checked)
|
||||||
this._setHighlightTimeout();
|
this._setHighlightTimeout();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user