toolkit/components/thumbnails/test/browser_thumbnails_bg_crash_during_capture.js

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:9a5e62c03503
1 /* Any copyright is dedicated to the Public Domain.
2 * http://creativecommons.org/publicdomain/zero/1.0/ */
3
4 function runTests() {
5 let crashObserver = bgAddCrashObserver();
6
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);
12
13 // inject our content script.
14 let mm = bgInjectCrashContentScript();
15
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 }});
32
33 info("Crashing the thumbnail content process.");
34 mm.sendAsyncMessage("thumbnails-test:crash");
35 yield true;
36 }

mercurial