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

michael@0 1 /* Any copyright is dedicated to the Public Domain.
michael@0 2 * http://creativecommons.org/publicdomain/zero/1.0/ */
michael@0 3
michael@0 4 function runTests() {
michael@0 5 let crashObserver = bgAddCrashObserver();
michael@0 6
michael@0 7 // make a good capture first - this ensures we have the <browser>
michael@0 8 let goodUrl = bgTestPageURL();
michael@0 9 yield bgCapture(goodUrl);
michael@0 10 ok(thumbnailExists(goodUrl), "Thumbnail should be cached after capture");
michael@0 11 removeThumbnail(goodUrl);
michael@0 12
michael@0 13 // inject our content script.
michael@0 14 let mm = bgInjectCrashContentScript();
michael@0 15
michael@0 16 // the observer for the crashing process is basically async, so it's hard
michael@0 17 // to know when the <browser> has actually seen it. Easist is to just add
michael@0 18 // our own observer.
michael@0 19 Services.obs.addObserver(function onCrash() {
michael@0 20 Services.obs.removeObserver(onCrash, "oop-frameloader-crashed");
michael@0 21 // spin the event loop to ensure the BPT observer was called.
michael@0 22 executeSoon(function() {
michael@0 23 // Now queue another capture and ensure it recovers.
michael@0 24 bgCapture(goodUrl, { onDone: () => {
michael@0 25 ok(thumbnailExists(goodUrl), "We should have recovered and handled new capture requests");
michael@0 26 removeThumbnail(goodUrl);
michael@0 27 // Test done.
michael@0 28 ok(crashObserver.crashed, "Saw a crash from this test");
michael@0 29 next();
michael@0 30 }});
michael@0 31 });
michael@0 32 } , "oop-frameloader-crashed", false);
michael@0 33
michael@0 34 // Nothing is pending - crash the process.
michael@0 35 info("Crashing the thumbnail content process.");
michael@0 36 mm.sendAsyncMessage("thumbnails-test:crash");
michael@0 37 yield true;
michael@0 38 }

mercurial