From edbf1b9d24ad0e4f76db69ee4f83626d599cae86 Mon Sep 17 00:00:00 2001 From: Andrea Marchesini Date: Mon, 13 May 2013 09:22:30 -0400 Subject: [PATCH] Bug 869006 - Comment should be consructable. r=Ms2ger --- content/base/src/Comment.cpp | 13 ++++++++++ content/base/src/Comment.h | 4 +++ content/base/test/Makefile.in | 1 + content/base/test/test_bug869006.html | 37 +++++++++++++++++++++++++++ dom/webidl/Comment.webidl | 1 + 5 files changed, 56 insertions(+) create mode 100644 content/base/test/test_bug869006.html diff --git a/content/base/src/Comment.cpp b/content/base/src/Comment.cpp index 1d3089c7597..6a76cac390c 100644 --- a/content/base/src/Comment.cpp +++ b/content/base/src/Comment.cpp @@ -60,6 +60,19 @@ Comment::List(FILE* out, int32_t aIndent) const } #endif +/* static */ already_AddRefed +Comment::Constructor(const GlobalObject& aGlobal, const nsAString& aData, + ErrorResult& aRv) +{ + nsCOMPtr window = do_QueryInterface(aGlobal.Get()); + if (!window || !window->GetDoc()) { + aRv.Throw(NS_ERROR_FAILURE); + return nullptr; + } + + return window->GetDoc()->CreateComment(aData); +} + JSObject* Comment::WrapNode(JSContext *aCx, JS::Handle aScope) { diff --git a/content/base/src/Comment.h b/content/base/src/Comment.h index 26c9fcbac13..a83fdd3dd01 100644 --- a/content/base/src/Comment.h +++ b/content/base/src/Comment.h @@ -66,6 +66,10 @@ public: } #endif + static already_AddRefed + Constructor(const GlobalObject& aGlobal, const nsAString& aData, + ErrorResult& aRv); + protected: virtual JSObject* WrapNode(JSContext *aCx, JS::Handle aScope) MOZ_OVERRIDE; diff --git a/content/base/test/Makefile.in b/content/base/test/Makefile.in index fc0edf70ad3..6eb1edc4563 100644 --- a/content/base/test/Makefile.in +++ b/content/base/test/Makefile.in @@ -625,6 +625,7 @@ MOCHITEST_FILES_C= \ badMessageEvent2.eventsource \ badMessageEvent2.eventsource^headers^ \ test_object.html \ + test_bug869006.html \ $(NULL) # OOP tests don't work on Windows (bug 763081) or native-fennec diff --git a/content/base/test/test_bug869006.html b/content/base/test/test_bug869006.html new file mode 100644 index 00000000000..94716603094 --- /dev/null +++ b/content/base/test/test_bug869006.html @@ -0,0 +1,37 @@ + + + + + + Test for Bug 869006 + + + + +Mozilla Bug 869006 +

+ +
+
+
+ + diff --git a/dom/webidl/Comment.webidl b/dom/webidl/Comment.webidl index fd775090080..023335f166a 100644 --- a/dom/webidl/Comment.webidl +++ b/dom/webidl/Comment.webidl @@ -10,5 +10,6 @@ * liability, trademark and document use rules apply. */ +[Constructor(optional DOMString data = "")] interface Comment : CharacterData { };