test_anonymousContent_insert.html (1540B)
1 <!DOCTYPE HTML> 2 <html> 3 <!-- 4 https://bugzilla.mozilla.org/show_bug.cgi?id=1020244 5 --> 6 <meta charset="utf-8"> 7 <title>Test for Bug 1020244 - Insert content using the AnonymousContent API, several times, and don't remove it</title> 8 <script src="/tests/SimpleTest/SimpleTest.js"></script> 9 <link rel="stylesheet" href="/tests/SimpleTest/test.css"/> 10 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1020244">Mozilla Bug 1020244</a> 11 <div> 12 <div id="id" class="test">text content</div> 13 </div> 14 <script> 15 const INSERTED_NB = 5; 16 17 // Insert the same content several times 18 let chromeDocument = SpecialPowers.wrap(document); 19 let testElement = document.querySelector("div"); 20 21 let anonymousContents = []; 22 for (let i = 0; i < INSERTED_NB; i ++) { 23 let content = chromeDocument.insertAnonymousContent(); 24 content.root.appendChild(testElement.cloneNode(true)); 25 // Adding an expando pointing to the document to make sure this doesn't 26 // cause leaks. 27 content.dummyExpando = testElement.ownerDocument; 28 anonymousContents.push(content); 29 } 30 31 // Make sure that modifying one of the inserted elements does not modify the 32 // other ones. 33 anonymousContents[0].root.getElementById("id").className = "updated"; 34 for (let i = 1; i < INSERTED_NB; i ++) { 35 is( 36 anonymousContents[i].root.getElementById("id").className, 37 "test", 38 "Element " + i + " didn't change when element 0 was changed" 39 ); 40 } 41 // Do not remove inserted elements on purpose to test for potential leaks too. 42 </script>