Bug 199959 – Attribute.specified isn't true when attribute set through Attribute.value='string'. r=sicking, sr=bz
authorSmaug <Olli.Pettay@gmail.com>
Sat, 12 Jul 2008 13:05:49 +0200
changeset 15879 f08f6a21deb764e6d104c56ff6901436cdb48d94
parent 15878 b2233053a9415d9762592a934ab45ff10d7c4e1d
child 15880 c5a99dd3ae515b48fe61f8e8d14991b0ae0483a0
push id569
push userdgottwald@mozilla.com
push dateSat, 12 Jul 2008 11:06:10 +0000
treeherderautoland@f08f6a21deb7 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssicking, bz
bugs199959
milestone1.9.1a1pre
Bug 199959 – Attribute.specified isn't true when attribute set through Attribute.value='string'. r=sicking, sr=bz
content/base/src/nsDOMAttribute.cpp
content/base/test/Makefile.in
content/base/test/test_bug199959.html
--- a/content/base/src/nsDOMAttribute.cpp
+++ b/content/base/src/nsDOMAttribute.cpp
@@ -196,21 +196,17 @@ nsDOMAttribute::SetValue(const nsAString
 
   return rv;
 }
 
 NS_IMETHODIMP
 nsDOMAttribute::GetSpecified(PRBool* aSpecified)
 {
   NS_ENSURE_ARG_POINTER(aSpecified);
-
-  nsIContent* content = GetContentInternal();
-  *aSpecified = content && content->HasAttr(mNodeInfo->NamespaceID(),
-                                            mNodeInfo->NameAtom());
-
+  *aSpecified = PR_TRUE;
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDOMAttribute::GetOwnerElement(nsIDOMElement** aOwnerElement)
 {
   NS_ENSURE_ARG_POINTER(aOwnerElement);
 
--- a/content/base/test/Makefile.in
+++ b/content/base/test/Makefile.in
@@ -71,16 +71,17 @@ LIBS += \
   $(XPCOM_GLUE_LDOPTS) \
   $(NSPR_LIBS) \
   $(NULL)
 
 include $(topsrcdir)/config/rules.mk
 
 _TEST_FILES = 	test_bug5141.html \
 		test_bug51034.html \
+		test_bug199959.html \
 		test_bug218236.html \
 		file_bug218236_multipart.txt \
 		file_bug218236_multipart.txt^headers^ \
 		test_bug218277.html \
 		test_bug238409.html \
 		test_bug276037-1.html \
 		test_bug276037-2.xhtml \
 		test_bug308484.html \
new file mode 100644
--- /dev/null
+++ b/content/base/test/test_bug199959.html
@@ -0,0 +1,40 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=199959
+-->
+<head>
+  <title>Test for Bug 199959</title>
+  <script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
+  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.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=199959">Mozilla Bug 199959</a>
+<p id="display"></p>
+<div id="content" style="display: none">
+  
+</div>
+<div id="attrTest" testAttr="testValue"></div>
+<pre id="test">
+<script class="testbody" type="text/javascript">
+
+/** Test for Bug 199959 **/
+
+// From ACID3
+var attrTest = document.getElementById("attrTest");
+var attr = attrTest.getAttributeNode("testAttr");
+ok(attr.specified, "Attribute isn't specified!");
+attrTest.removeAttributeNode(attr);
+ok(attr.specified, "Attribute isn't specified after removal!");
+
+// From bug 199959
+attr = document.createAttribute('foo');
+ok(attr.specified, "Attribute isn't specified!");
+
+
+</script>
+</pre>
+</body>
+</html>
+