Bug 1075702 - Added mochitest for Element.setAttributeNode(). r=bz
authorAnuj Agarwal <anujagarwal464@gmail.com>
Thu, 15 Jan 2015 05:13:00 +0100
changeset 224169 bafcd4598f5d41c4ee76f8722a0f22224e216c03
parent 224168 acc9dcd07546c13e4ddafe04f36b9069b1ed38e9
child 224170 d5092aaecfca907b4d4d29276020f03689858ddf
push id54148
push usercbook@mozilla.com
push dateFri, 16 Jan 2015 13:24:28 +0000
treeherdermozilla-inbound@6c227c0e4d60 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs1075702
milestone38.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1075702 - Added mochitest for Element.setAttributeNode(). r=bz
dom/base/test/mochitest.ini
dom/base/test/test_bug1075702.html
--- a/dom/base/test/mochitest.ini
+++ b/dom/base/test/mochitest.ini
@@ -652,16 +652,17 @@ skip-if = buildapp == 'mulet' || buildap
 [test_bug922681.html]
 [test_bug927196.html]
 [test_bug945152.html]
 run-if = os == 'linux'
 [test_bug982153.html]
 [test_bug1008126.html]
 run-if = os == 'linux'
 [test_bug1057176.html]
+[test_bug1075702.html]
 [test_bug1101364.html]
 skip-if = buildapp == 'mulet' || buildapp == 'b2g' || toolkit == 'android'
 [test_caretPositionFromPoint.html]
 [test_classList.html]
 # This test fails on the Mac for some reason
 [test_copyimage.html]
 skip-if = (buildapp == 'b2g' && toolkit != 'gonk') || toolkit != 'gtk2' && toolkit != 'gtk3' && toolkit != 'windows' || e10s #b2g-desktop(Bug 931116, b2g desktop specific, initial triage)
 [test_copypaste.html]
new file mode 100644
--- /dev/null
+++ b/dom/base/test/test_bug1075702.html
@@ -0,0 +1,69 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=1075702
+-->
+<head>
+  <meta charset="utf-8">
+  <title> Test for Bug 1075702 </title>
+  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"> </script>
+  <script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"> </script>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1075702"> Mozilla Bug 1075702 </a>
+<p id="display"></p>
+
+<pre id="test">
+<script type="application/javascript">
+
+  /** Test for Bug 1075702 **/
+  // test: Element.removeAttributeNode()
+
+  var a1 = document.createAttribute("aa");
+  a1.nodeValue = "lowercase";
+
+  var a2 = document.createAttribute("AA");
+  a2.nodeValue = "UPPERCASE";
+
+  document.documentElement.setAttributeNode(a1);
+  document.documentElement.setAttributeNode(a2);
+
+  is(document.documentElement.getAttributeNS("", "aa"), null, "Should be NULL!");
+  is(document.documentElement.getAttributeNS("", "AA"), "UPPERCASE", "Should be UPPERCASE!");
+
+  var removedNodeAccordingToEvent;
+
+  function mutationHandler(aEvent) {
+    removedNodeAccordingToEvent = aEvent.relatedNode;
+  }
+
+  var test1 = document.createElement("div");
+  test1.setAttribute("x", "y");
+  removedNodeAccordingToEvent = null;
+
+  function testremoveNamedItemNS() {
+    test1.addEventListener("DOMAttrModified", mutationHandler, true);
+    var removedNodeAccordingToRemoveNamedItemNS = test1.attributes.removeNamedItemNS(null, "x");
+    test1.removeEventListener("DOMAttrModified", mutationHandler, true);
+    ise(removedNodeAccordingToEvent, removedNodeAccordingToRemoveNamedItemNS, "Node removed according to event is not same as node removed by removeNamedItemNS.");
+  }
+
+  testremoveNamedItemNS();
+
+  var test2 = document.createElement("div");
+  test2.setAttribute("x", "y");
+  removedNodeAccordingToEvent = null;
+
+  function testremoveNamedItem() {
+    test2.addEventListener("DOMAttrModified", mutationHandler, true);
+    var removedNodeAccordingToRemoveNamedItem = test2.attributes.removeNamedItem("x");
+    test2.removeEventListener("DOMAttrModified", mutationHandler, true);
+    ise(removedNodeAccordingToEvent, removedNodeAccordingToRemoveNamedItem, "Node removed according to event is not same as node removed by removeNamedItem.");
+  }
+
+  testremoveNamedItem();
+
+</script>
+</body>
+</html>