Merge autoland to mozilla-central. a=merge
authorMarian-Vasile Laza <mlaza@mozilla.com>
Sun, 17 Apr 2022 02:38:24 -0700
changeset 684929 017b16354ae6c213e97f265f18c7227caa68fa2a
parent 684928 7ffaf8691780f008aae9f3826fc3da4e4392a545 (current diff)
parent 684927 709b507ed708763f0c809fe86e48bfcea071b7b6 (diff)
child 684930 49f93756f94b15faafff2b342ffa7916efdcc397
child 684932 08918da0d247f66ca5ff7955fe7078e3d37991b4
push id16598
push userffxbld-merge
push dateMon, 02 May 2022 14:23:32 +0000
treeherdermozilla-beta@de86a81c7a63 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmerge
milestone101.0a1
first release with
nightly linux32
017b16354ae6 / 101.0a1 / 20220417093901 / files
nightly linux64
017b16354ae6 / 101.0a1 / 20220417093901 / files
nightly mac
017b16354ae6 / 101.0a1 / 20220417093901 / files
nightly win32
017b16354ae6 / 101.0a1 / 20220417093901 / files
nightly win64
017b16354ae6 / 101.0a1 / 20220417093901 / files
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
releases
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Merge autoland to mozilla-central. a=merge
--- a/browser/base/content/test/tabs/browser_navigate_through_urls_origin_attributes.js
+++ b/browser/base/content/test/tabs/browser_navigate_through_urls_origin_attributes.js
@@ -149,17 +149,26 @@ async function loadURIAndCheckRemoteType
     aBrowser.remoteType,
     `correct remote type for ${aURI} ${aText}`
   );
 
   // Verify XULFrameLoaderCreated firing correct number of times
   info(
     `XULFrameLoaderCreated was fired ${xulFrameLoaderCreatedCounter.numCalledSoFar} time(s) for ${aURI} ${aText}`
   );
