content/base/test/test_bug744830.html

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     1 <!DOCTYPE HTML>
     2 <html>
     3 <!--
     4 https://bugzilla.mozilla.org/show_bug.cgi?id=744830
     5 -->
     6 <head>
     7   <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
     8   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
     9 </head>
    10 <body>
    11 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=166235">Mozilla Bug 166235</a>
    12 <div id="testnodes"><span>hi</span> there <!-- mon ami --></div>
    13 <pre id="test">
    14 <script type="application/javascript">
    15   var t = document.getElementById('testnodes');
    16   is(t.innerHTML, 
    17      "<span>hi</span> there <!-- mon ami -->",
    18      "comment nodes should be included");
    20   var PI = document.createProcessingInstruction('foo', 'bar="1.0"');
    21   t.appendChild(PI);
    22   is(t.innerHTML, '<span>hi</span> there <!-- mon ami --><?foo bar="1.0">',
    23     "pi nodes should be included");
    25   t.innerHTML = null;
    26   t.appendChild(document.createElement("textarea"));
    27   t.firstChild.appendChild(document.createTextNode("\nhello"));
    28   // This is the old behavior. Spec requires something else.
    29   is(t.innerHTML, "<textarea>\nhello</textarea>",
    30      "No extra newlines should be inserted to the textarea!");
    32   t.innerHTML = null;
    33   t.appendChild(document.createElementNS("http://www.w3.org/2000/svg", "svg:svg"));
    34   t.firstChild.textContent = "<foo>";
    35   is(t.innerHTML, "<svg>&lt;foo&gt;</svg>");
    37   t.innerHTML = null;
    38   t.appendChild(document.createElementNS("http://www.w3.org/1998/Math/MathML", "math:math"));
    39   t.firstChild.textContent = "<foo>";
    40   is(t.innerHTML, "<math>&lt;foo&gt;</math>");
    42   // Prefix is serialized if element isn't HTML/SVG/MathML  
    43   t.innerHTML = null;
    44   t.appendChild(document.createElementNS("http://www.example.org", "ex:example"));
    45   t.firstChild.textContent = "<foo>";
    46   is(t.innerHTML, "<ex:example>&lt;foo&gt;</ex:example>");
    48   t.innerHTML = null;
    49   t.appendChild(document.createElementNS("http://www.example.org", "example"));
    50   t.firstChild.textContent = "<foo>";
    51   is(t.innerHTML, "<example>&lt;foo&gt;</example>");
    53   t.firstChild.setAttributeNS("http://www.w3.org/XML/1998/namespace", "xml:lang", "us-en");
    54   is(t.innerHTML, '<example xml:lang="us-en">&lt;foo&gt;</example>');
    56   t.firstChild.setAttributeNS("http://www.w3.org/1999/xlink", "href", "foo");
    57   is(t.innerHTML, '<example xlink:href="foo" xml:lang="us-en">&lt;foo&gt;</example>');
    59   t.firstChild.setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns", "http://foo");
    60   is(t.innerHTML, '<example xmlns="http://foo" xlink:href="foo" xml:lang="us-en">&lt;foo&gt;</example>');
    62   t.firstChild.setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:bar", "http://bar");
    63   is(t.innerHTML, '<example xmlns:bar="http://bar" xmlns="http://foo" xlink:href="foo" xml:lang="us-en">&lt;foo&gt;</example>');
    65   t.firstChild.setAttributeNS("http://www.helloworldns.org", "hello:world", "!");
    66   is(t.innerHTML, '<example hello:world="!" xmlns:bar="http://bar" xmlns="http://foo" xlink:href="foo" xml:lang="us-en">&lt;foo&gt;</example>');
    68   t.firstChild.setAttribute("foo", '-"&\xA0-');
    69   is(t.innerHTML, '<example foo="-&quot;&amp;&nbsp;-" hello:world="!" xmlns:bar="http://bar" xmlns="http://foo" xlink:href="foo" xml:lang="us-en">&lt;foo&gt;</example>');
    71   t.innerHTML = null;
    72   t.appendChild(document.createElement("div"));
    73   t.firstChild.appendChild(document.implementation
    74                                    .createDocument(null, null, null)
    75                                    .createCDATASection("foo"));
    76   is(t.innerHTML, '<div>foo</div>');
    78   t.firstChild.textContent = "1&2<3>4\xA0";
    79   is(t.innerHTML, '<div>1&amp;2&lt;3&gt;4&nbsp;</div>');
    81   t.innerHTML = null;
    82   t.appendChild(document.createElement("script"));
    83   t.firstChild.textContent = "1&2<3>4\xA0";
    84   is(t.innerHTML, '<script>1&2<3>4\xA0\u003C/script>');
    86   t.innerHTML = null;
    87   t.appendChild(document.createElement("style"));
    88   t.firstChild.textContent = "1&2<3>4\xA0";
    89   is(t.innerHTML, '<style>1&2<3>4\xA0\u003C/style>');
    91   t.innerHTML = null;
    92   t.appendChild(document.createElement("span"));
    93   t.firstChild.setAttributeNS("ext", "attr", "foo");
    94   t.firstChild.textContent = "1&2<3>4\xA0";
    95   is(t.innerHTML, '<span attr="foo">1&amp;2&lt;3&gt;4&nbsp;\u003C/span>');
    97   t.innerHTML = null;
    98   t.appendChild(document.createElementNS("http://www.w3.org/2000/svg", "svg"));
    99   is(t.firstChild.namespaceURI, "http://www.w3.org/2000/svg");
   100   t.firstChild.appendChild(document.createElementNS("http://www.w3.org/2000/svg", "script"));
   101   is(t.firstChild.firstChild.namespaceURI, "http://www.w3.org/2000/svg");
   102   t.firstChild.firstChild.textContent = "1&2<3>4\xA0";
   103   is(t.innerHTML, '<svg><script>1&amp;2&lt;3&gt;4&nbsp;\u003C/script></svg>');
   105   t.innerHTML = null;
   106   t.appendChild(document.createElementNS("http://www.w3.org/2000/svg", "svg"));
   107   is(t.firstChild.namespaceURI, "http://www.w3.org/2000/svg");
   108   t.firstChild.appendChild(document.createElementNS("http://www.w3.org/2000/svg", "style"));
   109   is(t.firstChild.firstChild.namespaceURI, "http://www.w3.org/2000/svg");
   110   t.firstChild.firstChild.textContent = "1&2<3>4\xA0";
   111   is(t.innerHTML, '<svg><style>1&amp;2&lt;3&gt;4&nbsp;\u003C/style></svg>');
   113   t.innerHTML = null;
   114   t.appendChild(document.createElementNS("http://www.w3.org/1998/Math/MathML", "math"));
   115   is(t.firstChild.namespaceURI, "http://www.w3.org/1998/Math/MathML");
   116   t.firstChild.appendChild(document.createElementNS("http://www.w3.org/1998/Math/MathML", "script"));
   117   is(t.firstChild.firstChild.namespaceURI, "http://www.w3.org/1998/Math/MathML");
   118   t.firstChild.firstChild.textContent = "1&2<3>4\xA0";
   119   is(t.innerHTML, '<math><script>1&amp;2&lt;3&gt;4&nbsp;\u003C/script></math>');
   121   t.innerHTML = null;
   122   t.appendChild(document.createElementNS("http://www.w3.org/1998/Math/MathML", "math"));
   123   is(t.firstChild.namespaceURI, "http://www.w3.org/1998/Math/MathML");
   124   t.firstChild.appendChild(document.createElementNS("http://www.w3.org/1998/Math/MathML", "style"));
   125   is(t.firstChild.firstChild.namespaceURI, "http://www.w3.org/1998/Math/MathML");
   126   t.firstChild.firstChild.textContent = "1&2<3>4\xA0";
   127   is(t.innerHTML, '<math><style>1&amp;2&lt;3&gt;4&nbsp;\u003C/style></math>');
   128 </script>
   129 </pre>
   130 </body>
   131 </html>

mercurial