Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(37)

Unified Diff: third_party/WebKit/LayoutTests/fast/canvas/canvas-hit-regions-basic-test.html

Issue 1553373002: Canvas2d: Fix incorrect alignment of hit region when applied css/zoom. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/fast/canvas/canvas-hit-regions-basic-test-expected.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/LayoutTests/fast/canvas/canvas-hit-regions-basic-test.html
diff --git a/third_party/WebKit/LayoutTests/fast/canvas/canvas-hit-regions-basic-test.html b/third_party/WebKit/LayoutTests/fast/canvas/canvas-hit-regions-basic-test.html
index 0349c15adca45a6eea74260b20cc376657f23533..873fa027b86af31e826b7e5657e32eeb08fe76e6 100644
--- a/third_party/WebKit/LayoutTests/fast/canvas/canvas-hit-regions-basic-test.html
+++ b/third_party/WebKit/LayoutTests/fast/canvas/canvas-hit-regions-basic-test.html
@@ -1,114 +1,38 @@
<!DOCTYPE html>
-<html>
-<head>
- <title>Canvas Hit Regions: basic test</title>
- <script src="../../resources/js-test.js"></script>
-</head>
-<body>
-<canvas id="canvas" width="400" height="400">
- <button id="face"></button>
- <button id="eyes"></button>
-</canvas>
-<script src="./resources/canvas-hit-region-event.js"></script>
+<title>HitRegion Basic Test</title>
+<script src="../../resources/testharness.js"></script>
+<script src="../../resources/testharnessreport.js"></script>
+<script src="./resources/test-helpers.js"></script>
+<canvas width="400" height="400"></canvas>
+<style>
+
+body {
+ margin : 0px;
+ padding : 0px;
+}
+
+</style>
<script>
- var canvas = document.getElementById("canvas");
- var context = canvas.getContext("2d");
+var canvas = document.querySelector('canvas');
+var context = canvas.getContext('2d');
- context.fillStyle = "pink";
- context.arc(200, 175, 150, 0, Math.PI * 2, true);
- context.fill();
- context.addHitRegion({ id : "face", control : document.getElementById("face") });
+createFace(context);
- context.beginPath();
- context.fillStyle = "black";
- context.globalAlpha = .5;
- context.moveTo(200, 165);
- context.lineTo(240, 205);
- context.lineTo(160, 205);
- context.closePath();
- context.fill();
- context.addHitRegion({ id : "nose" });
+coroutine(function*() {
+ setup({ explicit_done : true, explicit_timeout : true });
- context.beginPath();
- context.fillStyle = "red";
- context.rect(125, 240, 150, 20);
- context.fill();
- context.addHitRegion({ id : "mouth" });
-
- context.beginPath();
- context.globalAlpha = 1;
- context.fillStyle = "blue";
- context.arc(150, 125, 25, 0, Math.PI * 2, true);
- context.arc(250, 125, 25, 0, Math.PI * 2, true);
- context.fill();
- context.addHitRegion({ id: "eye", control : document.getElementById("eyes") });
+ generate_tests(assert_equals, [
+ [ 'face', yield clickOrTouch(100, 100), 'face' ],
+ [ 'nose', yield clickOrTouch(200, 200), 'nose' ],
+ [ 'mouth', yield clickOrTouch(127, 242), 'mouth' ],
+ [ 'eye', yield clickOrTouch(150, 125), 'eye' ],
+ [ 'eye', yield clickOrTouch(250, 125), 'eye' ],
+ [ 'face', yield clickOrTouch(200, 120), 'face' ],
+ [ 'null', yield clickOrTouch(20, 10), null ]
+ ]);
- debug("Hit detection and mouse event tests");
- shouldBe("clickCanvas(100, 100)", "'face'");
- shouldBe("clickCanvas(200, 200)", "'nose'");
- shouldBe("clickCanvas(127, 242)", "'mouth'");
- shouldBe("clickCanvas(150, 125)", "'eye'");
- shouldBe("clickCanvas(250, 125)", "'eye'");
- shouldBe("clickCanvas(200, 125)", "'face'");
- shouldBe("clickCanvas(20, 10)", "null");
- debug("");
-
- debug("Hit detection and mouse/touch event tests with CSS sizing");
- canvas.style.width = "220px";
- canvas.style.height = "220px";
- shouldBe("clickCanvas(100, 100)", "'face'");
- shouldBe("clickCanvas(200, 200)", "'nose'");
- shouldBe("clickCanvas(127, 242)", "'no event sent to canvas'");
- shouldBe("clickCanvas(150, 125)", "'eye'");
- shouldBe("clickCanvas(250, 125)", "'no event sent to canvas'");
- shouldBe("clickCanvas(200, 125)", "'face'");
- shouldBe("clickCanvas(20, 10)", "null");
- canvas.style.width = "400px";
- canvas.style.height = "400px";
- debug("");
-
- debug("Hit detection and mouse/touch event tests with adjusted pixel ratio");
- eventSender.setPageZoomFactor(0.5);
- shouldBe("clickCanvas(50, 50)", "'face'");
- shouldBe("clickCanvas(100, 100)", "'nose'");
- shouldBe("clickCanvas(64, 121)", "'mouth'");
- shouldBe("clickCanvas(75, 63)", "'eye'");
- shouldBe("clickCanvas(125, 63)", "'eye'");
- shouldBe("clickCanvas(100, 63)", "'face'");
- shouldBe("clickCanvas(10, 5)", "null");
- eventSender.setPageZoomFactor(1);
- debug("");
-
- debug("Hit detection and mouse/touch event tests with adjusted page scale factor");
- window.internals.setPageScaleFactorLimits(0.5, 0.5);
- window.internals.setPageScaleFactor(0.5);
- shouldBe("clickCanvas(50, 50, 0.5)", "'face'");
- shouldBe("clickCanvas(100, 100, 0.5)", "'nose'");
- shouldBe("clickCanvas(64, 121, 0.5)", "'mouth'");
- shouldBe("clickCanvas(75, 63, 0.5)", "'eye'");
- shouldBe("clickCanvas(125, 63, 0.5)", "'eye'");
- shouldBe("clickCanvas(100, 63, 0.5)", "'face'");
- shouldBe("clickCanvas(10, 5, 0.5)", "null");
- window.internals.setPageScaleFactorLimits(1, 1);
- window.internals.setPageScaleFactor(1);
- debug("");
-
- debug("NotSupportedError exception tests");
- shouldThrow("context.addHitRegion()");
- shouldThrow("context.addHitRegion({ id : '' })");
- shouldThrow("context.addHitRegion({ id : undefined })");
- shouldThrow("context.addHitRegion({ control : {} })");
- shouldThrow("context.addHitRegion({ control : null })");
- shouldThrow("context.addHitRegion({ control : undefined })");
- shouldThrow("context.addHitRegion({ id : '', control : {} })");
- shouldThrow("context.addHitRegion({ id : undefined, control : {} })");
- shouldThrow("context.addHitRegion({ id : '', control : null })");
- shouldThrow("context.addHitRegion({ id : undefined, control : null })");
- shouldThrow("context.addHitRegion({ id : '', control : undefined })");
- shouldThrow("context.addHitRegion({ id : undefined, control : undefined })");
- debug("");
+ done();
+});
</script>
-</body>
-</html>
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/fast/canvas/canvas-hit-regions-basic-test-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698