Title: [161867] trunk
Revision
161867
Author
[email protected]
Date
2014-01-13 01:46:57 -0800 (Mon, 13 Jan 2014)

Log Message

Comment should be consructable.
https://bugs.webkit.org/show_bug.cgi?id=115642

Patch by László Langó <[email protected]> on 2014-01-13
Reviewed by Andreas Kling.

Source/WebCore:

http://dom.spec.whatwg.org/#comment
This allows us to do `new Comment('abc')` instead of `document.createComment('abc')`.

Backported from Blink: https://chromium.googlesource.com/chromium/blink/+/06e4a37f6b11348606de5405edac1ada97499d2a%5E%21

Test: fast/dom/Comment/comment-constructor.html

* dom/Comment.cpp:
(WebCore::Comment::create):
* dom/Comment.h:
* dom/Comment.idl:

LayoutTests:

* fast/dom/Comment/comment-constructor-expected.txt: Added.
* fast/dom/Comment/comment-constructor.html: Added.
* fast/dom/dom-constructors-expected.txt:
* fast/dom/dom-constructors.html:

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (161866 => 161867)


--- trunk/LayoutTests/ChangeLog	2014-01-13 09:23:12 UTC (rev 161866)
+++ trunk/LayoutTests/ChangeLog	2014-01-13 09:46:57 UTC (rev 161867)
@@ -1,3 +1,15 @@
+2014-01-13  László Langó  <[email protected]>
+
+        Comment should be consructable.
+        https://bugs.webkit.org/show_bug.cgi?id=115642
+
+        Reviewed by Andreas Kling.
+
+        * fast/dom/Comment/comment-constructor-expected.txt: Added.
+        * fast/dom/Comment/comment-constructor.html: Added.
+        * fast/dom/dom-constructors-expected.txt:
+        * fast/dom/dom-constructors.html:
+
 2014-01-12  Commit Queue  <[email protected]>
 
         Unreviewed, rolling out r161843.

Added: trunk/LayoutTests/fast/dom/Comment/comment-constructor-expected.txt (0 => 161867)


--- trunk/LayoutTests/fast/dom/Comment/comment-constructor-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/Comment/comment-constructor-expected.txt	2014-01-13 09:46:57 UTC (rev 161867)
@@ -0,0 +1,19 @@
+This tests that Comment is constructable.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS new Comment("one").data is "one"
+PASS new Comment().data is ""
+PASS new Comment("two").ownerDocument is document
+PASS typeof new Comment is "object"
+PASS Object.prototype.toString.call(new Comment) is "[object Comment]"
+PASS new Comment instanceof Comment is true
+PASS Object.getPrototypeOf(new Comment) is Comment.prototype
+PASS new innerWindow.Comment("three").ownerDocument is innerDocument
+PASS new innerWindow.Comment instanceof innerWindow.Comment is true
+PASS Object.getPrototypeOf(new innerWindow.Comment) is innerWindow.Comment.prototype
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/fast/dom/Comment/comment-constructor.html (0 => 161867)


--- trunk/LayoutTests/fast/dom/Comment/comment-constructor.html	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/Comment/comment-constructor.html	2014-01-13 09:46:57 UTC (rev 161867)
@@ -0,0 +1,27 @@
+<!DOCTYPE html>
+<body>
+<script src=""
+<script>
+
+description('This tests that Comment is constructable.');
+
+shouldBe('new Comment("one").data', '"one"');
+shouldBe('new Comment().data', '""');
+shouldBe('new Comment("two").ownerDocument', 'document');
+
+shouldBe('typeof new Comment', '"object"');
+shouldBe('Object.prototype.toString.call(new Comment)', '"[object Comment]"');
+shouldBeTrue('new Comment instanceof Comment');
+shouldBe('Object.getPrototypeOf(new Comment)', 'Comment.prototype');
+
+var frame = document.createElement('iframe');
+document.body.appendChild(frame);
+var innerWindow = frame.contentWindow;
+var innerDocument = frame.contentDocument;
+
+shouldBe('new innerWindow.Comment("three").ownerDocument', 'innerDocument')
+shouldBeTrue('new innerWindow.Comment instanceof innerWindow.Comment');
+shouldBe('Object.getPrototypeOf(new innerWindow.Comment)', 'innerWindow.Comment.prototype');
+
+</script>
+<script src=""

Modified: trunk/LayoutTests/fast/dom/dom-constructors-expected.txt (161866 => 161867)


--- trunk/LayoutTests/fast/dom/dom-constructors-expected.txt	2014-01-13 09:23:12 UTC (rev 161866)
+++ trunk/LayoutTests/fast/dom/dom-constructors-expected.txt	2014-01-13 09:46:57 UTC (rev 161867)
@@ -6,7 +6,6 @@
 PASS TryAllocate('Attr') is 'exception'
 PASS TryAllocate('CharacterData') is 'exception'
 PASS TryAllocate('CDATASection') is 'exception'
-PASS TryAllocate('Comment') is 'exception'
 PASS TryAllocate('Document') is 'exception'
 PASS TryAllocate('DocumentFragment') is 'exception'
 PASS TryAllocate('DocumentType') is 'exception'
