summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/html/canvas/tools/yaml-new/scroll.yaml
blob: dd088aa396f47e70a6e66b0b9c7d8ffca0fa0e1e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
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;