tor-browser

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

test-001.html (2225B)


      1 <!DOCTYPE html>
      2 <html>
      3 <head>
      4 <title>Shadow DOM Test: A_08_01_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/#inert-html-elements">
      7 <meta name="assert" content="HTML Elements in shadow trees: base element must behave as inert, or not part of the document tree">
      8 <script src="/resources/testharness.js"></script>
      9 <script src="/resources/testharnessreport.js"></script>
     10 <script src="../../../../html/resources/common.js"></script>
     11 </head>
     12 <body>
     13 <div id="log"></div>
     14 <script>
     15 var A_08_01_01_T01 = async_test('A_08_01_01_T01');
     16 
     17 A_08_01_01_T01.checkIframeContent = A_08_01_01_T01.step_func(function () {
     18    //remember value to check before cleaning the context (it'll destroy the iframe)
     19    var valueToCheck = A_08_01_01_T01.iframe.contentWindow;
     20    cleanContext(A_08_01_01_T01.ctx);
     21 
     22    assert_equals(valueToCheck, null,
     23        'base html element ih a shadow tree must beahve like inert one');
     24 
     25    A_08_01_01_T01.done();
     26 });
     27 
     28 
     29 A_08_01_01_T01.step(function () {
     30 
     31    A_08_01_01_T01.ctx = newContext();
     32    var d = newRenderedHTMLDocument(A_08_01_01_T01.ctx);
     33 
     34    //create iframe
     35    var iframe = document.createElement('iframe');
     36 
     37    iframe.src = '../../resources/blank.html';
     38    iframe.setAttribute('name', 'targetIframe');
     39    d.body.appendChild(iframe);
     40 
     41    A_08_01_01_T01.iframe = iframe;
     42 
     43    // create a link
     44    var link = d.createElement('a');
     45    link.setAttribute('href', '../../resources/bobs_page.html');
     46    link.innerHTML = 'the link';
     47    d.body.appendChild(link);
     48 
     49    //create Shadow root
     50    var root = d.createElement('div');
     51    d.body.appendChild(root);
     52    var s = root.attachShadow({mode: 'open'});
     53 
     54    // create base element, set iframe as a target
     55    var base = d.createElement('base');
     56    base.setAttribute('target', 'targetIframe');
     57    s.appendChild(base);
     58 
     59    //click the link
     60    link.click();
     61 
     62    //Expected: base should be inert therefore document d
     63    // should be reloaded, so iframe context shouldn't be affected
     64 
     65    // set timeout to give the iframe time to load content
     66    step_timeout(A_08_01_01_T01.checkIframeContent, 2000);
     67 });
     68 </script>
     69 </body>
     70 </html>