tor-browser

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

css-style-reparse.html (1971B)


      1 <!doctype html>
      2 <html>
      3 <head>
      4  <meta charset=utf-8>
      5  <title>CSS Test: DOM modification re-parsing test</title>
      6  <link rel="help" href="https://drafts.csswg.org/cssom/">
      7  <link rel="help" href="http://www.w3.org/TR/cssom-1/#the-cssrule-interface">
      8  <script src=/resources/testharness.js></script>
      9  <script src=/resources/testharnessreport.js></script>
     10  <style>div { min-width: 0px; }</style>
     11  <style id="style-element"></style>
     12 </head>
     13 <body>
     14 <div id="test-div"></div>
     15 <script type="text/javascript">
     16    var style = document.getElementById("style-element");
     17    var div = document.getElementById("test-div");
     18 
     19    function testProperty(prop) {
     20      // Assigning an empty string to textContent or innerHTML should trigger a
     21      // reparse only if the element is not empty.
     22      style.sheet.insertRule("#test-div { min-width: 42px; }");
     23      assert_equals(getComputedStyle(div).minWidth, "42px");
     24 
     25      style[prop] = "";
     26      assert_equals(getComputedStyle(div).minWidth, "42px");
     27 
     28      style[prop] = " ";
     29      assert_equals(getComputedStyle(div).minWidth, "0px");
     30 
     31      style.sheet.insertRule("#test-div { min-width: 42px; }");
     32      assert_equals(getComputedStyle(div).minWidth, "42px");
     33 
     34      style[prop] = "";
     35      assert_equals(getComputedStyle(div).minWidth, "0px");
     36 
     37      style.sheet.insertRule("#test-div { min-width: 42px; }");
     38      assert_equals(getComputedStyle(div).minWidth, "42px");
     39 
     40      style.appendChild(document.createTextNode(""));
     41      assert_equals(getComputedStyle(div).minWidth, "0px");
     42 
     43      style.sheet.insertRule("#test-div { min-width: 42px; }");
     44      assert_equals(getComputedStyle(div).minWidth, "42px");
     45 
     46      style[prop] = "";
     47      assert_equals(getComputedStyle(div).minWidth, "0px");
     48    }
     49 
     50    test(function() {
     51      testProperty("textContent");
     52    }, "style.textContent modification");
     53 
     54    test(function() {
     55      testProperty("innerHTML");
     56    }, "style.innerHTML modification");
     57 </script>
     58 </body>
     59 </html>