4 https://bugzilla.mozilla.org/show_bug.cgi?id=288392
7 <title>Test for Bug
288392</title>
8 <script src=
"/tests/SimpleTest/SimpleTest.js"></script>
9 <link rel=
"stylesheet" type=
"text/css" href=
"/tests/SimpleTest/test.css" />
12 <a target=
"_blank" href=
"https://bugzilla.mozilla.org/show_bug.cgi?id=288392">Mozilla Bug
288392</a>
14 <div id=
"content" style=
"display: none">
15 <div id=
"mutationTarget">
19 <script class=
"testbody" type=
"text/javascript">
21 /** Test for Bug
288392 **/
22 var subtreeModifiedCount;
24 function subtreeModified(e)
26 ++subtreeModifiedCount;
30 var targetNode = document.getElementById(
"mutationTarget");
31 targetNode.addEventListener(
"DOMSubtreeModified", subtreeModified);
33 subtreeModifiedCount =
0;
34 var temp = document.createElement(
"DIV");
35 targetNode.appendChild(temp);
36 is(subtreeModifiedCount,
1,
37 "Appending a child node should have dispatched a DOMSubtreeModified event");
39 subtreeModifiedCount =
0;
40 temp.setAttribute(
"foo",
"bar");
41 is(subtreeModifiedCount,
1,
42 "Setting an attribute should have dispatched a DOMSubtreeModified event");
44 subtreeModifiedCount =
0;
45 targetNode.removeChild(temp);
46 is(subtreeModifiedCount,
1,
47 "Removing a child node should have dispatched a DOMSubtreeModified event");
49 // Testing events in a subtree, which is not in the document.
50 var subtree = document.createElement(
"div");
51 var s =
"<e1 attr1='value1'>Something1</e1><e2 attr2='value2'>Something2</e2>";
52 subtree.innerHTML = s;
53 subtree.addEventListener(
"DOMSubtreeModified", subtreeModified);
55 subtreeModifiedCount =
0;
56 subtree.firstChild.firstChild.data =
"foo";
57 is(subtreeModifiedCount,
1,
58 "Editing character data should have dispatched a DOMSubtreeModified event");
60 subtreeModifiedCount =
0;
61 subtree.firstChild.removeChild(subtree.firstChild.firstChild);
62 is(subtreeModifiedCount,
1,
63 "Removing a child node should have dispatched a DOMSubtreeModified event");
65 subtree.innerHTML = s;
66 subtreeModifiedCount =
0;
67 subtree.firstChild.firstChild.remove();
68 is(subtreeModifiedCount,
1,
69 "Removing a child node should have dispatched a DOMSubtreeModified event");
71 subtreeModifiedCount =
0;
72 subtree.firstChild.setAttribute(
"foo",
"bar");
73 is(subtreeModifiedCount,
1,
74 "Setting an attribute should have dispatched a DOMSubtreeModified event");
76 subtreeModifiedCount =
0;
77 subtree.textContent =
"foobar";
78 is(subtreeModifiedCount,
1,
79 "Setting .textContent should have dispatched a DOMSubtreeModified event");
81 subtreeModifiedCount =
0;
82 subtree.innerHTML = s;
83 is(subtreeModifiedCount,
1,
84 "Setting .innerHTML should have dispatched a DOMSubtreeModified event");
86 subtreeModifiedCount =
0;
87 subtree.removeEventListener(
"DOMSubtreeModified", subtreeModified);
88 subtree.appendChild(document.createTextNode(
""));
89 subtree.addEventListener(
"DOMSubtreeModified", subtreeModified);
91 is(subtreeModifiedCount,
1,
92 "Calling normalize() should have dispatched a DOMSubtreeModified event");
95 SimpleTest.waitForExplicitFinish();
97 addLoadEvent(SimpleTest.finish);