| OLD | NEW |
| (Empty) |
| 1 // DO NOT EDIT! This test has been generated by tools/gentest.py. | |
| 2 // OffscreenCanvas test in a worker:2d.drawImage.5arg | |
| 3 // Description: | |
| 4 // Note: | |
| 5 | |
| 6 importScripts("/resources/testharness.js"); | |
| 7 importScripts("/common/canvas-tests.js"); | |
| 8 | |
| 9 var t = async_test(""); | |
| 10 t.step(function() { | |
| 11 | |
| 12 var offscreenCanvas = new OffscreenCanvas(100, 50); | |
| 13 var ctx = offscreenCanvas.getContext('2d'); | |
| 14 | |
| 15 ctx.fillStyle = '#f00'; | |
| 16 ctx.fillRect(0, 0, 100, 50); | |
| 17 var promise1 = new Promise(function(resolve, reject) { | |
| 18 var xhr = new XMLHttpRequest(); | |
| 19 xhr.open("GET", '/images/red.png'); | |
| 20 xhr.responseType = 'blob'; | |
| 21 xhr.send(); | |
| 22 xhr.onload = function() { | |
| 23 resolve(xhr.response); | |
| 24 }; | |
| 25 }); | |
| 26 var promise2 = new Promise(function(resolve, reject) { | |
| 27 var xhr = new XMLHttpRequest(); | |
| 28 xhr.open("GET", '/images/green.png'); | |
| 29 xhr.responseType = 'blob'; | |
| 30 xhr.send(); | |
| 31 xhr.onload = function() { | |
| 32 resolve(xhr.response); | |
| 33 }; | |
| 34 }); | |
| 35 Promise.all([promise1, promise2]).then(function(response1, response2) { | |
| 36 ctx.drawImage(response2, 50, 0, 50, 50); | |
| 37 ctx.drawImage(response1, 0, 0, 50, 50); | |
| 38 ctx.fillStyle = '#0f0'; | |
| 39 ctx.fillRect(0, 0, 50, 50); | |
| 40 _assertPixelApprox(offscreenCanvas, 0,0, 0,255,0,255, "0,0", "0,255,0,255",
2); | |
| 41 _assertPixelApprox(offscreenCanvas, 99,0, 0,255,0,255, "99,0", "0,255,0,255"
, 2); | |
| 42 _assertPixelApprox(offscreenCanvas, 0,49, 0,255,0,255, "0,49", "0,255,0,255"
, 2); | |
| 43 _assertPixelApprox(offscreenCanvas, 99,49, 0,255,0,255, "99,49", "0,255,0,25
5", 2); | |
| 44 }); | |
| 45 | |
| 46 t.done(); | |
| 47 | |
| 48 }); | |
| 49 done(); | |
| OLD | NEW |