| <!DOCTYPE html> |
| <html> |
| <script src="../resources/test-runner-paint-worklet.js"></script> |
| <style> |
| html, body { margin: 0; padding: 0; } |
| .container { |
| width: 187px; |
| height: 187px; |
| } |
| |
| #canvas-geometry { |
| background-image: paint(geometry); |
| } |
| </style> |
| <body> |
| <div id="canvas-geometry" class="container"></div> |
| |
| <script id="code" type="text/worklet"> |
| registerPaint('geometry', class { |
| paint(ctx, geom) { |
| // TODO(xidachen): Remove the |expected_size_mac_android| once |
| // --use-zoom-for-dsf is supported across all platforms. |
| var expected_size = Math.round(187 * 0.33 * devicePixelRatio) / (0.33 * devicePixelRatio); |
| var expected_size_mac_android = Math.round(187 * 0.33) / 0.33; |
| if ((Math.abs(geom.width - expected_size) < 0.001 && Math.abs(geom.height - expected_size) < 0.001) || |
| (Math.abs(geom.width - expected_size_mac_android) < 0.001 && Math.abs(geom.height - expected_size_mac_android) < 0.001)) |
| ctx.fillStyle = 'green'; |
| else |
| ctx.fillStyle = 'red'; |
| ctx.fillRect(0, 0, geom.width, geom.height); |
| } |
| }); |
| </script> |
| |
| <script> |
| document.body.style.zoom = "33%"; |
| importPaintWorkletThenEndTest(document.getElementById('code').textContent); |
| </script> |
| </body> |
| </html> |