tor-browser

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

ignore-frameset-token.html (4486B)


      1 <!DOCTYPE html>
      2 <html>
      3 <head>
      4 <title>HTML Templates: In body insertion mode: parser should ignore FRAMESET token</title>
      5 <meta name="author" title="Sergey G. Grekhov" href="mailto:sgrekhov@unipro.ru">
      6 <meta name="author" title="Aleksei Yu. Semenov" href="mailto:a.semenov@unipro.ru">
      7 <meta name="assert" content="If parser is in 'in body' insertion mode and meets HTML token it should be ignored">
      8 <link rel="help" href="http://www.w3.org/TR/2013/WD-html-templates-20130214/#in-body-addition">
      9 <script src="/resources/testharness.js"></script>
     10 <script src="/resources/testharnessreport.js"></script>
     11 <script src="/html/resources/common.js"></script>
     12 </head>
     13 <body>
     14 <div id="log"></div>
     15 <script type="text/javascript">
     16 
     17 /*
     18 * According to http://www.w3.org/TR/2013/WD-html-templates-20130214/#template-contents-insertion-mode
     19 * when parser is in "template content" mode and meets <frameset> tag it should be switched to
     20 * "in body" insertion mode.
     21 * According to https://html.spec.whatwg.org/multipage/#parsing-main-inbody
     22 * this token (FRAMESET) should be ignored
     23 */
     24 
     25 test(function() {
     26    var doc = newHTMLDocument();
     27    var template = doc.createElement('template');
     28 
     29    template.innerHTML = '<frameset cols="25%,*,25%">'
     30        + '<frame src="frame_a.htm">'
     31        + '<frame src="frame_b.htm">' + '<frame src="frame_c.htm">'
     32        + '</frameset>';
     33 
     34    doc.body.appendChild(template);
     35 
     36    assert_equals(template.content.childNodes.length, 0,
     37            'Template cannot contain FRAMESET element');
     38 
     39 }, 'Ignore frameset token. Test FRAMESET element assigned to template innerHTML');
     40 
     41 
     42 test(function() {
     43    var doc = newHTMLDocument();
     44    var template = doc.createElement('template');
     45 
     46    template.innerHTML = '<div id="div1">Some text</div>'
     47        + '<frameset cols="25%,*,25%">'
     48        + '<frame src="frame_a.htm">'
     49        + '<frame src="frame_b.htm">'
     50        + '<frame src="frame_c.htm">'
     51        + '</frameset>';
     52 
     53    doc.body.appendChild(template);
     54 
     55    assert_equals(template.content.childNodes.length, 1,
     56            'Template cannot contain FRAMESET element');
     57    assert_not_equals(template.content.querySelector('#div1'), null,
     58            'Template should contain valid element');
     59 
     60 }, 'Ignore frameset token. '
     61    + 'Test FRAMESET element and some valid element before it, assigned '
     62    + 'to the template\'s innerHTML');
     63 
     64 
     65 test(function() {
     66    var doc = newHTMLDocument();
     67    var template = doc.createElement('template');
     68 
     69    template.innerHTML = '<frameset cols="25%,*,25%">'
     70        + '<frame src="frame_a.htm">'
     71        + '<frame src="frame_b.htm">'
     72        + '<frame src="frame_c.htm">'
     73        + '</frameset><div id="div1">Some text</div>';
     74 
     75    doc.body.appendChild(template);
     76 
     77    assert_equals(template.content.childNodes.length, 1,
     78            'Template cannot contain FRAMESET element');
     79    assert_not_equals(template.content.querySelector('#div1'), null,
     80            'Template should contain valid element');
     81 
     82 }, 'Ignore frameset token. '
     83    + 'Test FRAMESET element and some valid element after it, assigned '
     84    + 'to the template\'s innerHTML');
     85 
     86 
     87 test(function() {
     88    var doc = newHTMLDocument();
     89    var template = doc.createElement('template');
     90 
     91    template.innerHTML = '<template id="t2">'
     92        + '<frameset cols="25%,*,25%">'
     93        + '<frame src="frame_a.htm">'
     94        + '<frame src="frame_b.htm">'
     95        + '<frame src="frame_c.htm">'
     96        + '</frameset></template>';
     97 
     98    doc.body.appendChild(template);
     99 
    100    assert_equals(template.content.childNodes.length, 1,
    101            'Template should contain nested template');
    102    assert_not_equals(template.content.querySelector('#t2'), null,
    103            'Template should contain nested element');
    104 
    105    var nestedTemplate = template.content.querySelector('#t2');
    106 
    107    assert_equals(nestedTemplate.content.childNodes.length, 0,
    108            'Template cannot contain FRAMESET element');
    109 
    110 }, 'Ignore frameset token. '
    111    + 'Test FRAMESET tag inside template tag assigned to another template\'s innerHTML');
    112 
    113 
    114 testInIFrame('/html/semantics/scripting-1/the-template-element/resources/template-contents-frameset.html', function(context) {
    115    var doc = context.iframes[0].contentDocument;
    116 
    117    var template = doc.body.querySelector('template');
    118 
    119    assert_equals(template.content.childNodes.length, 0,
    120            'Template cannot contain FRAMESET element');
    121 }, 'Ignore frameset token. Test loading a HTML file with FRAMESET tag inside template');
    122 
    123 </script>
    124 </body>
    125 </html>