1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/content/base/test/test_bug311681.xml Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,103 @@ 1.4 +<html xmlns="http://www.w3.org/1999/xhtml"> 1.5 +<!-- 1.6 +https://bugzilla.mozilla.org/show_bug.cgi?id=311681 1.7 +--> 1.8 +<head> 1.9 + <title>Test for Bug 311681</title> 1.10 + <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> 1.11 + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> 1.12 +</head> 1.13 +<body> 1.14 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=311681">Mozilla Bug 311681</a> 1.15 +<script class="testbody" type="text/javascript"> 1.16 +<![CDATA[ 1.17 + // Setup script 1.18 + SimpleTest.waitForExplicitFinish(); 1.19 + 1.20 + // Make sure to trigger the hashtable case by asking for enough elements 1.21 + // by ID. 1.22 + for (var i = 0; i < 256; ++i) { 1.23 + var x = document.getElementById(i); 1.24 + } 1.25 + 1.26 + // save off the document.getElementById function, since getting it as a 1.27 + // property off the document it causes a content flush. 1.28 + var fun = document.getElementById; 1.29 + 1.30 + // Slot for our initial element with id "content" 1.31 + var testNode; 1.32 + 1.33 + function getCont() { 1.34 + return fun.call(document, "content"); 1.35 + } 1.36 + 1.37 + function testClone() { 1.38 + // Test to make sure that if we have multiple nodes with the same ID in 1.39 + // a document we don't forget about one of them when the other is 1.40 + // removed. 1.41 + var newParent = $("display"); 1.42 + var node = testNode.cloneNode(true); 1.43 + isnot(node, testNode, "Clone should be a different node"); 1.44 + 1.45 + newParent.appendChild(node); 1.46 + 1.47 + // Check what getElementById returns, no flushing 1.48 + is(getCont(), node, "Should be getting orig node pre-flush 1"); 1.49 + 1.50 + // Trigger a layout flush, just in case. 1.51 + var itemHeight = newParent.offsetHeight/10; 1.52 + 1.53 + // Check what getElementById returns now. 1.54 + is(getCont(), node, "Should be getting new node post-flush 1"); 1.55 + 1.56 + clear(newParent); 1.57 + 1.58 + // Check what getElementById returns, no flushing 1.59 + is(getCont(), testNode, "Should be getting orig node pre-flush 2"); 1.60 + 1.61 + // Trigger a layout flush, just in case. 1.62 + var itemHeight = newParent.offsetHeight/10; 1.63 + 1.64 + // Check what getElementById returns now. 1.65 + is(getCont(), testNode, "Should be getting orig node post-flush 2"); 1.66 + 1.67 + node = testNode.cloneNode(true); 1.68 + newParent.appendChild(node); 1.69 + testNode.parentNode.removeChild(testNode); 1.70 + 1.71 + // Check what getElementById returns, no flushing 1.72 + is(getCont(), node, "Should be getting clone pre-flush"); 1.73 + 1.74 + // Trigger a layout flush, just in case. 1.75 + var itemHeight = newParent.offsetHeight/10; 1.76 + 1.77 + // Check what getElementById returns now. 1.78 + is(getCont(), node, "Should be getting clone post-flush"); 1.79 + 1.80 + } 1.81 + 1.82 + function clear(node) { 1.83 + while (node.hasChildNodes()) { 1.84 + node.removeChild(node.firstChild); 1.85 + } 1.86 + } 1.87 + 1.88 + addLoadEvent(testClone); 1.89 + addLoadEvent(SimpleTest.finish); 1.90 +]]> 1.91 +</script> 1.92 +<p id="display"></p> 1.93 +<div id="content" style="display: none"> 1.94 + <script class="testbody" type="text/javascript"> 1.95 + <![CDATA[ 1.96 + testNode = fun.call(document, "content"); 1.97 + // Needs incremental XML parser 1.98 + isnot(testNode, null, "Should have node here"); 1.99 + ]]> 1.100 + </script> 1.101 +</div> 1.102 +<pre id="test"> 1.103 +</pre> 1.104 +</body> 1.105 +</html> 1.106 +