mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-26 14:22:01 +00:00
Bug 326743: update tests to know about the Find Clipboard on OSX. r=Unfocused
This commit is contained in:
parent
b3953af07a
commit
d98ecb3db7
@ -11,6 +11,9 @@ let texts = [
|
||||
"To err is human; to forgive is not company policy."
|
||||
];
|
||||
|
||||
let Clipboard = Cc["@mozilla.org/widget/clipboard;1"].getService(Ci.nsIClipboard);
|
||||
let HasFindClipboard = Clipboard.supportsFindClipboard();
|
||||
|
||||
function addTabWithText(aText, aCallback) {
|
||||
let newTab = gBrowser.addTab("data:text/html,<h1 id='h1'>" + aText + "</h1>");
|
||||
tabs.push(newTab);
|
||||
@ -19,6 +22,7 @@ function addTabWithText(aText, aCallback) {
|
||||
|
||||
function setFindString(aString) {
|
||||
gFindBar.open();
|
||||
gFindBar._findField.focus();
|
||||
gFindBar._findField.select();
|
||||
EventUtils.sendString(aString);
|
||||
is(gFindBar._findField.value, aString, "Set the field correctly!");
|
||||
@ -61,7 +65,9 @@ function continueTests1() {
|
||||
// Confirm the first tab is still correct, ensure re-hiding works as expected
|
||||
gBrowser.selectedTab = tabs[0];
|
||||
ok(!gFindBar.hidden, "First tab shows find bar!");
|
||||
is(gFindBar._findField.value, texts[0], "First tab persists find value!");
|
||||
// When the Find Clipboard is supported, this test not relevant.
|
||||
if (!HasFindClipboard)
|
||||
is(gFindBar._findField.value, texts[0], "First tab persists find value!");
|
||||
ok(gFindBar.getElement("highlight").checked,
|
||||
"Highlight button state persists!");
|
||||
|
||||
@ -94,8 +100,11 @@ function continueTests2() {
|
||||
ok(gFindBar.hidden, "Fourth tab doesn't show find bar!");
|
||||
is(gFindBar, gBrowser.getFindBar(), "Find bar is right one!");
|
||||
gFindBar.open();
|
||||
is(gFindBar._findField.value, texts[1],
|
||||
"Fourth tab has second tab's find value!");
|
||||
// Disabled the following assertion due to intermittent failure on OSX 10.6 Debug.
|
||||
if (!HasFindClipboard) {
|
||||
is(gFindBar._findField.value, texts[1],
|
||||
"Fourth tab has second tab's find value!");
|
||||
}
|
||||
|
||||
newWindow = gBrowser.replaceTabWithWindow(tabs.pop());
|
||||
whenDelayedStartupFinished(newWindow, checkNewWindow);
|
||||
@ -104,8 +113,11 @@ function continueTests2() {
|
||||
// Test that findbar gets restored when a tab is moved to a new window.
|
||||
function checkNewWindow() {
|
||||
ok(!newWindow.gFindBar.hidden, "New window shows find bar!");
|
||||
is(newWindow.gFindBar._findField.value, texts[1],
|
||||
"New window find bar has correct find value!");
|
||||
// Disabled the following assertion due to intermittent failure on OSX 10.6 Debug.
|
||||
if (!HasFindClipboard) {
|
||||
is(newWindow.gFindBar._findField.value, texts[1],
|
||||
"New window find bar has correct find value!");
|
||||
}
|
||||
ok(!newWindow.gFindBar.getElement("find-next").disabled,
|
||||
"New window findbar has enabled buttons!");
|
||||
newWindow.close();
|
||||
|
@ -2,7 +2,10 @@
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/
|
||||
*/
|
||||
|
||||
let Ci = Components.interfaces;
|
||||
const {Ci: interfaces, Cc: classes} = Components;
|
||||
|
||||
let Clipboard = Cc["@mozilla.org/widget/clipboard;1"].getService(Ci.nsIClipboard);
|
||||
let HasFindClipboard = Clipboard.supportsFindClipboard();
|
||||
|
||||
function test() {
|
||||
waitForExplicitFinish();
|
||||
@ -37,7 +40,10 @@ function onFocus(win) {
|
||||
let findBar = win.gFindBar;
|
||||
selectText(win.content);
|
||||
findBar.onFindCommand();
|
||||
is(findBar._findField.value, "Select Me", "Findbar is initialized with selection");
|
||||
// When the OS supports the Find Clipboard (OSX), the find field value is
|
||||
// persisted across Fx sessions, thus not useful to test.
|
||||
if (!HasFindClipboard)
|
||||
is(findBar._findField.value, "Select Me", "Findbar is initialized with selection");
|
||||
findBar.close();
|
||||
win.close();
|
||||
finish();
|
||||
|
@ -58,6 +58,7 @@
|
||||
|
||||
// Simulate typical input
|
||||
textbox.focus();
|
||||
gFindBar.clear();
|
||||
sendChar("m");
|
||||
ok(gFindBar.canClear, "canClear property true after input");
|
||||
let preSelection = gBrowser.contentWindow.getSelection();
|
||||
|
@ -30,6 +30,9 @@
|
||||
var gFindBar = null;
|
||||
var gBrowser;
|
||||
|
||||
var gClipboard = Cc["@mozilla.org/widget/clipboard;1"].getService(Ci.nsIClipboard);
|
||||
var gHasFindClipboard = gClipboard.supportsFindClipboard();
|
||||
|
||||
var gStatusText;
|
||||
var gXULBrowserWindow = {
|
||||
QueryInterface: function(aIID) {
|
||||
@ -97,7 +100,8 @@
|
||||
testFindbarSelection();
|
||||
testDrop();
|
||||
testQuickFindLink();
|
||||
testStatusText();
|
||||
if (gHasFindClipboard)
|
||||
testStatusText();
|
||||
testQuickFindClose();
|
||||
}
|
||||
|
||||
@ -107,8 +111,11 @@
|
||||
ok(!gFindBar.hidden, "testFindbarSelection: failed to open findbar: " + aTestName);
|
||||
ok(document.commandDispatcher.focusedElement == gFindBar._findField.inputField,
|
||||
"testFindbarSelection: find field is not focused: " + aTestName);
|
||||
ok(gFindBar._findField.value == aExpSelection,
|
||||
"Incorrect selection in testFindbarSelection: " + aTestName + ". Selection: " + gFindBar._findField.value);
|
||||
if (!gHasFindClipboard) {
|
||||
ok(gFindBar._findField.value == aExpSelection,
|
||||
"Incorrect selection in testFindbarSelection: " + aTestName +
|
||||
". Selection: " + gFindBar._findField.value);
|
||||
}
|
||||
|
||||
// Clear the value, close the findbar
|
||||
gFindBar._findField.value = "";
|
||||
@ -188,6 +195,7 @@
|
||||
enterStringIntoFindField(searchStr);
|
||||
ok(gBrowser.contentWindow.getSelection().toString().toLowerCase() == searchStr,
|
||||
"testNormalFind: failed to find '" + searchStr + "'");
|
||||
testClipboardSearchString(gBrowser.contentWindow.getSelection().toString());
|
||||
|
||||
if (!matchCaseCheckbox.hidden) {
|
||||
matchCaseCheckbox.click();
|
||||
@ -246,6 +254,7 @@
|
||||
|
||||
ok(gBrowser.contentWindow.getSelection().toString().toLowerCase() == searchStr,
|
||||
"testNormalFindWithComposition: text should be found after committing composition");
|
||||
testClipboardSearchString(gBrowser.contentWindow.getSelection().toString());
|
||||
|
||||
if (clicked) {
|
||||
matchCaseCheckbox.click();
|
||||
@ -305,6 +314,7 @@
|
||||
enterStringIntoFindField(searchStr);
|
||||
ok(gBrowser.contentWindow.getSelection() == searchStr,
|
||||
"testQuickFindLink: failed to find sample link");
|
||||
testClipboardSearchString(searchStr);
|
||||
}
|
||||
|
||||
// See bug 963925 for more details on this test.
|
||||
@ -321,7 +331,7 @@
|
||||
let a = gFindBar._findField.value;
|
||||
let b = gFindBar._browser.finder._fastFind.searchString;
|
||||
let c = gFindBar._browser.finder.searchString;
|
||||
ok(a == b && b == c, "testFindWithHighlight: " + a + ", " + b + ", " + c + ".");
|
||||
ok(a == b && b == c, "testFindWithHighlight 1: " + a + ", " + b + ", " + c + ".");
|
||||
|
||||
let oldGetInitialSelection = gFindBar._getInitialSelection;
|
||||
let searchStr = "t";
|
||||
@ -332,22 +342,25 @@
|
||||
a = gFindBar._findField.value;
|
||||
b = gFindBar._browser.finder._fastFind.searchString;
|
||||
c = gFindBar._browser.finder.searchString;
|
||||
ok(a == searchStr && b == c, "testFindWithHighlight: " + a + ", " + b + ", " + c + ".");
|
||||
ok(a == searchStr && b == c, "testFindWithHighlight 2: " + searchStr +
|
||||
", " + a + ", " + b + ", " + c + ".");
|
||||
|
||||
let highlightButton = gFindBar.getElement("highlight");
|
||||
highlightButton.click();
|
||||
ok(highlightButton.checked, "testFindWithHighlight: Highlight All should be checked.");
|
||||
ok(highlightButton.checked, "testFindWithHighlight 3: Highlight All should be checked.");
|
||||
|
||||
a = gFindBar._findField.value;
|
||||
b = gFindBar._browser.finder._fastFind.searchString;
|
||||
c = gFindBar._browser.finder.searchString;
|
||||
ok(a == searchStr && b == c, "testFindWithHighlight: " + a + ", " + b + ", " + c + ".");
|
||||
if (!gHasFindClipboard) {
|
||||
a = gFindBar._findField.value;
|
||||
b = gFindBar._browser.finder._fastFind.searchString;
|
||||
c = gFindBar._browser.finder.searchString;
|
||||
ok(a == searchStr && b == c, "testFindWithHighlight 4: " + a + ", " + b + ", " + c + ".");
|
||||
}
|
||||
|
||||
gFindBar.onFindAgainCommand();
|
||||
a = gFindBar._findField.value;
|
||||
b = gFindBar._browser.finder._fastFind.searchString;
|
||||
c = gFindBar._browser.finder.searchString;
|
||||
ok(a == b && b == c, "testFindWithHighlight: " + a + ", " + b + ", " + c + ".");
|
||||
ok(a == b && b == c, "testFindWithHighlight 5: " + a + ", " + b + ", " + c + ".");
|
||||
|
||||
highlightButton.click();
|
||||
ok(!highlightButton.checked, "testFindWithHighlight: Highlight All should be unchecked.");
|
||||
@ -368,6 +381,19 @@
|
||||
enterStringIntoFindField(SEARCH_TEXT);
|
||||
ok(gBrowser.contentWindow.getSelection() == SEARCH_TEXT,
|
||||
"testQuickFindText: failed to find '" + SEARCH_TEXT + "'");
|
||||
testClipboardSearchString(SEARCH_TEXT);
|
||||
}
|
||||
|
||||
function testClipboardSearchString(aExpected) {
|
||||
if (!gHasFindClipboard)
|
||||
return;
|
||||
|
||||
if (!aExpected)
|
||||
aExpected = "";
|
||||
var searchStr = gFindBar.browser.finder.clipboardSearchString;
|
||||
ok(searchStr.toLowerCase() == aExpected.toLowerCase(),
|
||||
"testClipboardSearchString: search string not set to '" + aExpected +
|
||||
"', instead found '" + searchStr + "'");
|
||||
}
|
||||
]]></script>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user