Chromium Code Reviews| Index: LayoutTests/fast/canvas/canvas-scroll-path-into-view.html |
| diff --git a/LayoutTests/fast/canvas/canvas-scroll-path-into-view.html b/LayoutTests/fast/canvas/canvas-scroll-path-into-view.html |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..2cf4cf8dc470546998ecb7082b690f99d5bb5dff |
| --- /dev/null |
| +++ b/LayoutTests/fast/canvas/canvas-scroll-path-into-view.html |
| @@ -0,0 +1,111 @@ |
| +<!DOCTYPE html> |
| +<html> |
| +<head> |
| + <script src="../../resources/js-test.js"></script> |
| + <style> |
| + |
| + .container { |
| + display : inline-block; |
| + width : 200px; |
| + height : 200px; |
| + overflow : scroll; |
| + } |
| + |
| + .border { |
| + border : 500px solid white; |
| + } |
| + |
| + .padding { |
| + padding : 500px; |
| + } |
| + |
| + .margin { |
| + margin : 500px; |
| + } |
| + |
| + </style> |
| +</head> |
| +<body> |
| + <div class="container"> |
| + <canvas width="400" height="400"></canvas> |
| + </div> |
| + <script> |
| + |
| + if (window.testRunner) |
| + testRunner.dumpAsText(); |
| + |
| + function drawAndScroll(container, context, path) { |
| + |
| + // reset scroll |
| + container.scrollTop = 0; |
| + container.scrollLeft = 0; |
| + |
| + // draw path stroke |
| + context.clearRect(0, 0, 400, 400); |
| + context.beginPath(); |
| + if (path == undefined || path == null) { |
| + context.rect(100, 100, 100, 100); |
| + context.stroke(); |
| + } else { |
| + path.rect(100, 100, 100, 100); |
| + context.stroke(path); |
| + } |
| + |
| + // scroll path into view |
| + if (path == undefined || path == null) |
| + context.scrollPathIntoView(); |
| + else |
| + context.scrollPathIntoView(path); |
| + |
| + // save scroll top value |
| + window.testValue = container.scrollTop; |
| + } |
| + |
| + function scrollTest(container, context, path) { |
| + |
| + canvas.className = ""; |
| + drawAndScroll(container, context); |
| + shouldBe("testValue", "100"); |
| + |
| + canvas.className = "border"; |
| + drawAndScroll(container, context); |
| + shouldBe("testValue", "600"); |
| + |
| + canvas.className = "padding"; |
| + drawAndScroll(container, context); |
| + shouldBe("testValue", "600"); |
| + |
| + canvas.className = "padding border"; |
| + drawAndScroll(container, context); |
| + shouldBe("testValue", "1100"); |
| + |
| + canvas.className = "margin"; |
| + drawAndScroll(container, context); |
| + shouldBe("testValue", "600"); |
| + } |
| + |
| + var container = document.querySelector("div[class='container']"); |
| + var canvas = document.querySelector("canvas"); |
| + var context = canvas.getContext("2d"); |
| + |
| + var path = new Path2D(); |
| + |
| + description("Series of tests to ensure correct results of scrolling path into view on canvas"); |
| + |
| + debug("Test case 1: scrollPathIntoView();"); |
| + scrollTest(container, context); |
| + debug(""); |
| + |
| + debug("Test case 2: scrollPathIntoView(path);"); |
| + scrollTest(container, context, path); |
|
Justin Novosad
2014/03/20 20:03:12
Need additional test case with CTM != identity. A
|
| + debug(""); |
| + |
| + debug("Test case 3: exceptions"); |
| + shouldThrow("context.scrollPathIntoView(null);"); |
| + shouldThrow("context.scrollPathIntoView([]);"); |
| + shouldThrow("context.scrollPathIntoView({});"); |
| + debug(""); |
| + |
| + </script> |
| +</body> |
| +</html> |