tor-browser

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

test-001.html (2431B)


      1 <!DOCTYPE html>
      2 <html>
      3 <head>
      4 <title>Shadow DOM Test: A_06_00_01</title>
      5 <link rel="author" title="Sergey G. Grekhov" href="mailto:sgrekhov@unipro.ru">
      6 <link rel="help" href="http://www.w3.org/TR/2013/WD-shadow-dom-20130514/#styles">
      7 <meta name="assert" content="Styles: CSS rules declared in an enclosing tree must not apply in a shadow tree if apply-author-styles flag is set to false for this tree">
      8 <script src="/resources/testharness.js"></script>
      9 <script src="/resources/testharnessreport.js"></script>
     10 <script src="../../../html/resources/common.js"></script>
     11 <script src="../../resources/shadow-dom-utils.js"></script>
     12 </head>
     13 <body>
     14 <div id="log"></div>
     15 <script>
     16 //test apply-author-styles flag of ShadowRoot object (default value)
     17 test(unit(function (ctx) {
     18 
     19    var d = newRenderedHTMLDocument(ctx);
     20 
     21    d.head.innerHTML = '<style>' +
     22        '.invis {' +
     23        'display:none;' +
     24        '}' +
     25        '</style>';
     26 
     27    var host = d.createElement('div');
     28    d.body.appendChild(host);
     29 
     30    //Shadow root to play with
     31    var s = host.attachShadow({mode: 'open'});
     32 
     33    var div1 = d.createElement('div');
     34    div1.innerHTML ='<span id="shd" class="invis">This is the shadow tree</span>';
     35    s.appendChild(div1);
     36 
     37    //apply-author-styles flag is false by default. Invisible style shouldn't be applied
     38    assert_true(s.querySelector('#shd').offsetTop > 0,
     39        'CSS styles declared in enclosing tree must not be applied in a shadow tree ' +
     40        'if the apply-author-styles flag is set to false');
     41 
     42 
     43 }), 'A_06_00_01_T01');
     44 
     45 
     46 //test apply-author-styles flag of ShadowRoot object (set it)
     47 test(unit(function (ctx) {
     48 
     49    var d = newRenderedHTMLDocument(ctx);
     50 
     51    d.head.innerHTML = '<style>' +
     52        '.invis {' +
     53        'display:none;' +
     54        '}' +
     55        '</style>';
     56 
     57    var host = d.createElement('div');
     58    d.body.appendChild(host);
     59 
     60    //Shadow root to play with
     61    var s = host.attachShadow({mode: 'open'});
     62 
     63    var div1 = d.createElement('div');
     64    div1.innerHTML ='<span id="shd" class="invis">This is the shadow tree</span>';
     65    s.appendChild(div1);
     66 
     67    //apply-author-styles flag is set to false. Invisible style shouldn't be applied
     68    assert_true(s.querySelector('#shd').offsetTop > 0,
     69        'CSS styles declared in enclosing tree must not be applied in a shadow tree ' +
     70        'if the apply-author-styles flag is set to false');
     71 
     72 
     73 }), 'A_06_00_01_T02');
     74 </script>
     75 </body>
     76 </html>