OLD | NEW |
| (Empty) |
1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> | |
2 <html> | |
3 <head> | |
4 <script src="../../resources/js-test.js"></script> | |
5 </head> | |
6 <body> | |
7 <script> | |
8 | |
9 description("Test OffscreenCanvas transferable with exception cases."); | |
10 window.jsTestIsAsync = true; | |
11 | |
12 var worker = new Worker('./resources/OffscreenCanvas-transferable.js'); | |
13 | |
14 var width = 50; | |
15 var height = 50; | |
16 var offscreenCanvas1 = new OffscreenCanvas(width, height); | |
17 | |
18 var ctx; | |
19 shouldNotThrow("ctx = offscreenCanvas1.getContext('2d')"); | |
20 shouldBeType("ctx", "OffscreenCanvasRenderingContext2D"); | |
21 try { | |
22 worker.postMessage({data: offscreenCanvas1}, [offscreenCanvas1]); | |
23 testFailed("Transfer an offscreenCanvas with a context succeed, expected to
fail"); | |
24 } catch(e) { | |
25 testPassed("Transfer an offscreenCanvas with a context should throw an excep
tion: " + e); | |
26 } | |
27 | |
28 var offscreenCanvas2 = new OffscreenCanvas(width, height); | |
29 worker.postMessage({data: offscreenCanvas2}, [offscreenCanvas2]); | |
30 try { | |
31 var image = offscreenCanvas2.transferToImageBitmap(); | |
32 testFailed("Calling transferToImageBitmap from a neutered offscreenCanvas su
cceed, expected to fail"); | |
33 } catch(e) { | |
34 testPassed("Calling transferToImageBitmap from a neutered offscreenCanvas sh
ould throw an exception: " + e); | |
35 } | |
36 | |
37 try { | |
38 worker.postMessage({data: offscreenCanvas2}, [offscreenCanvas2]); | |
39 testFailed("Transfer a neutered offscreenCanvas succeed, expected to fail"); | |
40 } catch(e) { | |
41 testPassed("Transfer a neutered offscreenCanvas should throw an exception: "
+ e); | |
42 } | |
43 | |
44 try { | |
45 var ctx = offscreenCanvas2.getContext('2d'); | |
46 testFailed("Calling getContext('2d') from a neutered offscreenCanvas succeed
, expected to fail"); | |
47 } catch(e) { | |
48 testPassed("Calling getContext('2d') from a neutered offscreenCanvas should
throw an exception: " + e); | |
49 } | |
50 | |
51 finishJSTest(); | |
52 </script> | |
53 </body> | |
54 </html> | |
OLD | NEW |