1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/toolkit/components/thumbnails/test/browser_thumbnails_bg_crash_while_idle.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,38 @@ 1.4 +/* Any copyright is dedicated to the Public Domain. 1.5 + * http://creativecommons.org/publicdomain/zero/1.0/ */ 1.6 + 1.7 +function runTests() { 1.8 + let crashObserver = bgAddCrashObserver(); 1.9 + 1.10 + // make a good capture first - this ensures we have the <browser> 1.11 + let goodUrl = bgTestPageURL(); 1.12 + yield bgCapture(goodUrl); 1.13 + ok(thumbnailExists(goodUrl), "Thumbnail should be cached after capture"); 1.14 + removeThumbnail(goodUrl); 1.15 + 1.16 + // inject our content script. 1.17 + let mm = bgInjectCrashContentScript(); 1.18 + 1.19 + // the observer for the crashing process is basically async, so it's hard 1.20 + // to know when the <browser> has actually seen it. Easist is to just add 1.21 + // our own observer. 1.22 + Services.obs.addObserver(function onCrash() { 1.23 + Services.obs.removeObserver(onCrash, "oop-frameloader-crashed"); 1.24 + // spin the event loop to ensure the BPT observer was called. 1.25 + executeSoon(function() { 1.26 + // Now queue another capture and ensure it recovers. 1.27 + bgCapture(goodUrl, { onDone: () => { 1.28 + ok(thumbnailExists(goodUrl), "We should have recovered and handled new capture requests"); 1.29 + removeThumbnail(goodUrl); 1.30 + // Test done. 1.31 + ok(crashObserver.crashed, "Saw a crash from this test"); 1.32 + next(); 1.33 + }}); 1.34 + }); 1.35 + } , "oop-frameloader-crashed", false); 1.36 + 1.37 + // Nothing is pending - crash the process. 1.38 + info("Crashing the thumbnail content process."); 1.39 + mm.sendAsyncMessage("thumbnails-test:crash"); 1.40 + yield true; 1.41 +}