Commit dc965751 authored by Xida Chen's avatar Xida Chen Committed by Commit Bot

[PaintWorklet] Add a layout test to ensure API correctness with page zoom

This CL adds a new layout test to make sure that the following APIs:
lineWidth
lineDash
lineDashOffset
works properly with browser zoom.

Bug: 849706
Change-Id: I07c07e688203c26b2b2223377da88591a44a4e55
Reviewed-on: https://chromium-review.googlesource.com/1088870Reviewed-by: default avatarStephen McGruer <smcgruer@chromium.org>
Commit-Queue: Xida Chen <xidachen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#564932}
parent af486664
<!DOCTYPE html>
<html>
<style>
html, body { margin: 0; padding: 0; }
</style>
<body>
<canvas id ="canvas" width="400" height="400" style="position:relative;"></canvas>
<script>
var canvas = document.getElementById('canvas');
var context = canvas.getContext("2d");
context.lineWidth = 20;
context.setLineDash([10, 30]);
context.lineDashOffset = 4;
context.beginPath();
context.moveTo(0, 100);
context.lineTo(400, 100);
context.stroke();
</script>
</body>
</html>
<!DOCTYPE html>
<html>
<script src="../resources/run-after-layout-and-paint.js"></script>
<script src="./resources/test-runner-paint-worklet.js"></script>
<style>
html, body { margin: 0; padding: 0; }
.container {
width: 200px;
height: 200px;
}
#canvas-shadow {
background-image: paint(shadow);
}
</style>
<body>
<div id="canvas-shadow" class="container"></div>
<script id="code" type="text/worklet">
registerPaint('shadow', class {
paint(ctx) {
ctx.lineWidth = 10;
ctx.setLineDash([5, 15]);
ctx.lineDashOffset = 2;
// The values should not be affected by the browser zoom when queried
// from JS.
if (ctx.lineWidth == 10 && ctx.lineDashOffset == 2 &&
ctx.getLineDash()[0] == 5 && ctx.getLineDash()[1] == 15) {
ctx.beginPath();
ctx.moveTo(0, 50);
ctx.lineTo(200, 50);
ctx.stroke();
}
}
});
</script>
<script>
document.body.style.zoom = "200%"
importPaintWorkletAndTerminateTestAfterAsyncPaint(document.getElementById('code').textContent);
</script>
</body>
</html>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment