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 { transform: translateZ(0); } | 6 canvas { transform: translateZ(0); } |
7 img, canvas { margin: 5px; width: 48% } | 7 img, canvas { margin: 5px; width: 48% } |
8 </style> | 8 </style> |
9 | 9 |
10 <body style="overflow: hidden"> | 10 <body style="overflow: hidden"> |
11 <!-- The _blue_ sector of the <img> image should be at 12 o'clock. --> | 11 <!-- The _blue_ sector of the <img> image should be at 12 o'clock. --> |
12 <img> | 12 <img> |
13 <!-- The red sector of the <canvas> image should be at 12 o'clock. --> | 13 <!-- The red sector of the <canvas> image should be at 12 o'clock. --> |
14 <canvas></canvas> | 14 <canvas></canvas> |
15 </body> | 15 </body> |
16 | 16 |
17 <script> | 17 <script> |
18 window.onload = function() { | 18 window.onload = function() { |
19 var image = document.querySelector('img'); | 19 var image = document.querySelector('img'); |
20 | 20 |
21 image.onload = function() { | 21 image.onload = function() { |
22 runAfterLayoutAndPaint(window.testRunner ? changeColorProfile : profileChang
ed); | 22 runAfterLayoutAndPaint(window.testRunner ? changeColorProfile : profileChang
ed); |
23 }; | 23 }; |
24 | 24 |
25 image.src = 'resources/red-at-12-oclock-with-color-profile.jpg'; | 25 image.src = 'resources/red-at-12-oclock-with-color-profile.jpg'; |
26 }; | 26 }; |
27 | 27 |
28 function changeColorProfile() { | 28 function changeColorProfile() { |
29 window.testRunner.setColorProfile('whacked', profileChanged); | 29 window.testRunner.setColorProfile('colorSpin', profileChanged); |
30 } | 30 } |
31 | 31 |
32 function profileChanged() { | 32 function profileChanged() { |
33 setTimeout(drawImagePatternToCanvas, 0); | 33 setTimeout(drawImagePatternToCanvas, 0); |
34 } | 34 } |
35 | 35 |
36 function drawImagePatternToCanvas() { | 36 function drawImagePatternToCanvas() { |
37 var canvas = document.querySelector('canvas'); | 37 var canvas = document.querySelector('canvas'); |
38 var ctx = canvas.getContext('2d'); | 38 var ctx = canvas.getContext('2d'); |
39 var pattern = ctx.createPattern(document.querySelector('img'), null); | 39 var pattern = ctx.createPattern(document.querySelector('img'), null); |
40 var scale = 0.1870; | 40 var scale = 0.1870; |
41 | 41 |
42 ctx.clearRect(0, 0, canvas.width = 300, canvas.height = 300); | 42 ctx.clearRect(0, 0, canvas.width = 300, canvas.height = 300); |
43 ctx.save(); | 43 ctx.save(); |
44 ctx.scale(scale, scale); | 44 ctx.scale(scale, scale); |
45 ctx.fillStyle = pattern; | 45 ctx.fillStyle = pattern; |
46 ctx.fillRect(0, 0, canvas.width / scale, canvas.height / scale); | 46 ctx.fillRect(0, 0, canvas.width / scale, canvas.height / scale); |
47 ctx.restore(); | 47 ctx.restore(); |
48 | 48 |
49 if (window.testRunner) | 49 if (window.testRunner) |
50 window.testRunner.notifyDone(); | 50 window.testRunner.notifyDone(); |
51 } | 51 } |
52 | 52 |
53 if (window.internals) | |
54 internals.settings.setImageColorProfilesEnabled(true); | |
55 | |
56 if (window.testRunner) { | 53 if (window.testRunner) { |
57 testRunner.dumpAsTextWithPixelResults(); | 54 testRunner.dumpAsTextWithPixelResults(); |
58 testRunner.waitUntilDone(); | 55 testRunner.waitUntilDone(); |
59 } | 56 } |
60 </script> | 57 </script> |
61 </html> | 58 </html> |
OLD | NEW |