toolkit/components/thumbnails/test/browser_thumbnails_bg_crash_while_idle.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   // the observer for the crashing process is basically async, so it's hard
    17   // to know when the <browser> has actually seen it.  Easist is to just add
    18   // our own observer.
    19   Services.obs.addObserver(function onCrash() {
    20     Services.obs.removeObserver(onCrash, "oop-frameloader-crashed");
    21     // spin the event loop to ensure the BPT observer was called.
    22     executeSoon(function() {
    23       // Now queue another capture and ensure it recovers.
    24       bgCapture(goodUrl, { onDone: () => {
    25         ok(thumbnailExists(goodUrl), "We should have recovered and handled new capture requests");
    26         removeThumbnail(goodUrl);
    27         // Test done.
    28         ok(crashObserver.crashed, "Saw a crash from this test");
    29         next();
    30       }});
    31     });
    32   } , "oop-frameloader-crashed", false);
    34   // Nothing is pending - crash the process.
    35   info("Crashing the thumbnail content process.");
    36   mm.sendAsyncMessage("thumbnails-test:crash");
    37   yield true;
    38 }

mercurial