toolkit/components/thumbnails/test/browser_thumbnails_bg_crash_during_capture.js

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     1 /* Any copyright is dedicated to the Public Domain.
     2  * http://creativecommons.org/publicdomain/zero/1.0/ */
     4 function runTests() {
     5   let crashObserver = bgAddCrashObserver();
     7   // make a good capture first - this ensures we have the <browser>
     8   let goodUrl = bgTestPageURL();
     9   yield bgCapture(goodUrl);
    10   ok(thumbnailExists(goodUrl), "Thumbnail should be cached after capture");
    11   removeThumbnail(goodUrl);
    13   // inject our content script.
    14   let mm = bgInjectCrashContentScript();
    16   // queue up 2 captures - the first has a wait, so this is the one that
    17   // will die.  The second one should immediately capture after the crash.
    18   let waitUrl = bgTestPageURL({ wait: 30000 });
    19   let sawWaitUrlCapture = false;
    20   bgCapture(waitUrl, { onDone: () => {
    21     sawWaitUrlCapture = true;
    22     ok(!thumbnailExists(waitUrl), "Thumbnail should not have been saved due to the crash");
    23   }});
    24   bgCapture(goodUrl, { onDone: () => {
    25     ok(sawWaitUrlCapture, "waitUrl capture should have finished first");
    26     ok(thumbnailExists(goodUrl), "We should have recovered and completed the 2nd capture after the crash");
    27     removeThumbnail(goodUrl);
    28     // Test done.
    29     ok(crashObserver.crashed, "Saw a crash from this test");
    30     next();
    31   }});
    33   info("Crashing the thumbnail content process.");
    34   mm.sendAsyncMessage("thumbnails-test:crash");
    35   yield true;
    36 }

mercurial