summaryrefslogtreecommitdiffstats
path: root/layout/style/test/test_non_content_accessible_env_vars.html
blob: d9714216b78aa012762ccb5bf616cb8daeba25a1 (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
<!doctype html>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<iframe></iframe>
<iframe srcdoc="Foo"></iframe>
<script>
const NON_CONTENT_ACCESSIBLE_ENV_VARS = [
  "-moz-gtk-csd-titlebar-radius",
  "-moz-gtk-csd-minimize-button-position",
  "-moz-gtk-csd-maximize-button-position",
  "-moz-gtk-csd-close-button-position",
  "-moz-content-preferred-color-scheme",
  "-moz-overlay-scrollbar-fade-duration",
  "scrollbar-inline-size",
];

function testInWin(win) {
  let doc = win.document;
  const div = doc.createElement("div");
  doc.documentElement.appendChild(div);
  for (const envVar of NON_CONTENT_ACCESSIBLE_ENV_VARS) {
    div.style.setProperty("--foo", `env(${envVar},FALLBACK_VALUE)`);

    assert_equals(
      win.getComputedStyle(div).getPropertyValue("--foo"),
      "FALLBACK_VALUE",
      `${envVar} shouldn't be exposed to content in ${doc.documentURI}`
    );
  }
}

let t = async_test("Test non-content-accessible env() vars");
onload = t.step_func_done(function() {
  testInWin(window);
  for (let f of document.querySelectorAll("iframe")) {
    testInWin(f.contentWindow);
  }
});
</script>