Bug 922681 part 2 - Add some innerHTML tests. r=bz
authorJan de Mooij <jdemooij@mozilla.com>
Wed, 18 Dec 2013 11:01:49 +0100
changeset 161031 2ca8e48896c4f8bcfa4c37c73c65301537bfa37f
parent 161030 8939e7f497dbb73fa0e31de78eea8bee70623ec7
child 161032 1a5bb2f11bfbe6e78ece53969c5ded269a41876d
child 161059 fff2e3ac46f071edd3cf6fb6d98c5bfd121b17ee
push id3375
push usercbook@mozilla.com
push dateWed, 18 Dec 2013 15:11:08 +0000
treeherderb2g-inbound@e2a8732088de [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs922681
milestone29.0a1
Bug 922681 part 2 - Add some innerHTML tests. r=bz
content/base/test/mochitest.ini
content/base/test/test_bug922681.html
--- a/content/base/test/mochitest.ini
+++ b/content/base/test/mochitest.ini
@@ -517,16 +517,17 @@ skip-if = toolkit == "gonk" # bug 945189
 [test_bug869006.html]
 [test_bug876282.html]
 [test_bug890580.html]
 [test_bug894874.html]
 [test_bug895239.html]
 [test_bug895974.html]
 [test_bug902847.html]
 [test_bug907892.html]
+[test_bug922681.html]
 [test_bug927196.html]
 [test_caretPositionFromPoint.html]
 [test_classList.html]
 [test_copypaste.html]
 [test_copypaste.xhtml]
 [test_createHTMLDocument.html]
 [test_declare_stylesheet_obsolete.html]
 [test_domparser_null_char.html]
new file mode 100644
--- /dev/null
+++ b/content/base/test/test_bug922681.html
@@ -0,0 +1,113 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=922681
+-->
+<head>
+  <meta charset="utf-8">
+  <title>Test for Bug 922681</title>
+  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+  <script type="application/javascript">
+  function testInnerHTMLParserInsertionMode() {
+
+    function testInnerHTML(el, input, output) {
+        el.innerHTML = input;
+        is(el.innerHTML, output, el.tagName.toLowerCase() + ': "' + input + '"');
+    }
+
+    var c;
+
+    c = document.createElement("html");
+    testInnerHTML(c, "", "<head></head><body></body>");
+    testInnerHTML(c, "xyz", "<head></head><body>xyz</body>");
+    testInnerHTML(c, "<input>", "<head></head><body><input></body>");
+
+    c = document.createElement("colgroup");
+    testInnerHTML(c, "abcdef", "");
+    testInnerHTML(c, "", "");
+    testInnerHTML(c, "\n", "\n");
+    testInnerHTML(c, "<col>", "<col>");
+
+    c = document.createElement("select");
+    testInnerHTML(c, "123", "123");
+    testInnerHTML(c, "<input>", "");
+    testInnerHTML(c, "\0", "");
+    testInnerHTML(c, "<col>", "");
+    testInnerHTML(c, "<option>", "<option></option>");
+
+    c = document.createElement("head");
+    testInnerHTML(c, "123", "123");
+    testInnerHTML(c, "\n", "\n");
+
+    c = document.createElement("frameset");
+    testInnerHTML(c, "456", "");
+    testInnerHTML(c, "\n", "\n");
+    testInnerHTML(c, "<input>", "");
+    testInnerHTML(c, "\0", "");
+
+    c = document.createElement("table");
+    testInnerHTML(c, "abc", "abc");
+    testInnerHTML(c, "<td>", "<tbody><tr><td></td></tr></tbody>");
+    testInnerHTML(c, "</body>", "");
+    testInnerHTML(c, "<input>", "<input>");
+
+    c = document.createElement("tr");
+    testInnerHTML(c, "xyz", "xyz");
+    testInnerHTML(c, "<td>", "<td></td>");
+    testInnerHTML(c, "</body>", "");
+    testInnerHTML(c, "<table>", "");
+
+    c = document.createElement("td");
+    testInnerHTML(c, "789", "789");
+    testInnerHTML(c, "\0", "");
+    testInnerHTML(c, "<td>", "");
+
+    c = document.createElement("th");
+    testInnerHTML(c, "789", "789");
+    testInnerHTML(c, "\0", "");
+    testInnerHTML(c, "</tr>", "");
+
+    c = document.createElement("caption");
+    testInnerHTML(c, "xyz", "xyz");
+    testInnerHTML(c, "\0", "");
+    testInnerHTML(c, "<td>", "");
+    testInnerHTML(c, "<dd>", "<dd></dd>");
+    testInnerHTML(c, "<body>", "");
+
+    function testTableBody(tag) {
+        var c = document.createElement(tag);
+        testInnerHTML(c, "abc", "abc");
+        testInnerHTML(c, "<td>", "<tr><td></td></tr>");
+        testInnerHTML(c, "</body>", "");
+        testInnerHTML(c, "<input>", "<input>");
+    }
+    testTableBody("thead");
+    testTableBody("tbody");
+    testTableBody("tfoot");
+
+    c = document.createElement("template");
+    testInnerHTML(c, "abc", "abc");
+    testInnerHTML(c, "<td>", "<td></td>");
+    testInnerHTML(c, "</template>", "");
+    testInnerHTML(c, "<input>", "<input>");
+
+    c = document.createElement("div");
+    testInnerHTML(c, "abc", "abc");
+    testInnerHTML(c, "<td>", "");
+    testInnerHTML(c, "</body>", "");
+    testInnerHTML(c, "<input>", "<input>");
+
+    SimpleTest.finish();
+  }
+
+  addLoadEvent(testInnerHTMLParserInsertionMode);
+  SimpleTest.waitForExplicitFinish();
+  </script>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=922681">Mozilla Bug 922681</a>
+<pre id="test">
+</pre>
+</body>
+</html>