tor-browser

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

all-prop-initial-xml.html (1890B)


      1 <!doctype html>
      2 <title>all: initial on unknown XML tree</title>
      3 <link rel=help href=https://www.w3.org/TR/css-cascade-3/#all-shorthand>
      4 <script src="/resources/testharness.js"></script>
      5 <script src="/resources/testharnessreport.js"></script>
      6 <body>
      7 <script>
      8 const iframe = document.createElement("iframe");
      9 const setup_test = async_test("setup");
     10 iframe.onload = setup_test.step_func_done(function() {
     11    const root = iframe.contentDocument.documentElement;
     12    // we need the empty stylesheet to avoid default XSLT views of the XML
     13    const style = iframe.contentDocument.createElementNS("http://www.w3.org/1999/xhtml", "style");
     14    root.appendChild(style);
     15 
     16    // Grab initial styles from a random element, as the root can get non-initial UA styling.
     17    const div = iframe.contentDocument.createElementNS("http://www.w3.org/1999/xhtml", "div");
     18    root.appendChild(div);
     19    // the document element should have unicode-bidi 'normal', while <div> has 'isolate':
     20    div.style.unicodeBidi = 'normal';
     21    const cs = iframe.contentWindow.getComputedStyle(div);
     22 
     23    let actual_initial = Object.create(null);
     24    for (let i = 0; i < cs.length; i++) {
     25        let prop_name = cs[i];
     26        actual_initial[prop_name] = cs[prop_name];
     27    }
     28    const rootCS = iframe.contentWindow.getComputedStyle(root);
     29    test(() => {
     30        style.textContent = ":root { color: blue }";
     31        assert_equals(rootCS["color"], "rgb(0, 0, 255)");
     32    }, "stylesheet takes effect");
     33    style.textContent = ":root { all: initial; direction: initial; unicode-bidi: initial; } style { display: none; }";
     34    for (let prop_name in actual_initial) {
     35        test(() => {
     36            assert_equals(rootCS[prop_name], actual_initial[prop_name]);
     37        }, prop_name);
     38    }
     39 });
     40 iframe.src = URL.createObjectURL(new Blob(["<foo/>"], { type: "application/xml" }));
     41 document.body.appendChild(iframe);
     42 </script>