Backed out changeset d20f6afea6f0 (bug 1348409) for android failures in test_no_find_showDialog.html a=backout
authorWes Kocher <wkocher@mozilla.com>
Thu, 20 Apr 2017 13:20:47 -0700
changeset 354080 732dd62950212183eb8c3351be00b17980547468
parent 354079 06ab368e6c0223e7a37c806e0786939620cb3f52
child 354081 1e269a211fe79ce17e7fcf4041d7f726d23c1e28
push id41171
push userkwierso@gmail.com
push dateThu, 20 Apr 2017 20:23:07 +0000
treeherderautoland@732dd6295021 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbackout
bugs1348409
milestone55.0a1
backs outd20f6afea6f09a9a3df0822a29f33ee1d1778566
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Backed out changeset d20f6afea6f0 (bug 1348409) for android failures in test_no_find_showDialog.html a=backout MozReview-Commit-ID: Hq6Ebrk1OJ0
dom/base/nsGlobalWindow.cpp
dom/tests/mochitest/bugs/mochitest.ini
dom/tests/mochitest/bugs/test_no_find_showDialog.html
--- a/dom/base/nsGlobalWindow.cpp
+++ b/dom/base/nsGlobalWindow.cpp
@@ -10062,18 +10062,16 @@ nsGlobalWindow::GetSelection()
 bool
 nsGlobalWindow::FindOuter(const nsAString& aString, bool aCaseSensitive,
                           bool aBackwards, bool aWrapAround, bool aWholeWord,
                           bool aSearchInFrames, bool aShowDialog,
                           ErrorResult& aError)
 {
   MOZ_RELEASE_ASSERT(IsOuterWindow());
 
-  Unused << aShowDialog;
-
   if (Preferences::GetBool("dom.disable_window_find", false)) {
     aError.Throw(NS_ERROR_NOT_AVAILABLE);
     return false;
   }
 
   nsCOMPtr<nsIWebBrowserFind> finder(do_GetInterface(mDocShell));
   if (!finder) {
     aError.Throw(NS_ERROR_NOT_AVAILABLE);
@@ -10096,17 +10094,42 @@ nsGlobalWindow::FindOuter(const nsAStrin
   // frame. If we're being called from JS (as here), this window
   // should be the current search frame.
   nsCOMPtr<nsIWebBrowserFindInFrames> framesFinder(do_QueryInterface(finder));
   if (framesFinder) {
     framesFinder->SetRootSearchFrame(AsOuter());   // paranoia
     framesFinder->SetCurrentSearchFrame(AsOuter());
   }
 
-  if (aString.IsEmpty()) {
+  // The Find API does not accept empty strings. Launch the Find Dialog.
+  if (aString.IsEmpty() || aShowDialog) {
+    // See if the find dialog is already up using nsIWindowMediator
+    nsCOMPtr<nsIWindowMediator> windowMediator =
+      do_GetService(NS_WINDOWMEDIATOR_CONTRACTID);
+
+    nsCOMPtr<mozIDOMWindowProxy> findDialog;
+
+    if (windowMediator) {
+      windowMediator->GetMostRecentWindow(u"findInPage",
+                                          getter_AddRefs(findDialog));
+    }
+
+    if (findDialog) {
+      // The Find dialog is already open, bring it to the top.
+      auto* piFindDialog = nsPIDOMWindowOuter::From(findDialog);
+      aError = piFindDialog->Focus();
+    } else if (finder) {
+      // Open a Find dialog
+      nsCOMPtr<nsPIDOMWindowOuter> dialog;
+      aError = OpenDialog(NS_LITERAL_STRING("chrome://global/content/finddialog.xul"),
+                          NS_LITERAL_STRING("_blank"),
+                          NS_LITERAL_STRING("chrome, resizable=no, dependent=yes"),
+                          finder, getter_AddRefs(dialog));
+    }
+
     return false;
   }
 
   // Launch the search with the passed in search string
   bool didFind = false;
   aError = finder->FindNext(&didFind);
   return didFind;
 }
--- a/dom/tests/mochitest/bugs/mochitest.ini
+++ b/dom/tests/mochitest/bugs/mochitest.ini
@@ -157,9 +157,8 @@ skip-if = toolkit == 'android' || os == 
 skip-if = toolkit == 'android' #Windows can't change size on Android
 [test_toJSON.html]
 [test_window_bar.html]
 skip-if = toolkit == 'android'
 [test_bug1022869.html]
 [test_bug1112040.html]
 [test_bug1160342_marquee.html]
 [test_bug1171215.html]
-[test_no_find_showDialog.html]
deleted file mode 100644
--- a/dom/tests/mochitest/bugs/test_no_find_showDialog.html
+++ /dev/null
@@ -1,92 +0,0 @@
-<!DOCTYPE html>
-<html>
-<head>
-  <meta charset="utf-8">
-  <title>Test for Bug 1348409</title>
-  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
-  <script type="application/javascript" src="/tests/SimpleTest/SpawnTask.js"></script>
-  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
-  <iframe src="about:blank"></iframe>
-  <script type="text/javascript; version=1.8">
-
-  function checkForFindDialog() {
-    let chromeScript = SpecialPowers.loadChromeScript(_ => {
-      addMessageListener("test:check", () => {
-        const { utils: Cu } = Components;
-
-        Cu.import("resource://gre/modules/Services.jsm");
-
-        let sawFind = false;
-        let findDialog = Services.wm.getMostRecentWindow("findInPage");
-        if (findDialog) {
-          findDialog.close();
-          sawFind = true;
-        }
-
-        return sawFind;
-      });
-
-    });
-
-    let sawFind = chromeScript.sendSyncMessage("test:check")[0][0];
-    chromeScript.destroy();
-    return sawFind;
-  }
-
-  function ensureFinished(chromeScript) {
-    return new Promise(resolve => {
-      chromeScript.addMessageListener("test:disarm:done", (sawWindow) => {
-        resolve(sawWindow);
-      });
-      chromeScript.sendAsyncMessage("test:disarm");
-    });
-  }
-
-  function doWraparoundFind(findString, showDialog) {
-    let result = window.find(findString,
-                             false /* aCaseSensitive */,
-                             false /* aBackwards*/,
-                             true /* aWrapAround */,
-                             false /* aWholeWord */,
-                             false /* aSearchInFrames */,
-                             showDialog /* aShowInDialog */)
-    // Collapse selection so that we can do another find outside
-    // of the selection result.
-    document.getSelection().collapseToStart();
-    return result;
-  }
-
-  function startTest() {
-    add_task(function*() {
-      ok(doWraparoundFind("text to search for", false),
-         "Found the text in the document body.");
-
-      // We're asking for the dialog now. We should just ignore that request.
-      ok(doWraparoundFind("fhqwhgads", true),
-         "Should return true and not show a dialog if the string exists in the page.");
-      ok(!doWraparoundFind(null, true),
-         "Should return false and not show a dialog if we pass a null string.");
-      ok(!doWraparoundFind("", true),
-         "Should return false and not show a dialog if we pass an empty string.");
-
-      // Double check to ensure that the parent didn't open a find dialog
-      let sawWindow = checkForFindDialog();
-      ok(!sawWindow, "Should never have seen the dialog.");
-    });
-  }
-  </script>
-</head>
-<body onload="startTest()">
-<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1348409">Mozilla Bug 1348409</a>
-
-<p>
-  Here's some text to search for: fhqwhgads! A hovercraft full of eels!
-</p>
-
-<p id="display"></p>
-<div id="content" style="display: none">
-</div>
-<pre id="test">
-</pre>
-</body>
-</html>
\ No newline at end of file