Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 <script src="../../resources/testharness.js"></script> | |
| 2 <script src="../../resources/testharnessreport.js"></script> | |
| 3 <script type = 'text/javascript'> | |
| 4 // In WebKit Layout Tests, flag "--enable-threaded-compositing", which is | |
|
Justin Novosad
2017/01/06 15:49:21
nit: WebKit -> blink
| |
| 5 // essential for idle task running, is not turned on by default. This makes | |
| 6 // it convenient to test the case when CanvasAsyncBlobCreator is idling for | |
| 7 // too long and switching to forcing encoding in a normal task. | |
| 8 // Passing this test means that the enforcing mechanism in | |
| 9 // CanvasAsyncBlobCreator for OffscreenCanvas case is working as expected. | |
| 10 var w = 4; | |
| 11 var h = 4; | |
| 12 | |
| 13 var newImg = new Image(); | |
| 14 function imageLoaded() { | |
| 15 var canvas2 = document.createElement("canvas"); | |
| 16 canvas2.width = w; | |
| 17 canvas2.height = h; | |
| 18 var ctx2 = canvas2.getContext("2d"); | |
| 19 ctx2.drawImage(newImg, 0, 0, w, h); | |
| 20 | |
| 21 var imageData = ctx2.getImageData(0, 0, w, h).data; | |
| 22 assert_equals(imageData[0], 255); | |
| 23 assert_equals(imageData[1], 1); | |
| 24 assert_equals(imageData[2], 2); | |
| 25 assert_equals(imageData[3], 255); | |
| 26 testImageFromOffscreen.done(); | |
| 27 } | |
| 28 | |
| 29 var testImageFromOffscreen = async_test( | |
| 30 "Check if the image loaded from blob returned by " + | |
| 31 "OffscreenCanvas.convertToBlob() have expected image data values."); | |
| 32 | |
| 33 testImageFromOffscreen.step(function() { | |
| 34 newImg.onload = testImageFromOffscreen.step_func(imageLoaded); | |
| 35 | |
| 36 var offscreenCanvas = new OffscreenCanvas(w, h); | |
| 37 var ctx = offscreenCanvas.getContext("2d"); | |
| 38 ctx.fillStyle = "#FF0102"; | |
| 39 ctx.fillRect(0, 0, w, h); | |
| 40 | |
| 41 offscreenCanvas.convertToBlob().then(function(blob) { | |
| 42 newImg.src = URL.createObjectURL(blob); | |
| 43 }); | |
| 44 }); | |
| 45 | |
| 46 </script> | |
| OLD | NEW |