author | Andrea Marchesini <amarchesini@mozilla.com> |
Mon, 13 May 2013 09:22:30 -0400 | |
changeset 131759 | 3411817d911f168e6aa561aa5e6313cbff911ff7 |
parent 131758 | 74044ef81d275ac629c07c5aa9a16d699e1d977b |
child 131760 | b4ec5d600b9011f05de78f03043f8182948e8cf2 |
push id | 27962 |
push user | ryanvm@gmail.com |
push date | Mon, 13 May 2013 13:22:38 +0000 |
treeherder | mozilla-inbound@3411817d911f [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | Ms2ger |
bugs | 869006 |
milestone | 23.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
|
--- a/content/base/src/Comment.cpp +++ b/content/base/src/Comment.cpp @@ -55,16 +55,29 @@ Comment::List(FILE* out, int32_t aIndent nsAutoString tmp; ToCString(tmp, 0, mText.GetLength()); fputs(NS_LossyConvertUTF16toASCII(tmp).get(), out); fputs("-->\n", out); } #endif +/* static */ already_AddRefed<Comment> +Comment::Constructor(const GlobalObject& aGlobal, const nsAString& aData, + ErrorResult& aRv) +{ + nsCOMPtr<nsPIDOMWindow> 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<JSObject*> aScope) { return CommentBinding::Wrap(aCx, aScope, this); } } // namespace dom } // namespace mozilla
--- a/content/base/src/Comment.h +++ b/content/base/src/Comment.h @@ -61,16 +61,20 @@ public: virtual void List(FILE* out, int32_t aIndent) const; virtual void DumpContent(FILE* out = stdout, int32_t aIndent = 0, bool aDumpAll = true) const { return; } #endif + static already_AddRefed<Comment> + Constructor(const GlobalObject& aGlobal, const nsAString& aData, + ErrorResult& aRv); + protected: virtual JSObject* WrapNode(JSContext *aCx, JS::Handle<JSObject*> aScope) MOZ_OVERRIDE; }; } // namespace dom } // namespace mozilla
--- a/content/base/test/Makefile.in +++ b/content/base/test/Makefile.in @@ -620,16 +620,17 @@ MOCHITEST_FILES_C= \ test_bug814576.html \ test_xhr_withCredentials.html \ test_bothCSPheaders.html \ file_bothCSPheaders.html \ file_bothCSPheaders.html^headers^ \ badMessageEvent2.eventsource \ badMessageEvent2.eventsource^headers^ \ test_object.html \ + test_bug869006.html \ $(NULL) # OOP tests don't work on Windows (bug 763081) or native-fennec # (see Bug 774939) ifneq ($(OS_ARCH),WINNT) ifndef MOZ_ANDROID_OMTC MOCHITEST_FILES_B += \ test_messagemanager_assertpermission.html \
new file mode 100644 --- /dev/null +++ b/content/base/test/test_bug869006.html @@ -0,0 +1,37 @@ +<!DOCTYPE HTML> +<html> +<!-- +https://bugzilla.mozilla.org/show_bug.cgi?id=869006 +--> +<head> + <meta charset="utf-8"> + <title>Test for Bug 869006</title> + <script type="application/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=869006">Mozilla Bug 869006</a> +<p id="display"></p> +<div id="content" style="display: none"> + +</div> +<pre id="test"> +<script type="application/javascript"> + +/** Test for Bug 869006 **/ + +var c = new Comment(); +ok(c, "Comment has been created without content"); +is(c.data, "", "Comment.data is ok"); + +c = new Comment('foo'); +ok(c, "Comment has been created"); +is(c.data, "foo", "Comment.data is ok"); + +document.appendChild(c); +ok(true, "Comment has been added to the document"); + +</script> +</pre> +</body> +</html>
--- a/dom/webidl/Comment.webidl +++ b/dom/webidl/Comment.webidl @@ -5,10 +5,11 @@ * * The origin of this IDL file is * http://dom.spec.whatwg.org/#comment * * Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C * liability, trademark and document use rules apply. */ +[Constructor(optional DOMString data = "")] interface Comment : CharacterData { };