tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

test_non_content_accessible_env_vars.html (1279B)


      1 <!doctype html>
      2 <script src="/resources/testharness.js"></script>
      3 <script src="/resources/testharnessreport.js"></script>
      4 <iframe></iframe>
      5 <iframe srcdoc="Foo"></iframe>
      6 <script>
      7 const NON_CONTENT_ACCESSIBLE_ENV_VARS = [
      8  "-moz-gtk-csd-titlebar-radius",
      9  "-moz-gtk-csd-tooltip-radius",
     10  "-moz-gtk-csd-minimize-button-position",
     11  "-moz-gtk-csd-maximize-button-position",
     12  "-moz-gtk-csd-close-button-position",
     13  "-moz-content-preferred-color-scheme",
     14  "-moz-overlay-scrollbar-fade-duration",
     15  "scrollbar-inline-size",
     16  // Pending https://github.com/w3c/csswg-drafts/issues/3720
     17  "hairline",
     18 ];
     19 
     20 function testInWin(win) {
     21  let doc = win.document;
     22  const div = doc.createElement("div");
     23  doc.documentElement.appendChild(div);
     24  for (const envVar of NON_CONTENT_ACCESSIBLE_ENV_VARS) {
     25    div.style.setProperty("--foo", `env(${envVar},FALLBACK_VALUE)`);
     26 
     27    assert_equals(
     28      win.getComputedStyle(div).getPropertyValue("--foo"),
     29      "FALLBACK_VALUE",
     30      `${envVar} shouldn't be exposed to content in ${doc.documentURI}`
     31    );
     32  }
     33 }
     34 
     35 let t = async_test("Test non-content-accessible env() vars");
     36 onload = t.step_func_done(function() {
     37  testInWin(window);
     38  for (let f of document.querySelectorAll("iframe")) {
     39    testInWin(f.contentWindow);
     40  }
     41 });
     42 </script>