OLD | NEW |
(Empty) | |
| 1 // DO NOT EDIT! This test has been generated by tools/gentest.py. |
| 2 // OffscreenCanvas test in a worker:2d.drawImage.9arg.destpos |
| 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, 0, 0, 100, 50, 0, 0, 100, 50); |
| 37 ctx.drawImage(response1, 0, 0, 100, 50, -100, 0, 100, 50); |
| 38 ctx.drawImage(response1, 0, 0, 100, 50, 100, 0, 100, 50); |
| 39 ctx.drawImage(response1, 0, 0, 100, 50, 0, -50, 100, 50); |
| 40 ctx.drawImage(response1, 0, 0, 100, 50, 0, 50, 100, 50); |
| 41 _assertPixelApprox(offscreenCanvas, 0,0, 0,255,0,255, "0,0", "0,255,0,255",
2); |
| 42 _assertPixelApprox(offscreenCanvas, 99,0, 0,255,0,255, "99,0", "0,255,0,255"
, 2); |
| 43 _assertPixelApprox(offscreenCanvas, 0,49, 0,255,0,255, "0,49", "0,255,0,255"
, 2); |
| 44 _assertPixelApprox(offscreenCanvas, 99,49, 0,255,0,255, "99,49", "0,255,0,25
5", 2); |
| 45 }); |
| 46 |
| 47 t.done(); |
| 48 |
| 49 }); |
| 50 done(); |
OLD | NEW |