1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/events/test/test_bug288392.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,97 @@ 1.4 +<!DOCTYPE HTML> 1.5 +<html> 1.6 +<!-- 1.7 +https://bugzilla.mozilla.org/show_bug.cgi?id=288392 1.8 +--> 1.9 +<head> 1.10 + <title>Test for Bug 288392</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> 1.15 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=288392">Mozilla Bug 288392</a> 1.16 +<p id="display"></p> 1.17 +<div id="content" style="display: none"> 1.18 +<div id="mutationTarget"> 1.19 +</div> 1.20 +</div> 1.21 +<pre id="test"> 1.22 +<script class="testbody" type="text/javascript"> 1.23 + 1.24 +/** Test for Bug 288392 **/ 1.25 +var subtreeModifiedCount; 1.26 + 1.27 +function subtreeModified(e) 1.28 +{ 1.29 + ++subtreeModifiedCount; 1.30 +} 1.31 + 1.32 +function doTest() { 1.33 + var targetNode = document.getElementById("mutationTarget"); 1.34 + targetNode.addEventListener("DOMSubtreeModified", subtreeModified, false); 1.35 + 1.36 + subtreeModifiedCount = 0; 1.37 + var temp = document.createElement("DIV"); 1.38 + targetNode.appendChild(temp); 1.39 + is(subtreeModifiedCount, 1, 1.40 + "Appending a child node should have dispatched a DOMSubtreeModified event"); 1.41 + 1.42 + subtreeModifiedCount = 0; 1.43 + temp.setAttribute("foo", "bar"); 1.44 + is(subtreeModifiedCount, 1, 1.45 + "Setting an attribute should have dispatched a DOMSubtreeModified event"); 1.46 + 1.47 + subtreeModifiedCount = 0; 1.48 + targetNode.removeChild(temp); 1.49 + is(subtreeModifiedCount, 1, 1.50 + "Removing a child node should have dispatched a DOMSubtreeModified event"); 1.51 + 1.52 + // Testing events in a subtree, which is not in the document. 1.53 + var subtree = document.createElement("div"); 1.54 + var s = "<e1 attr1='value1'>Something1</e1><e2 attr2='value2'>Something2</e2>"; 1.55 + subtree.innerHTML = s; 1.56 + subtree.addEventListener("DOMSubtreeModified", subtreeModified, false); 1.57 + 1.58 + subtreeModifiedCount = 0; 1.59 + subtree.firstChild.firstChild.data = "foo"; 1.60 + is(subtreeModifiedCount, 1, 1.61 + "Editing character data should have dispatched a DOMSubtreeModified event"); 1.62 + 1.63 + subtreeModifiedCount = 0; 1.64 + subtree.firstChild.removeChild(subtree.firstChild.firstChild); 1.65 + is(subtreeModifiedCount, 1, 1.66 + "Removing a child node should have dispatched a DOMSubtreeModified event"); 1.67 + 1.68 + subtreeModifiedCount = 0; 1.69 + subtree.firstChild.setAttribute("foo", "bar"); 1.70 + is(subtreeModifiedCount, 1, 1.71 + "Setting an attribute should have dispatched a DOMSubtreeModified event"); 1.72 + 1.73 + subtreeModifiedCount = 0; 1.74 + subtree.textContent = "foobar"; 1.75 + is(subtreeModifiedCount, 1, 1.76 + "Setting .textContent should have dispatched a DOMSubtreeModified event"); 1.77 + 1.78 + subtreeModifiedCount = 0; 1.79 + subtree.innerHTML = s; 1.80 + is(subtreeModifiedCount, 1, 1.81 + "Setting .innerHTML should have dispatched a DOMSubtreeModified event"); 1.82 + 1.83 + subtreeModifiedCount = 0; 1.84 + subtree.removeEventListener("DOMSubtreeModified", subtreeModified, false); 1.85 + subtree.appendChild(document.createTextNode("")); 1.86 + subtree.addEventListener("DOMSubtreeModified", subtreeModified, false); 1.87 + subtree.normalize(); 1.88 + is(subtreeModifiedCount, 1, 1.89 + "Calling normalize() should have dispatched a DOMSubtreeModified event"); 1.90 +} 1.91 + 1.92 +SimpleTest.waitForExplicitFinish(); 1.93 +addLoadEvent(doTest); 1.94 +addLoadEvent(SimpleTest.finish); 1.95 + 1.96 +</script> 1.97 +</pre> 1.98 +</body> 1.99 +</html> 1.100 +