-  var numExpected = expectedCurr == aPrevRemoteType ? 0 : 1;
+  var numExpected =
+    expectedCurr == aPrevRemoteType &&
+    // With BFCache in the parent we'll get a XULFrameLoaderCreated even if
+    // expectedCurr == aPrevRemoteType, because we store the old frameloader
+    // in the BFCache. We have to make an exception for loads in the parent
+    // process (which have a null aPrevRemoteType/expectedCurr) because
+    // BFCache in the parent disables caching for those loads.
+    (!SpecialPowers.Services.appinfo.sessionHistoryInParent || !expectedCurr)
+      ? 0
+      : 1;
   is(
     xulFrameLoaderCreatedCounter.numCalledSoFar,
     numExpected,
     `XULFrameLoaderCreated fired correct number of times for ${aURI} ${aText} 
     prev=${aPrevRemoteType} curr =${aBrowser.remoteType}`
   );
   aBrowser.ownerGlobal.gBrowser.removeEventListener(
     "XULFrameLoaderCreated",
--- a/docshell/test/navigation/file_bug1300461_back.html
+++ b/docshell/test/navigation/file_bug1300461_back.html
@@ -15,17 +15,17 @@
       async function test() {
         if (opener) {
           opener.info("file_bug1300461_back.html");
           opener.is(shistory.count, 2, "check history length");
           opener.is(shistory.index, 1, "check history index");
           if (!SpecialPowers.Services.appinfo.sessionHistoryInParent) {
             opener.is(shistory.legacySHistory.requestedIndex, -1, "check requestedIndex");
           } else {
-            let index = await opener.getSHRequestedIndex();
+            let index = await opener.getSHRequestedIndex(SpecialPowers.wrap(window).browsingContext.id);
             opener.is(index, -1, "check requestedIndex");
           }
 
           opener.ok(webNav.canGoBack, "check canGoBack");
           if (opener.testCount == 1) {
             opener.info("replaceState to redirect.html");
             window.history.replaceState({}, "", "file_bug1300461_redirect.html");
           }
--- a/docshell/test/navigation/test_bug1300461.html
+++ b/docshell/test/navigation/test_bug1300461.html
@@ -15,42 +15,39 @@ https://bugzilla.mozilla.org/show_bug.cg
 
 </div>
 <pre id="test">
   <script type="application/javascript">
 
     let chromeScript = null;
     if (SpecialPowers.Services.appinfo.sessionHistoryInParent) {
       chromeScript = SpecialPowers.loadChromeScript(() => {
-        const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
-
         function doSend(message, fn) {
           try {
             // eslint-disable-next-line no-undef
             sendAsyncMessage(message, {success: true, value: fn()});
           } catch(_) {
             // eslint-disable-next-line no-undef
             sendAsyncMessage(message, {success: false});
           }
         }
 
         // eslint-disable-next-line no-undef
-        addMessageListener("requestedIndex", () => {
+        addMessageListener("requestedIndex", (id) => {
           doSend("requestedIndex", () => {
-            let win = Services.wm.getMostRecentWindow("navigator:browser");
-            let shistory = win.gBrowser.selectedBrowser.browsingContext.sessionHistory;
+            let shistory = BrowsingContext.get(id).top.sessionHistory;
             return shistory.requestedIndex;
           })
         });
       });
     }
 
-    async function getSHRequestedIndex() {
+    async function getSHRequestedIndex(browsingContextId) {
       let p = chromeScript.promiseOneMessage("requestedIndex");
-      chromeScript.sendAsyncMessage("requestedIndex");
+      chromeScript.sendAsyncMessage("requestedIndex", browsingContextId);
       let result = await p;
       ok(result.success, "Got requested index from parent");
       return result.value;
     }
 
     var testCount = 0;
 
     SimpleTest.waitForExplicitFinish();
--- a/docshell/test/navigation/test_bug1375833.html
+++ b/docshell/test/navigation/test_bug1375833.html
@@ -21,33 +21,30 @@ https://bugzilla.mozilla.org/show_bug.cg
 
     let testWin = window.open("file_bug1375833.html");
     let count = 0;
     let webNav, shistory;
     let frameDocShellId;
     let chromeScript = null;
     if (SpecialPowers.Services.appinfo.sessionHistoryInParent) {
       chromeScript = SpecialPowers.loadChromeScript(() => {
-        const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
-
         function doSend(message, fn) {
           try {
             // eslint-disable-next-line no-undef
             sendAsyncMessage(message, {success: true, value: fn()});
           } catch(_) {
             // eslint-disable-next-line no-undef
             sendAsyncMessage(message, {success: false});
           }
         }
 
         // eslint-disable-next-line no-undef
-        addMessageListener("test1", index => {
+        addMessageListener("test1", id => {
           doSend("test1", () => {
-            let win = Services.wm.getMostRecentWindow("navigator:browser");
-            let sessionHistory = win.gBrowser.selectedBrowser.browsingContext.sessionHistory;
+            let sessionHistory = BrowsingContext.get(id).top.sessionHistory;
             let entry = sessionHistory.getEntryAtIndex(sessionHistory.index);
             let frameEntry = entry.GetChildAt(0);
             return String(frameEntry.docshellID);
           })
         });
       });
     }
 
@@ -78,17 +75,17 @@ https://bugzilla.mozilla.org/show_bug.cg
           is(newFrameDocShellId, frameDocShellId, "check docshell ID remains after reload");
 
           if (!SpecialPowers.Services.appinfo.sessionHistoryInParent) {
             let entry = shistory.legacySHistory.getEntryAtIndex(shistory.index);
             let frameEntry = entry.GetChildAt(0);
             is(String(frameEntry.docshellID), frameDocShellId, "check newly added shentry uses the same docshell ID");
           } else {
             let p = chromeScript.promiseOneMessage("test1");
-            chromeScript.sendAsyncMessage("test1", shistory.index);
+            chromeScript.sendAsyncMessage("test1", SpecialPowers.wrap(testWin).browsingContext.id);
             let result = await p;
             ok(result.success, "legacySHistory worked around ok");
             is(result.value, frameDocShellId, "check newly added shentry uses the same docshell ID");
           }
 
           webNav.goBack();
           break;
         case 2:
--- a/dom/media/platforms/wmf/DXVA2Manager.cpp
+++ b/dom/media/platforms/wmf/DXVA2Manager.cpp
@@ -205,29 +205,29 @@ HRESULT ConvertMFTypeToDXVAType(IMFMedia
   NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
   NS_ENSURE_TRUE(width <= MAX_VIDEO_WIDTH, E_FAIL);
   NS_ENSURE_TRUE(height <= MAX_VIDEO_HEIGHT, E_FAIL);
   pDesc->SampleWidth = width;
   pDesc->SampleHeight = height;
 
   UINT32 fpsNumerator = 0;
   UINT32 fpsDenominator = 0;
-  hr = MFGetAttributeRatio(pType, MF_MT_FRAME_RATE, &fpsNumerator,
-                           &fpsDenominator);
-  NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
-  pDesc->InputSampleFreq.Numerator = fpsNumerator;
-  pDesc->InputSampleFreq.Denominator = fpsDenominator;
+  if (SUCCEEDED(MFGetAttributeRatio(pType, MF_MT_FRAME_RATE, &fpsNumerator,
+                                    &fpsDenominator))) {
+    pDesc->InputSampleFreq.Numerator = fpsNumerator;
+    pDesc->InputSampleFreq.Denominator = fpsDenominator;
 
-  GetDXVA2ExtendedFormatFromMFMediaType(pType, &pDesc->SampleFormat);
-  pDesc->OutputFrameFreq = pDesc->InputSampleFreq;
-  if ((pDesc->SampleFormat.SampleFormat ==
-       DXVA2_SampleFieldInterleavedEvenFirst) ||
-      (pDesc->SampleFormat.SampleFormat ==
-       DXVA2_SampleFieldInterleavedOddFirst)) {
-    pDesc->OutputFrameFreq.Numerator *= 2;
+    GetDXVA2ExtendedFormatFromMFMediaType(pType, &pDesc->SampleFormat);
+    pDesc->OutputFrameFreq = pDesc->InputSampleFreq;
+    if ((pDesc->SampleFormat.SampleFormat ==
+         DXVA2_SampleFieldInterleavedEvenFirst) ||
+        (pDesc->SampleFormat.SampleFormat ==
+         DXVA2_SampleFieldInterleavedOddFirst)) {
+      pDesc->OutputFrameFreq.Numerator *= 2;
+    }
   }
 
   return S_OK;
 }
 
 static const GUID DXVA2_ModeH264_E = {
     0x1b81be68,
     0xa0c7,
@@ -270,19 +270,17 @@ bool D3D9DXVA2Manager::SupportsConfig(IM
                                       float aFramerate) {
   GUID inputSubtype;
   HRESULT hr = aInputType->GetGUID(MF_MT_SUBTYPE, &inputSubtype);
   if (FAILED(hr) || inputSubtype != MFVideoFormat_H264) {
     return false;
   }
 
   DXVA2_VideoDesc desc;
-  // TODO Bug 1764823: ConvertMFTypeToDXVAType should accept the input type
-  // instead.
-  hr = ConvertMFTypeToDXVAType(aOutputType, &desc);
+  hr = ConvertMFTypeToDXVAType(aInputType, &desc);
   NS_ENSURE_TRUE(SUCCEEDED(hr), false);
   return CanCreateDecoder(desc, aFramerate);
 }
 
 D3D9DXVA2Manager::D3D9DXVA2Manager() { MOZ_COUNT_CTOR(D3D9DXVA2Manager); }
 
 D3D9DXVA2Manager::~D3D9DXVA2Manager() { MOZ_COUNT_DTOR(D3D9DXVA2Manager); }
 
--- a/dom/media/platforms/wmf/WMFVideoMFTManager.cpp
+++ b/dom/media/platforms/wmf/WMFVideoMFTManager.cpp
@@ -521,28 +521,38 @@ WMFVideoMFTManager::SetDecoderMediaTypes
   hr = inputType->SetUINT32(MF_MT_INTERLACE_MODE, MFVideoInterlace_Progressive);
   NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
 
   hr = MFSetAttributeSize(inputType, MF_MT_FRAME_SIZE,
                           mVideoInfo.ImageRect().width,
                           mVideoInfo.ImageRect().height);
   NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
 
+  UINT32 fpsDenominator = 1000;
+  UINT32 fpsNumerator = static_cast<uint32_t>(mFramerate * fpsDenominator);
+  hr = MFSetAttributeRatio(inputType, MF_MT_FRAME_RATE, fpsNumerator,
+                           fpsDenominator);
+  NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
+
   RefPtr<IMFMediaType> outputType;
   hr = wmf::MFCreateMediaType(getter_AddRefs(outputType));
   NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
 
   hr = outputType->SetGUID(MF_MT_MAJOR_TYPE, MFMediaType_Video);
   NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
 
   hr = MFSetAttributeSize(outputType, MF_MT_FRAME_SIZE,
                           mVideoInfo.ImageRect().width,
                           mVideoInfo.ImageRect().height);
   NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
 
+  hr = MFSetAttributeRatio(outputType, MF_MT_FRAME_RATE, fpsNumerator,
+                           fpsDenominator);
+  NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
+
   GUID outputSubType = mUseHwAccel ? MFVideoFormat_NV12 : MFVideoFormat_YV12;
   hr = outputType->SetGUID(MF_MT_SUBTYPE, outputSubType);
   NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
 
   if (mNoCopyNV12Texture) {
     RefPtr<IMFAttributes> attr(mDecoder->GetOutputStreamAttributes());
     if (attr) {
       hr = attr->SetUINT32(MF_SA_D3D11_SHARED_WITHOUT_MUTEX, TRUE);
@@ -985,19 +995,54 @@ bool WMFVideoMFTManager::IsHardwareAccel
     nsACString& aFailureReason) const {
   aFailureReason = mDXVAFailureReason;
   return mDecoder && mUseHwAccel;
 }
 
 nsCString WMFVideoMFTManager::GetDescriptionName() const {
   nsCString failureReason;
   bool hw = IsHardwareAccelerated(failureReason);
-  return nsPrintfCString("wmf %s codec %s video decoder - %s",
+
+  const char* formatName = [&]() {
+    if (!mDecoder) {
+      return "not initialized";
+    }
+    GUID format = mDecoder->GetOutputMediaSubType();
+    if (format == MFVideoFormat_NV12) {
+      if (!gfx::DeviceManagerDx::Get()->CanUseNV12()) {
+        return "nv12->argb32";
+      }
+      return "nv12";
+    }
+    if (format == MFVideoFormat_P010) {
+      if (!gfx::DeviceManagerDx::Get()->CanUseP010()) {
+        return "p010->argb32";
+      }
+      return "p010";
+    }
+    if (format == MFVideoFormat_P016) {
+      if (!gfx::DeviceManagerDx::Get()->CanUseP016()) {
+        return "p016->argb32";
+      }
+      return "p016";
+    }
+    if (format == MFVideoFormat_YV12) {
+      return "yv12";
+    }
+    return "unknown";
+  }();
+
+  const char* dxvaName = [&]() {
+    if (!mDXVA2Manager) {
+      return "no DXVA";
+    }
+    if (mDXVA2Manager->IsD3D11()) {
+      return "D3D11";
+    }
+    return "D3D9";
+  }();
+
+  return nsPrintfCString("wmf %s codec %s video decoder - %s, %s",
                          WMFDecoderModule::StreamTypeToString(mStreamType),
-                         hw ? "hardware" : "software",
-                         hw ? StaticPrefs::media_wmf_use_nv12_format() &&
-                                      gfx::DeviceManagerDx::Get()->CanUseNV12()
-                                  ? "nv12"
-                                  : "rgba32"
-                            : "yuv420");
+                         hw ? "hardware" : "software", dxvaName, formatName);
 }
 
 }  // namespace mozilla
--- a/layout/base/tests/file_zoom_restore_bfcache.html
+++ b/layout/base/tests/file_zoom_restore_bfcache.html
@@ -45,27 +45,35 @@
         case "case1click": {
           document.querySelector("a").click();
           // We are opening file_zoom_restore_bfcache.html?2, so the current
           // page is going into bfcache
           break;
         }
         case "case3sendData": {
           // We came back from bfcache
-          function waitUntilZoomLevelRestored() {
-            // Zoom level is updated asynchronously when bfcache lives in the
-            // parent process.
-            if (window.devicePixelRatio == 2) {
-              bc.postMessage({command: "case3data", devicePixelRatio: window.devicePixelRatio,
-              frameDevicePixelRatio: document.querySelector("iframe").contentWindow.devicePixelRatio});
-              return;
+          SpecialPowers.spawnChrome([], () => {
+            // We use FullZoom to set the zoom level in the parent, but if FullZoom is not
+            // available then that will fail. So we don't wait here for the devicePixelRatio
+            // to change if FullZoom is not available, and test_zoom_restore_bfcache.html
+            // will mark this test as todo.
+            return "FullZoom" in this.browsingContext.embedderElement.ownerGlobal;
+          }).then((hasFullZoom) => {
+            function waitUntilZoomLevelRestored() {
+              // Zoom level is updated asynchronously when bfcache lives in the
+              // parent process.
+              if (!hasFullZoom || window.devicePixelRatio == 2) {
+                bc.postMessage({command: "case3data", devicePixelRatio: window.devicePixelRatio,
+                frameDevicePixelRatio: document.querySelector("iframe").contentWindow.devicePixelRatio});
+                return;
+              }
+              window.requestAnimationFrame(waitUntilZoomLevelRestored);
             }
             window.requestAnimationFrame(waitUntilZoomLevelRestored);
-          }
-          window.requestAnimationFrame(waitUntilZoomLevelRestored);
+          });
           break;
         }
         case "close": {
           SpecialPowers.spawnChrome([], () => {
             const FullZoom = this.browsingContext.embedderElement.ownerGlobal.FullZoom;
             FullZoom.setZoom(1.0);
           });
           bc.postMessage({command: "closed"});
--- a/layout/base/tests/test_zoom_restore_bfcache.html
+++ b/layout/base/tests/test_zoom_restore_bfcache.html
@@ -47,25 +47,32 @@ bc.onmessage = (msgEvent) => {
       is(msg.devicePixelRatio, originalDPR, "No zoom");
       bc.postMessage({command: "case1click"});
       // The end of case 1
       break;
     }
     case "case3data": {
       is(loadCount, 2, "Case 3");
       is(msg.devicePixelRatio, originalDPR * 2, "Should preserve zoom when restored");
-      if (SpecialPowers.Services.appinfo.fissionAutostart) {
-        // When bfcache lives in the parent process, we get a proper zoom level
-        // update on the browsing context.
-        is(msg.frameDevicePixelRatio, originalDPR * 2, "Should preserve zoom on frames too");
-      } else {
-        todo_is(msg.frameDevicePixelRatio, originalDPR * 2, "Should preserve zoom on frames too");
-      }
-      bc.postMessage({command: "close"});
-      // Now we wait for "closed"
+      SpecialPowers.spawnChrome([], () => {
+        // We use FullZoom in file_zoom_restore_bfcache.html to set the zoom level in the
+        // parent, but if FullZoom is not available then that will fail. So check it here
+        // and mark the test as todo if it's not available.
+        return "FullZoom" in this.browsingContext.top.embedderElement.ownerGlobal;
+      }).then((hasFullZoom) => {
+        if (SpecialPowers.Services.appinfo.sessionHistoryInParent && hasFullZoom) {
+          // When bfcache lives in the parent process, we get a proper zoom level
+          // update on the browsing context.
+          is(msg.frameDevicePixelRatio, originalDPR * 2, "Should preserve zoom on frames too");
+        } else {
+          todo_is(msg.frameDevicePixelRatio, originalDPR * 2, "Should preserve zoom on frames too");
+        }
+        bc.postMessage({command: "close"});
+        // Now we wait for "closed"
+      });
       break;
     }
     case "closed": {
       is(loadCount, 2, "Case 3");
       bc.close();
       SimpleTest.finish();
       break;
     }
--- a/netwerk/base/LoadTainting.h
+++ b/netwerk/base/LoadTainting.h
@@ -19,22 +19,13 @@ namespace mozilla {
 // Roughly the tainting means:
 //
 //  * Basic: the request resulted in a same-origin or non-http load
 //  * CORS: the request resulted in a cross-origin load with CORS headers
 //  * Opaque: the request resulted in a cross-origin load without CORS headers
 //
 // The enumeration is purposefully designed such that more restrictive tainting
 // corresponds to a higher integral value.
-//
-// NOTE: Checking the tainting is not currently adequate.  You *must* still
-//       check the final URL and CORS mode on the channel.
-//
-// These values are currently only set on the channel LoadInfo when the request
-// was initiated through fetch() or when a service worker interception occurs.
-// In the future we should set the tainting value within necko so that it is
-// consistently applied.  Once that is done consumers can replace checks against
-// the final URL and CORS mode with checks against tainting.
 enum class LoadTainting : uint8_t { Basic = 0, CORS = 1, Opaque = 2 };
 
 }  // namespace mozilla
 
 #endif  // mozilla_LoadTainting_h
--- a/testing/parse_build_tests_ccov.py
+++ b/testing/parse_build_tests_ccov.py
@@ -8,17 +8,16 @@ from __future__ import absolute_import
 import sys
 import os
 import pathlib
 import shutil
 import subprocess
 import tempfile
 import zipfile
 import buildconfig
-from mozbuild import shellutil
 
 
 def main():
     if not buildconfig.substs.get("MOZ_CODE_COVERAGE") or not buildconfig.substs.get(
         "MOZ_RUST_TESTS"
     ):
         return
 
@@ -32,44 +31,16 @@ def main():
         grcov_path,
         "-t",
         "lcov",
         "-p",
         buildconfig.topsrcdir,
         buildconfig.topobjdir,
     ]
 
-    # We want to ignore system headers in our reports.
-    if buildconfig.substs["OS_TARGET"] == "WINNT":
-        # We use WINDOWSSDKDIR to find the directory holding the system headers on Windows.
-        windows_sdk_dir = None
-        config_opts = shellutil.split(buildconfig.substs["MOZ_CONFIGURE_OPTIONS"])
-        for opt in config_opts:
-            if opt.startswith("WINDOWSSDKDIR="):
-                windows_sdk_dir = opt[len("WINDOWSSDKDIR=") :]
-                break
-
-        assert (
-            windows_sdk_dir is not None
-        ), "WINDOWSSDKDIR should be in MOZ_CONFIGURE_OPTIONS"
-
-        ignore_dir_abs = pathlib.Path(windows_sdk_dir).parent
-
-        # globs passed to grcov must exist and must be relative to the source directory.
-        # If it doesn't exist, maybe it has moved and we need to update the paths above.
-        # If it is no longer relative to the source directory, we no longer need to ignore it and
-        # this code can be removed.
-        assert ignore_dir_abs.is_dir(), f"{ignore_dir_abs} is not a directory"
-        ignore_dir_rel = ignore_dir_abs.relative_to(buildconfig.topsrcdir)
-
-        grcov_command += [
-            "--ignore",
-            f"{ignore_dir_rel}*",
-        ]
-
     if buildconfig.substs["OS_TARGET"] == "Linux":
         gcc_dir = os.path.join(os.environ["MOZ_FETCHES_DIR"], "gcc")
         if "LD_LIBRARY_PATH" in os.environ:
             os.environ["LD_LIBRARY_PATH"] = "{}/lib64/:{}".format(
                 gcc_dir, os.environ["LD_LIBRARY_PATH"]
             )
         else:
             os.environ["LD_LIBRARY_PATH"] = "{}/lib64/".format(gcc_dir)
--- a/toolkit/content/tests/chrome/findbar_entireword_window.xhtml
+++ b/toolkit/content/tests/chrome/findbar_entireword_window.xhtml
@@ -116,25 +116,21 @@
         window.close();
         SimpleTest.finish();
       });
     }
 
     async function startTestWithBrowser(testName, browserId) {
       info("Starting test with browser '" + browserId + "'");
       gBrowser = document.getElementById(browserId);
-      gFindBar.browser = gBrowser;
 
-      let promise = ContentTask.spawn(gBrowser, null, () =>
-        new Promise(resolve => {
-          addEventListener("DOMContentLoaded", () => resolve(), { once: true });
-        })
-      );
+      let promise = BrowserTestUtils.browserLoaded(gBrowser);
       BrowserTestUtils.loadURI(gBrowser, kBaseURL + "/sample_entireword_" + testName + ".html");
       await promise;
+      gFindBar.browser = gBrowser;
       await onDocumentLoaded(testName);
     }
 
     async function onDocumentLoaded(testName) {
       let suite = kTests[testName];
       await testSimpleEntireWord(suite.testSimpleEntireWord);
       await testCaseSensitive(suite.testCaseSensitive);
       await testWordBreakChars(suite.testWordBreakChars);
--- a/toolkit/content/tests/chrome/findbar_events_window.xhtml
+++ b/toolkit/content/tests/chrome/findbar_events_window.xhtml
@@ -39,21 +39,21 @@
         window.close();
         SimpleTest.finish();
       });
     }
 
     async function startTestWithBrowser(browserId) {
       info("Starting test with browser '" + browserId + "'");
       gBrowser = document.getElementById(browserId);
-      gFindBar.browser = gBrowser;
       const url = "data:text/html,hello there";
       let promise = BrowserTestUtils.browserLoaded(gBrowser, false, url);
       BrowserTestUtils.loadURI(gBrowser, url);
       await promise;
+      gFindBar.browser = gBrowser;
       await onDocumentLoaded();
     }
 
     async function onDocumentLoaded() {
       gFindBar.open();
       gFindBar.onFindCommand();
 
       await testFind();
--- a/toolkit/content/tests/chrome/findbar_window.xhtml
+++ b/toolkit/content/tests/chrome/findbar_window.xhtml
@@ -67,27 +67,27 @@
         window.close();
         SimpleTest.finish();
       });
     }
 
     async function startTestWithBrowser(browserId) {
       info("Starting test with browser '" + browserId + "'");
       gBrowser = document.getElementById(browserId);
-      gFindBar.browser = gBrowser;
 
       // Tests delays the loading of a document for one second.
       await new Promise(resolve => setTimeout(resolve, 1000));
 
       let promise = BrowserTestUtils.browserLoaded(gBrowser);
       BrowserTestUtils.loadURI(gBrowser, "data:text/html;charset=utf-8,<h2 id='h2'>" + SEARCH_TEXT +
         "</h2><h2><a href='" + SAMPLE_URL + "'>Link Test</a></h2><input id='text' type='text' value='" +
         SAMPLE_TEXT + "'></input><input id='button' type='button'></input><img id='img' width='50' height='50'/>",
         { triggeringPrincipal: window.document.nodePrincipal });
       await promise;
+      gFindBar.browser = gBrowser;
       await onDocumentLoaded();
     }
 
     async function onDocumentLoaded() {
       await testNormalFind();
       gFindBar.close();
       ok(gFindBar.hidden, "Failed to close findbar after testNormalFind");
       await openFindbar();