summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/html/canvas/tools/yaml-new/scroll.yaml
diff options
context:
space:
mode:
Diffstat (limited to 'testing/web-platform/tests/html/canvas/tools/yaml-new/scroll.yaml')
-rw-r--r--testing/web-platform/tests/html/canvas/tools/yaml-new/scroll.yaml76
1 files changed, 76 insertions, 0 deletions
diff --git a/testing/web-platform/tests/html/canvas/tools/yaml-new/scroll.yaml b/testing/web-platform/tests/html/canvas/tools/yaml-new/scroll.yaml
new file mode 100644
index 0000000000..dd088aa396
--- /dev/null
+++ b/testing/web-platform/tests/html/canvas/tools/yaml-new/scroll.yaml
@@ -0,0 +1,76 @@
+- name: 2d.scrollPathIntoView.basic
+ desc: scrollPathIntoView() works
+ canvasType:
+ ['HTMLCanvas']
+ code: |
+ var div = document.createElement('div');
+ div.style.cssText = 'width: 200vw; height: 200vh';
+ document.body.appendChild(div);
+ canvas.style.cssText = 'position: absolute; top: 100px; left: 200px; border: none;';
+ window.scrollTo(0, 0);
+
+ ctx.beginPath();
+ ctx.rect(4, 8, 16, 32);
+ ctx.scrollPathIntoView();
+ var rect = canvas.getBoundingClientRect();
+ @assert Math.round(rect.top) === -8;
+ @assert Math.round(rect.left) === 200;
+
+- name: 2d.scrollPathIntoView.verticalLR
+ desc: scrollPathIntoView() works in vertical-lr writing mode
+ canvasType:
+ ['HTMLCanvas']
+ code: |
+ document.documentElement.style.cssText = 'writing-mode: vertical-lr';
+ var div = document.createElement('div');
+ div.style.cssText = 'width: 200vw; height: 200vh';
+ document.body.appendChild(div);
+ canvas.style.cssText = 'position: absolute; top: 100px; left: 200px; border: none;';
+ window.scrollTo(0, 0);
+
+ ctx.beginPath();
+ ctx.rect(4, 8, 16, 32);
+ ctx.scrollPathIntoView();
+ var rect = canvas.getBoundingClientRect();
+ @assert Math.round(rect.top) === 100;
+ @assert Math.round(rect.left) === -4;
+
+- name: 2d.scrollPathIntoView.verticalRL
+ desc: scrollPathIntoView() works in vertical-rl writing mode
+ canvasType:
+ ['HTMLCanvas']
+ code: |
+ document.documentElement.style.cssText = 'writing-mode: vertical-rl';
+ var div = document.createElement('div');
+ div.style.cssText = 'width: 200vw; height: 200vh';
+ document.body.appendChild(div);
+ canvas.style.cssText = 'position: absolute; top: 100px; right: 200px; border: none;';
+ window.scrollTo(0, 0);
+
+ ctx.beginPath();
+ ctx.rect(4, 8, 16, 32);
+ ctx.scrollPathIntoView();
+ var rect = canvas.getBoundingClientRect();
+ var viewportWidth = document.scrollingElement.clientWidth;
+ var canvasWidth = canvas.width;
+ @assert Math.round(rect.top) === 100;
+ @assert Math.round(rect.right) === viewportWidth + (canvasWidth - 4 - 16);
+
+- name: 2d.scrollPathIntoView.path
+ desc: scrollPathIntoView() with path argument works
+ canvasType:
+ ['HTMLCanvas']
+ code: |
+ var div = document.createElement('div');
+ div.style.cssText = 'width: 200vw; height: 200vh';
+ document.body.appendChild(div);
+ canvas.style.cssText = 'position: absolute; top: 100px; left: 200px; border: none;';
+ window.scrollTo(0, 0);
+
+ var path = new Path2D();
+ path.rect(4, 8, 16, 32);
+ ctx.scrollPathIntoView(path);
+ var rect = canvas.getBoundingClientRect();
+ @assert Math.round(rect.top) === -8;
+ @assert Math.round(rect.left) === 200;
+