| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <html> | 2 <html> |
| 3 <script src="../resources/run-after-layout-and-paint.js"></script> | 3 <script src="../resources/run-after-layout-and-paint.js"></script> |
| 4 | 4 |
| 5 <style> | 5 <style> |
| 6 canvas, img { margin: 5px; width: 380px } | 6 canvas, img { margin: 5px; width: 380px } |
| 7 </style> | 7 </style> |
| 8 | 8 |
| 9 <body style="overflow: hidden"> | 9 <body style="overflow: hidden"> |
| 10 <!-- The _blue_ sector of the <img> image should be at 12 o'clock. --> | 10 <!-- The _blue_ sector of the <img> image should be at 12 o'clock. --> |
| 11 <img> | 11 <img> |
| 12 <!-- The red sector of the <canvas> image should be at 12 o'clock. --> | 12 <!-- The red sector of the <canvas> image should be at 12 o'clock. --> |
| 13 <canvas></canvas> | 13 <canvas></canvas> |
| 14 </body> | 14 </body> |
| 15 | 15 |
| 16 <script> | 16 <script> |
| 17 window.onload = function() { | 17 window.onload = function() { |
| 18 var image = document.querySelector('img'); | 18 var image = document.querySelector('img'); |
| 19 | 19 |
| 20 image.onload = function() { | 20 image.onload = function() { |
| 21 runAfterLayoutAndPaint(window.testRunner ? changeColorProfile : profileChang
ed); | 21 runAfterLayoutAndPaint(drawImageToCanvas); |
| 22 }; | 22 }; |
| 23 | 23 |
| 24 image.src = 'resources/red-at-12-oclock-with-color-profile.jpg'; | 24 image.src = 'resources/red-at-12-oclock-with-color-profile.jpg'; |
| 25 }; | 25 }; |
| 26 | 26 |
| 27 function changeColorProfile() { | |
| 28 window.testRunner.setColorProfile('sRGB', profileChanged); | |
| 29 } | |
| 30 | |
| 31 function profileChanged() { | |
| 32 setTimeout(drawImageToCanvas, 0); | |
| 33 } | |
| 34 | |
| 35 function drawImageToCanvas() { | 27 function drawImageToCanvas() { |
| 36 var canvas = document.querySelector('canvas'); | 28 var canvas = document.querySelector('canvas'); |
| 37 canvas.getContext('2d').clearRect(0, 0, canvas.width = 380, canvas.height = 38
0); | 29 canvas.getContext('2d').clearRect(0, 0, canvas.width = 380, canvas.height = 38
0); |
| 38 | 30 |
| 39 var image = document.querySelector('img'); | 31 var image = document.querySelector('img'); |
| 40 canvas.getContext('2d').drawImage(image, 0, 0, canvas.width, canvas.height); | 32 canvas.getContext('2d').drawImage(image, 0, 0, canvas.width, canvas.height); |
| 41 | 33 |
| 42 if (window.testRunner) | 34 if (window.testRunner) |
| 43 window.testRunner.setColorProfile('colorSpin', done); | 35 window.testRunner.setColorProfile('colorSpin', done); |
| 44 } | 36 } |
| 45 | 37 |
| 46 function done() { | 38 function done() { |
| 47 setTimeout(function() { window.testRunner.notifyDone() }, 0); | 39 setTimeout(function() { window.testRunner.notifyDone() }, 0); |
| 48 } | 40 } |
| 49 | 41 |
| 50 if (window.testRunner) { | 42 if (window.testRunner) { |
| 51 testRunner.dumpAsTextWithPixelResults(); | 43 testRunner.dumpAsTextWithPixelResults(); |
| 52 testRunner.waitUntilDone(); | 44 testRunner.waitUntilDone(); |
| 53 } | 45 } |
| 54 </script> | 46 </script> |
| 55 </html> | 47 </html> |
| OLD | NEW |