tor-browser

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

test-003.html (2723B)


      1 <!DOCTYPE html>
      2 <html>
      3 <head>
      4 <title>Shadow DOM Test: A_08_02_03</title>
      5 <link rel="author" title="Sergey G. Grekhov" href="mailto:sgrekhov@unipro.ru">
      6 <link rel="help" href="https://w3c.github.io/webcomponents/spec/shadow/#inertness-of-html-elements-in-a-shadow-tree">
      7 <meta name="assert" content="HTML Elements in shadow trees: form should not submit elements in shadow 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_02_03_T01 = async_test('A_08_02_03_T01');
     16 
     17 var checkIframeContent = A_08_02_03_T01.step_func(function () {
     18    // remember value to check before cleaning the context (it'll destroy the iframe)
     19    var valueToCheck = A_08_02_03_T01.iframe.contentWindow.document.URL;
     20    cleanContext(A_08_02_03_T01.ctx);
     21 
     22    assert_true(valueToCheck.indexOf('inp1=value1') > 0,
     23        'html form should submit all of its fields');
     24 
     25    // Form data crossing shadow boundary should not be submitted.
     26    // https://github.com/w3c/webcomponents/issues/65
     27    assert_equals(valueToCheck.indexOf('inp2=value2'), -1,
     28        'html form should not submit fields in the shadow tree');
     29 
     30    A_08_02_03_T01.done();
     31 });
     32 
     33 
     34 A_08_02_03_T01.step(function () {
     35 
     36    A_08_02_03_T01.ctx = newContext();
     37    var d = newRenderedHTMLDocument(A_08_02_03_T01.ctx);
     38 
     39    //create iframe
     40    var iframe = document.createElement('iframe');
     41    A_08_02_03_T01.iframe = iframe;
     42 
     43    iframe.src = '../../resources/blank.html';
     44    iframe.setAttribute('name', 'targetIframe');
     45 
     46    // create form
     47    var form = d.createElement('form');
     48    form.setAttribute('target', 'targetIframe');
     49    form.setAttribute('method', 'GET');
     50    form.setAttribute('action', '../../resources/blank.html');
     51    d.body.appendChild(form);
     52 
     53    // create shadow root
     54    var root = d.createElement('div');
     55    form.appendChild(root);
     56    var s = root.attachShadow({mode: 'open'});
     57 
     58    var input1 = d.createElement('input');
     59    input1.setAttribute('type', 'text');
     60    input1.setAttribute('name', 'inp1');
     61    input1.setAttribute('value', 'value1');
     62    form.appendChild(input1);
     63 
     64    var input2 = d.createElement('input');
     65    input2.setAttribute('type', 'text');
     66    input2.setAttribute('name', 'inp2');
     67    input2.setAttribute('value', 'value2');
     68    s.appendChild(input2);
     69 
     70    // Wait for the first 'load' event for blank.html.
     71    iframe.onload = A_08_02_03_T01.step_func(() => {
     72        // Wait for the second 'load' event for the submission.
     73        iframe.onload = checkIframeContent;
     74        form.submit();
     75    });
     76    d.body.appendChild(iframe);
     77 });
     78 </script>
     79 </body>
     80 </html>