diff --git a/browser/base/content/test/general/browser_bug537013.js b/browser/base/content/test/general/browser_bug537013.js
index 4f8d0be6797..96719cac4d2 100644
--- a/browser/base/content/test/general/browser_bug537013.js
+++ b/browser/base/content/test/general/browser_bug537013.js
@@ -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,
" + aText + "
");
tabs.push(newTab);
@@ -61,7 +64,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,7 +99,8 @@ 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],
+ let toTest = HasFindClipboard ? texts[2] : texts[1];
+ is(gFindBar._findField.value, toTest,
"Fourth tab has second tab's find value!");
newWindow = gBrowser.replaceTabWithWindow(tabs.pop());
@@ -104,7 +110,8 @@ 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],
+ let toTest = HasFindClipboard ? texts[2] : texts[1];
+ is(newWindow.gFindBar._findField.value, toTest,
"New window find bar has correct find value!");
ok(!newWindow.gFindBar.getElement("find-next").disabled,
"New window findbar has enabled buttons!");
diff --git a/browser/base/content/test/general/browser_bug567306.js b/browser/base/content/test/general/browser_bug567306.js
index 1fa35efa851..f3507f66eea 100644
--- a/browser/base/content/test/general/browser_bug567306.js
+++ b/browser/base/content/test/general/browser_bug567306.js
@@ -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();
diff --git a/toolkit/content/tests/chrome/bug409624_window.xul b/toolkit/content/tests/chrome/bug409624_window.xul
index d4bb387dde8..fe9948936f7 100644
--- a/toolkit/content/tests/chrome/bug409624_window.xul
+++ b/toolkit/content/tests/chrome/bug409624_window.xul
@@ -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();
diff --git a/toolkit/content/tests/chrome/findbar_window.xul b/toolkit/content/tests/chrome/findbar_window.xul
index 8e902964dc7..012c596ebb8 100644
--- a/toolkit/content/tests/chrome/findbar_window.xul
+++ b/toolkit/content/tests/chrome/findbar_window.xul
@@ -30,6 +30,9 @@
var gFindBar = null;
var gBrowser;
+ var gClipboard = Cc["@mozilla.org/widget/clipboard;1"].getService("nsIClipboard");
+ var gHasFindClipboard = gClipboard.supportsFindClipboard();
+
var gStatusText;
var gXULBrowserWindow = {
QueryInterface: function(aIID) {
@@ -94,7 +97,8 @@
testFindbarSelection();
testDrop();
testQuickFindLink();
- testStatusText();
+ if (gHasFindClipboard)
+ testStatusText();
testQuickFindClose();
}
@@ -104,8 +108,12 @@
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);
+ }
+ testClipboardSearchString(aExpSelection);
// Clear the value, close the findbar
gFindBar._findField.value = "";
@@ -185,12 +193,14 @@
enterStringIntoFindField(searchStr);
ok(gBrowser.contentWindow.getSelection().toString().toLowerCase() == searchStr,
"testNormalFind: failed to find '" + searchStr + "'");
+ testClipboardSearchString(gBrowser.contentWindow.getSelection().toString());
if (!matchCaseCheckbox.hidden) {
matchCaseCheckbox.click();
enterStringIntoFindField("t");
ok(gBrowser.contentWindow.getSelection() != searchStr,
"testNormalFind: Case-sensitivy is broken '" + searchStr + "'");
+ testClipboardSearchString(gBrowser.contentWindow.getSelection().toString());
matchCaseCheckbox.click();
}
}
@@ -228,6 +238,7 @@
ok(gBrowser.contentWindow.getSelection().toString().toLowerCase() != searchStr,
"testNormalFindWithComposition: text shouldn't be found during composition");
+ testClipboardSearchString(gBrowser.contentWindow.getSelection().toString());
synthesizeText(
{ "composition":
@@ -243,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();
@@ -302,6 +314,7 @@
enterStringIntoFindField(searchStr);
ok(gBrowser.contentWindow.getSelection() == searchStr,
"testQuickFindLink: failed to find sample link");
+ testClipboardSearchString(searchStr);
}
function testQuickFindText() {
@@ -319,6 +332,18 @@
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 == aExpected, "testClipboardSearchString: search string not " +
+ "set to '" + aExpected + "', instead found '" + searchStr + "'");
}
]]>