test_bug1070015.html (1626B)
1 <!DOCTYPE HTML> 2 <html> 3 <!-- 4 https://bugzilla.mozilla.org/show_bug.cgi?id=1070015 5 --> 6 <head> 7 <title>Test for Bug 1070015</title> 8 <script src="/tests/SimpleTest/SimpleTest.js"></script> 9 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> 10 </head> 11 <body> 12 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1070015">Mozilla Bug 1070015</a> 13 <p id="display"></p> 14 <div id="content" style="display: none"> 15 16 </div> 17 <div id="attrTest1" testAttr="testValue1"></div> 18 <div id="attrTest2" testAttr="testValue2"></div> 19 <pre id="test"> 20 <script type="application/javascript"> 21 22 /** Test for Bug 1070015 */ 23 24 function testRemoveAttribute() { 25 var attrTest1 = document.getElementById("attrTest1"); 26 var attr1 = attrTest1.getAttributeNode("testAttr"); 27 28 var attrTest2 = document.getElementById("attrTest2"); 29 var attr2 = attrTest2.getAttributeNode("testAttr"); 30 31 ok(attrTest1.hasAttribute("testAttr"), "First object should have attribute"); 32 ok(attrTest2.hasAttribute("testAttr"), "Second object should have attribute"); 33 34 try { 35 attrTest1.removeAttributeNode(attr2); 36 ok(false, "Should throw when removing from the different element"); 37 } catch (e) { 38 ok(true, "Should throw when removing from the different element"); 39 } 40 41 ok(attrTest1.hasAttribute("testAttr"), "Object should not remove attribute which not belongs to it"); 42 ok(attrTest2.hasAttribute("testAttr"), "Object should not be changed"); 43 44 attrTest1.removeAttributeNode(attr1); 45 ok(!attrTest1.hasAttribute("testAttr"), "Object should remove its attribute"); 46 } 47 testRemoveAttribute(); 48 49 </script> 50 </pre> 51 </body> 52 </html>