summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/appmanifest/display-override-member/display-override-member-css-environment-variables-window-controls-overlay-manual.tentative.html
blob: a49b4f6f9853c3f824347e64b9d2e6b318b4a39e (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
<!DOCTYPE html>
<html>

<head>
  <title>Test CSS environment variables when "window-controls-overlay" in display-override member</title>
  <link rel="manifest" href="resources/display-override-member-css-environment-variables-window-controls-overlay.webmanifest" />
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <h1>Test CSS environment variables when "window-controls-overlay" in display-override member</h1>
  <style>
    #windowControlsOverlayElementStyle {
      padding-left: env(titlebar-area-x);
      padding-right: env(titlebar-area-width);
      padding-top: env(titlebar-area-y);
      padding-bottom: env(titlebar-area-height);
    }
  </style>

  <script src="/resources/testharness.js"></script>
  <script src="/resources/testharnessreport.js"></script>
  <script src="resources/display-override-member-media-feature-manual.js"></script>

  <script>
    setup({ explicit_timeout: true });
    var manual_test = async_test("titlebar-area CSS environment variables");
    manual_test.step_timeout(() => {
      manual_test.force_timeout();
      manual_test.done();
    }, 60000);
    manual_test.step(() => {
      navigator.windowControlsOverlay.addEventListener('geometrychange', (event) => {
        if (navigator.windowControlsOverlay.visible) {
          const windowControlsOverlayElementStyle = document.getElementById('windowControlsOverlayElementStyle');
          const x = getComputedStyle(windowControlsOverlayElementStyle).getPropertyValue('padding-left');
          const w = getComputedStyle(windowControlsOverlayElementStyle).getPropertyValue('padding-right');
          const y = getComputedStyle(windowControlsOverlayElementStyle).getPropertyValue('padding-top');
          const h = getComputedStyle(windowControlsOverlayElementStyle).getPropertyValue('padding-bottom');
          const boundingClientRect = navigator.windowControlsOverlay.getTitlebarAreaRect();
          manual_test.step(() => {
            assert_equals(x, boundingClientRect.x + 'px', 'CSS environment "titlebar-area-x" does not equal navigator.windowControlsOverlay.getTitlebarAreaRect().x');
            assert_equals(y, boundingClientRect.y + 'px', 'CSS environment "titlebar-area-x" does not equal navigator.windowControlsOverlay.getTitlebarAreaRect().y');
            assert_equals(w, boundingClientRect.width + 'px', 'CSS environment "titlebar-area-x" does not equal navigator.windowControlsOverlay.getTitlebarAreaRect().width');
            assert_equals(h, boundingClientRect.height + 'px', 'CSS environment "titlebar-area-x" does not equal navigator.windowControlsOverlay.getTitlebarAreaRect().height');
          });
          manual_test.done();
        }
      });
    });
  </script>
</head>

<body>
  <h1>Description</h1>
  <p>This test validates that when in "window-controls-overlay" mode, the 'titlebar-area-*' CSS environment variables
    match the values returned by navigator.windowControlsOverlay.getTitlebarAreaRect().</p>
  <h1>Manual Test Steps:</h1>
  <p>
    <ol>
      <li> Install this app, and toggle into "window-controls-overlay" mode.</li>
      <li> Upon toggling into "window-controls-overlay" mode, the test will validate that the CSS enviroment variable
        values match the JavaScript API.</li>
    </ol>
  Note: This test will automatically timeout and fail if not completed within 60 seconds.
  </p>
  <div id="windowControlsOverlayElementStyle"></div>
</body>

</html>