summaryrefslogtreecommitdiffstats
path: root/dom/events/test/test_bug328885.html
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /dom/events/test/test_bug328885.html
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'dom/events/test/test_bug328885.html')
-rw-r--r--dom/events/test/test_bug328885.html134
1 files changed, 134 insertions, 0 deletions
diff --git a/dom/events/test/test_bug328885.html b/dom/events/test/test_bug328885.html
new file mode 100644
index 000000000..5af2d5611
--- /dev/null
+++ b/dom/events/test/test_bug328885.html
@@ -0,0 +1,134 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=328885
+-->
+<head>
+ <title>Test for Bug 328885</title>
+ <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=328885">Mozilla Bug 328885</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+
+</div>
+<input type="text" id="inputelement"
+ style="position: absolute; left: 0px; top: 0px;">
+<pre id="test">
+<script class="testbody" type="text/javascript">
+
+/** Test for Bug 328885 **/
+
+ var inputelement = null;
+ var mutationCount = 0;
+
+ function mutationListener(evt) {
+ ++mutationCount;
+ }
+
+ function clickTest() {
+ inputelement.addEventListener("DOMSubtreeModified", mutationListener, false);
+ inputelement.addEventListener("DOMNodeInserted", mutationListener, false);
+ inputelement.addEventListener("DOMNodeRemoved", mutationListener, false);
+ inputelement.addEventListener("DOMNodeRemovedFromDocument", mutationListener, false);
+ inputelement.addEventListener("DOMNodeInsertedIntoDocument", mutationListener, false);
+ inputelement.addEventListener("DOMAttrModified", mutationListener, false);
+ inputelement.addEventListener("DOMCharacterDataModified", mutationListener, false);
+
+ inputelement.addEventListener('click',
+ function(event) {
+ var evt = SpecialPowers.wrap(event);
+ ok(SpecialPowers.unwrap(evt.originalTarget) instanceof HTMLDivElement,
+ "(1) Wrong originalTarget!");
+ is(SpecialPowers.unwrap(evt.originalTarget.parentNode), inputelement,
+ "(2) Wront parent node!");
+ ok(mutationCount == 0, "(3) No mutations should have happened! [" + mutationCount + "]");
+ evt.originalTarget.textContent = "foo";
+ ok(mutationCount == 0, "(4) Mutation listener shouldn't have been called! [" + mutationCount + "]");
+ evt.originalTarget.innerHTML = "foo2";
+ ok(mutationCount == 0, "(5) Mutation listener shouldn't have been called! [" + mutationCount + "]");
+ evt.originalTarget.lastChild.data = "bar";
+ ok(mutationCount == 0, "(6) Mutation listener shouldn't have been called! [" + mutationCount + "]");
+
+ var r = SpecialPowers.wrap(document.createRange());
+ r.selectNodeContents(evt.originalTarget);
+ r.deleteContents();
+ ok(mutationCount == 0, "(7) Mutation listener shouldn't have been called! [" + mutationCount + "]");
+
+ evt.originalTarget.textContent = "foo";
+ ok(mutationCount == 0, "(8) Mutation listener shouldn't have been called! [" + mutationCount + "]");
+ r = SpecialPowers.wrap(document.createRange());
+ r.selectNodeContents(evt.originalTarget);
+ r.extractContents();
+ ok(mutationCount == 0, "(9) Mutation listener shouldn't have been called! [" + mutationCount + "]");
+
+ evt.originalTarget.setAttribute("foo", "bar");
+ ok(mutationCount == 0, "(10) Mutation listener shouldn't have been called! ["+ mutationCount + "]");
+
+ // Same tests with non-native-anononymous element.
+ // mutationCount should be increased by 2 each time, since there is
+ // first a mutation specific event and then DOMSubtreeModified.
+ inputelement.textContent = "foo";
+ ok(mutationCount == 2, "(11) Mutation listener should have been called! [" + mutationCount + "]");
+ inputelement.lastChild.data = "bar";
+ ok(mutationCount == 4, "(12) Mutation listener should have been called! [" + mutationCount + "]");
+
+ r = document.createRange();
+ r.selectNodeContents(inputelement);
+ r.deleteContents();
+ ok(mutationCount == 6, "(13) Mutation listener should have been called! [" + mutationCount + "]");
+
+ inputelement.textContent = "foo";
+ ok(mutationCount == 8, "(14) Mutation listener should have been called! [" + mutationCount + "]");
+ r = document.createRange();
+ r.selectNodeContents(inputelement);
+ r.extractContents();
+ ok(mutationCount == 10, "(15) Mutation listener should have been called! [" + mutationCount + "]");
+
+ inputelement.setAttribute("foo", "bar");
+ ok(mutationCount == 12, "(16) Mutation listener should have been called! ["+ mutationCount + "]");
+
+ // Then try some mixed mutations. The mutation handler of non-native-a
+ inputelement.addEventListener("DOMAttrModified",
+ function (evt2) {
+ evt.originalTarget.setAttribute("foo", "bar" + mutationCount);
+ ok(evt.originalTarget.getAttribute("foo") == "bar" + mutationCount,
+ "(17) Couldn't update the attribute?!?");
+ }
+ , false);
+ inputelement.setAttribute("foo", "");
+ ok(mutationCount == 14, "(18) Mutation listener should have been called! ["+ mutationCount + "]");
+
+ inputelement.textContent = "foo";
+ ok(mutationCount == 16, "(19) Mutation listener should have been called! ["+ mutationCount + "]");
+ inputelement.addEventListener("DOMCharacterDataModified",
+ function (evt2) {
+ evt.originalTarget.textContent = "bar" + mutationCount;
+ }, false);
+ // This one deletes and inserts a new node, then DOMSubtreeModified.
+ inputelement.textContent = "bar";
+ ok(mutationCount == 19, "(20) Mutation listener should have been called! ["+ mutationCount + "]");
+ }
+ ,false);
+ synthesizeMouseAtCenter(inputelement, {}, window);
+ SimpleTest.finish();
+ }
+
+ function doTest() {
+ inputelement = document.getElementById('inputelement');
+ inputelement.focus();
+ setTimeout(clickTest, 100);
+ }
+
+ SimpleTest.waitForExplicitFinish();
+ SimpleTest.requestFlakyTimeout("untriaged");
+ addLoadEvent(doTest);
+
+</script>
+</pre>
+</body>
+</html>
+