@@ -129,6 +128,9 @@
 PASS TryAllocate('EventTarget') is 'no constructor'
 PASS TryAllocate('EventListener') is 'no constructor'
 PASS TryAllocate('NPObject') is 'no constructor'
+PASS TryAllocate('Comment') is '[object Comment]'
+PASS TryAllocate('Comment') is '[object Comment]'
+PASS TryAllocate('Comment') is '[object Comment]'
 PASS TryAllocate('DOMParser') is '[object DOMParser]'
 PASS TryAllocate('DOMParser') is '[object DOMParser]'
 PASS TryAllocate('DOMParser') is '[object DOMParser]'

Modified: trunk/LayoutTests/fast/dom/dom-constructors.html (161866 => 161867)


--- trunk/LayoutTests/fast/dom/dom-constructors.html	2014-01-13 09:23:12 UTC (rev 161866)
+++ trunk/LayoutTests/fast/dom/dom-constructors.html	2014-01-13 09:46:57 UTC (rev 161867)
@@ -13,7 +13,7 @@
 // with no arguments. (Some of them may have working constructors that require
 // arguments to be valid.)
 var objects_exception = [
-    'Attr', 'CharacterData', 'CDATASection', 'Comment', 'Document',
+    'Attr', 'CharacterData', 'CDATASection', 'Document',
     'DocumentFragment', 'DocumentType', 'Element', 'Entity',
     'EntityReference', 'HTMLDocument', 'Node', 'Notation',
     'ProcessingInstruction', 'Text', 'HTMLAllCollection', 'HTMLAnchorElement',
@@ -55,7 +55,7 @@
 
 // These objects should have a working constructor.
 var objects_constructor = [
-    'DOMParser', 'XMLHttpRequest', 'XMLSerializer', 'XPathEvaluator',
+    'Comment', 'DOMParser', 'XMLHttpRequest', 'XMLSerializer', 'XPathEvaluator',
     'XSLTProcessor'
 ];
 

Modified: trunk/Source/WebCore/ChangeLog (161866 => 161867)


--- trunk/Source/WebCore/ChangeLog	2014-01-13 09:23:12 UTC (rev 161866)
+++ trunk/Source/WebCore/ChangeLog	2014-01-13 09:46:57 UTC (rev 161867)
@@ -1,3 +1,22 @@
+2014-01-13  László Langó  <[email protected]>
+
+        Comment should be consructable.
+        https://bugs.webkit.org/show_bug.cgi?id=115642
+
+        Reviewed by Andreas Kling.
+
+        http://dom.spec.whatwg.org/#comment
+        This allows us to do `new Comment('abc')` instead of `document.createComment('abc')`.
+
+        Backported from Blink: https://chromium.googlesource.com/chromium/blink/+/06e4a37f6b11348606de5405edac1ada97499d2a%5E%21
+
+        Test: fast/dom/Comment/comment-constructor.html
+
+        * dom/Comment.cpp:
+        (WebCore::Comment::create):
+        * dom/Comment.h:
+        * dom/Comment.idl:
+
 2014-01-13  Commit Queue  <[email protected]>
 
         Unreviewed, rolling out r161808.

Modified: trunk/Source/WebCore/dom/Comment.cpp (161866 => 161867)


--- trunk/Source/WebCore/dom/Comment.cpp	2014-01-13 09:23:12 UTC (rev 161866)
+++ trunk/Source/WebCore/dom/Comment.cpp	2014-01-13 09:46:57 UTC (rev 161867)
@@ -36,6 +36,11 @@
     return adoptRef(new Comment(document, text));
 }
 
+PassRefPtr<Comment> Comment::create(ScriptExecutionContext& context, const String& text)
+{
+    return adoptRef(new Comment(toDocument(context), text));
+}
+
 String Comment::nodeName() const
 {
     return commentAtom.string();

Modified: trunk/Source/WebCore/dom/Comment.h (161866 => 161867)


--- trunk/Source/WebCore/dom/Comment.h	2014-01-13 09:23:12 UTC (rev 161866)
+++ trunk/Source/WebCore/dom/Comment.h	2014-01-13 09:46:57 UTC (rev 161867)
@@ -30,6 +30,7 @@
 class Comment FINAL : public CharacterData {
 public:
     static PassRefPtr<Comment> create(Document&, const String&);
+    static PassRefPtr<Comment> create(ScriptExecutionContext&, const String&);
 
 private:
     Comment(Document&, const String&);

Modified: trunk/Source/WebCore/dom/Comment.idl (161866 => 161867)


--- trunk/Source/WebCore/dom/Comment.idl	2014-01-13 09:23:12 UTC (rev 161866)
+++ trunk/Source/WebCore/dom/Comment.idl	2014-01-13 09:46:57 UTC (rev 161867)
@@ -17,6 +17,9 @@
  * Boston, MA 02110-1301, USA.
  */
 
-interface Comment : CharacterData {
+[
+    Constructor([Default=NullString] optional DOMString data),
+    ConstructorCallWith=ScriptExecutionContext
+] interface Comment : CharacterData {
 };
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to