tor-browser

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

test_outerHTML.xhtml (3447B)


      1 <!DOCTYPE HTML>
      2 <html xmlns="http://www.w3.org/1999/xhtml">
      3 <!--
      4 https://bugzilla.mozilla.org/show_bug.cgi?id=92264
      5 -->
      6 <head>
      7  <title>Test for Bug 92264</title>
      8  <script src="/tests/SimpleTest/SimpleTest.js"></script>
      9  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
     10 </head>
     11 <body onload="runTest();">
     12 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=92264">Mozilla Bug 92264</a>
     13 <p id="display"></p>
     14 <div id="content" style="display: none">
     15 <div id="wrap"><dl></dl><p id="thep">foo<span>bar</span></p><ol></ol></div>
     16 <table id="thetable"><tbody><tr><td>1</td></tr><tr id="thetr"><td>2</td></tr><tr><td>3</td></tr></tbody></table>
     17 <iframe></iframe>
     18 <div id="fragmentwrap"></div>
     19 </div>
     20 <pre id="test">
     21 <script type="application/javascript">
     22 <![CDATA[
     23 
     24 /** Test for Bug 92264 */
     25 
     26 SimpleTest.waitForExplicitFinish();
     27 
     28 function runTest() {
     29 
     30  var thep = document.getElementById("thep");
     31  var wrap = document.getElementById("wrap");
     32  is(thep.outerHTML, '<p xmlns="http://www.w3.org/1999/xhtml" id="thep">foo<span>bar</span></p>', "Unexpected thep outerHTML");
     33  thep.outerHTML = "<ul></ul><tr></tr><p></p>";
     34  is(wrap.innerHTML, '<dl xmlns="http://www.w3.org/1999/xhtml"></dl><ul xmlns="http://www.w3.org/1999/xhtml"></ul><tr xmlns="http://www.w3.org/1999/xhtml"></tr><p xmlns="http://www.w3.org/1999/xhtml"></p><ol xmlns="http://www.w3.org/1999/xhtml"></ol>', "Bad outerHTML parsing inside wrap");
     35 
     36  var thetr = document.getElementById("thetr");
     37  thetr.outerHTML = "<tr><td>a</td></tr><div></div><tr><td>b</td></tr>";
     38  var thetable = document.getElementById("thetable");
     39  is(thetable.innerHTML, '<tbody xmlns="http://www.w3.org/1999/xhtml"><tr><td>1</td></tr><tr><td>a</td></tr><div></div><tr><td>b</td></tr><tr><td>3</td></tr></tbody>', "Wrong outerHTML parsing inside table");
     40 
     41  var iframe = document.getElementsByTagName("iframe")[0];
     42  var oldbody = iframe.contentDocument.body;
     43  iframe.contentDocument.body.outerHTML = "<body></body>";
     44  isnot(oldbody, iframe.contentDocument.body, "Failed to replace body");
     45  is(iframe.contentDocument.getElementsByTagName("body").length, 1, "Should have gotten one body");
     46  // Yes, two heads per spec. Also Ragnarök and Chrome produce two heads.
     47  is(iframe.contentDocument.getElementsByTagName("head").length, 2, "Should have gotten two heads");
     48 
     49  try {
     50    document.documentElement.outerHTML = "<html></html>";
     51    ok(false, "Should have thrown an exception");
     52  } catch(e) {
     53    is(e.name, "NoModificationAllowedError", "outerHTML should throw NoModificationAllowedError");
     54    is(e.code, 7, "outerHTML should throw NO_MODIFICATION_ALLOWED_ERR");
     55  }
     56 
     57  var f = document.createDocumentFragment();
     58  var dl = document.createElement("dl");
     59  var p = document.createElement("p");
     60  var ol = document.createElement("ol");
     61  f.appendChild(dl);
     62  f.appendChild(p);
     63  f.appendChild(ol);
     64  p.outerHTML = "<ul></ul><tr></tr><body></body><p></p>";
     65  var fragmentwrap = document.getElementById("fragmentwrap");
     66  fragmentwrap.appendChild(f);
     67  is(fragmentwrap.innerHTML, '<dl xmlns="http://www.w3.org/1999/xhtml"></dl><ul xmlns="http://www.w3.org/1999/xhtml"></ul><tr xmlns="http://www.w3.org/1999/xhtml"></tr><body xmlns="http://www.w3.org/1999/xhtml"></body><p xmlns="http://www.w3.org/1999/xhtml"></p><ol xmlns="http://www.w3.org/1999/xhtml"></ol>', "Bad outerHTML parsing in fragment");
     68 
     69  SimpleTest.finish();
     70 }
     71 ]]>
     72 </script>
     73 </pre>
     74 </body>
     75 </html>