Bug 1595130 - Explicitly catch Promise rejection instead of using Assert.rejects for browser_thumbnails_bg_crash_during_capture.js. r=Mardak
authorMike Conley <mconley@mozilla.com>
Mon, 18 Nov 2019 15:25:29 +0000
changeset 502420 a52581ac4a9dd02c9ae085f428db1e1579a60513
parent 502419 4ddb439ba4c1f14314e3707830ee7f71a048b37b
child 502421 09bdf1773bfd1b61d928938fe43b00834f8c3e85
push id114172
push userdluca@mozilla.com
push dateTue, 19 Nov 2019 11:31:10 +0000
treeherdermozilla-inbound@b5c5ba07d3db [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersMardak
bugs1595130, 1591495
milestone72.0a1
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
Bug 1595130 - Explicitly catch Promise rejection instead of using Assert.rejects for browser_thumbnails_bg_crash_during_capture.js. r=Mardak It seems that if we set up a Promise that we expect to reject, and then on a later tick of the event loop, use `await Assert.rejects(theRejectingPromise)`, then we can get into situations where the Promise is rejected _before_ we hit the Assert.rejects, and so the test framework will record that rejection as having been "unhandled". This patch reverts browser_thumbnails_bg_crash_during_capture.js back slightly to how it ran before bug 1591495 landed, so that the Promise rejection is caught explicitly. Differential Revision: https://phabricator.services.mozilla.com/D53225
toolkit/components/thumbnails/test/browser_thumbnails_bg_crash_during_capture.js
--- a/toolkit/components/thumbnails/test/browser_thumbnails_bg_crash_during_capture.js
+++ b/toolkit/components/thumbnails/test/browser_thumbnails_bg_crash_during_capture.js
@@ -27,22 +27,23 @@ add_task(async function thumbnails_bg_cr
       ok(
         thumbnailExists(goodUrl),
         "We should have recovered and completed the 2nd capture after the crash"
       );
       removeThumbnail(goodUrl);
     },
   });
 
-  let crashPromise = bgAddPageThumbObserver(waitUrl);
+  let crashPromise = bgAddPageThumbObserver(waitUrl).catch(err => {
+    ok(/page-thumbnail:error/.test(err), "Got the right kind of error");
+  });
   let capturePromise = bgAddPageThumbObserver(goodUrl);
 
   info("Crashing the thumbnail content process.");
   let crash = await BrowserTestUtils.crashFrame(
     BackgroundPageThumbs._thumbBrowser,
     false
   );
   ok(crash.CrashTime, "Saw a crash from this test");
 
-  await Assert.rejects(crashPromise, /page-thumbnail:error/);
-
+  await crashPromise;
   await Promise.all([failCapture, goodCapture, capturePromise]);
 });