1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/toolkit/components/thumbnails/test/browser_thumbnails_bg_crash_during_capture.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,36 @@ 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 + // queue up 2 captures - the first has a wait, so this is the one that 1.20 + // will die. The second one should immediately capture after the crash. 1.21 + let waitUrl = bgTestPageURL({ wait: 30000 }); 1.22 + let sawWaitUrlCapture = false; 1.23 + bgCapture(waitUrl, { onDone: () => { 1.24 + sawWaitUrlCapture = true; 1.25 + ok(!thumbnailExists(waitUrl), "Thumbnail should not have been saved due to the crash"); 1.26 + }}); 1.27 + bgCapture(goodUrl, { onDone: () => { 1.28 + ok(sawWaitUrlCapture, "waitUrl capture should have finished first"); 1.29 + ok(thumbnailExists(goodUrl), "We should have recovered and completed the 2nd capture after the crash"); 1.30 + removeThumbnail(goodUrl); 1.31 + // Test done. 1.32 + ok(crashObserver.crashed, "Saw a crash from this test"); 1.33 + next(); 1.34 + }}); 1.35 + 1.36 + info("Crashing the thumbnail content process."); 1.37 + mm.sendAsyncMessage("thumbnails-test:crash"); 1.38 + yield true; 1.39 +}