dom/tests/mochitest/bugs/test_bug42976.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/tests/mochitest/bugs/test_bug42976.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,81 @@
     1.4 +<!DOCTYPE HTML>
     1.5 +<html>
     1.6 +<!--
     1.7 +https://bugzilla.mozilla.org/show_bug.cgi?id=42976
     1.8 +-->
     1.9 +<head>
    1.10 +  <title>Test for Bug 42976</title>
    1.11 +  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>        
    1.12 +  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
    1.13 +</head>
    1.14 +<body onload="runTest()">
    1.15 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=42976">Mozilla Bug 42976</a>
    1.16 +<p id="display"></p>
    1.17 +<div id="content">
    1.18 +    <iframe id=specialtest src="data:text/html,<meta http-equiv='Content-Language' content='ja-JP'><base href='http://www.mozilla.org'><p>asdf"></iframe>;
    1.19 +    <iframe id=htmlquirks src="data:text/html;charset=ISO-8859-2,<html><body><div></div></body></html>"></iframe>
    1.20 +    <iframe id=htmlstd src="data:text/html;charset=ISO-8859-3,<!DOCTYPE html><html><body><div></div></body></html>"></iframe>
    1.21 +    <iframe id=textplain src="data:text/plain;charset=ISO-8859-4,asdf%0Azxcv%0A"></iframe>
    1.22 +    <iframe id=xhtmlstd src="data:application/xhtml+xml;charset=ISO-8859-5,<!DOCTYPE html><html xmlns='http://www.w3.org/1999/xhtml'><body><div></div></body></html>"></iframe>
    1.23 +    <iframe id=xmlstd src="data:image/svg+xml;charset=ISO-8859-6,<svg xmlns=&quot;http://www.w3.org/2000/svg&quot; width='300' height='300'><text x='60' y='150' fill='blue'>Hello, World!</text><text x='60' y='250' fill='blue'>Hello, World!</text></svg>"></iframe>
    1.24 +</div>
    1.25 +<pre id="test">
    1.26 +<script class="testbody" type="text/javascript">
    1.27 +
    1.28 +SimpleTest.waitForExplicitFinish();
    1.29 +
    1.30 +function runTest() {
    1.31 +
    1.32 +  var iframes = document.getElementsByTagName("iframe");
    1.33 +  for (var i = 1; i < iframes.length; i++) {
    1.34 +    var doc = iframes[i].contentDocument;
    1.35 +    var clonefalse = doc.cloneNode(false);
    1.36 +    // doc.compatMode
    1.37 +    ok(doc.compatMode == clonefalse.compatMode, "compatMode not preserved correctly; " + iframes[i].id);
    1.38 +  
    1.39 +    // doc.contentType
    1.40 +    ok(doc.contentType == clonefalse.contentType, "contentType not preserved correctly; " + iframes[i].id);
    1.41 +  
    1.42 +    // doc.characterSet
    1.43 +    ok(doc.characterSet == clonefalse.characterSet, "charset not preserved correctly; " + iframes[i].id);
    1.44 +  
    1.45 +    // innerHTML+tag case test
    1.46 +    var clonetrue = doc.cloneNode(true);
    1.47 +    doc.documentElement.firstChild.innerHTML="<div><dD></dD></div>";
    1.48 +    clonetrue.documentElement.firstChild.innerHTML="<div><dD></dD></div>";
    1.49 +    ok(doc.documentElement.innerHTML == clonetrue.documentElement.innerHTML,
    1.50 +       "innerHTML not preserved correctly; " + iframes[i].id);
    1.51 +  
    1.52 +  }
    1.53 +  
    1.54 +  // A couple of tests that don't quite fit in the framework.
    1.55 +  var doc = iframes[0].contentDocument;
    1.56 +
    1.57 +  // Setting document.dir does nothing in a document without an <html> element
    1.58 +  doc.dir="rtl";
    1.59 +  var docclone = doc.cloneNode(false);
    1.60 +  
    1.61 +  // doc.dir
    1.62 +  ok(docclone.dir == "", "dir set on doc without html element");
    1.63 +  
    1.64 +  // document.querySelectorAll(":lang(ja)")
    1.65 +  docclone.appendChild(docclone.createElement("html"));
    1.66 +  ok(docclone.querySelectorAll(":lang(ja)").length == 1, "lang not preserved correctly");
    1.67 +  
    1.68 +  docclone.documentElement.innerHTML="<body><p><a href='a.html' id=a>asf</a></body>";
    1.69 +  ok(docclone.getElementById('a').href == "http://www.mozilla.org/a.html",
    1.70 +     "base not preserved correctly");
    1.71 +
    1.72 +  // Now that we have an <html> element, deep cloning preserves document.dir
    1.73 +  docclone.dir="rtl";
    1.74 +  var cloneclone = docclone.cloneNode(true);
    1.75 +
    1.76 +  // doc.dir
    1.77 +  ok(cloneclone.dir == "rtl", "dir not preserved correctly");
    1.78 +
    1.79 +  SimpleTest.finish();
    1.80 +}
    1.81 +</script>
    1.82 +</pre>
    1.83 +</body>
    1.84 +</html>

mercurial