Diff
Modified: trunk/LayoutTests/ChangeLog (164035 => 164036)
--- trunk/LayoutTests/ChangeLog 2014-02-13 18:07:05 UTC (rev 164035)
+++ trunk/LayoutTests/ChangeLog 2014-02-13 18:31:45 UTC (rev 164036)
@@ -1,3 +1,15 @@
+2014-02-13 László Langó <[email protected]>
+
+ Document should be constructable
+ https://bugs.webkit.org/show_bug.cgi?id=115643
+
+ Reviewed by Darin Adler.
+
+ * fast/dom/Document/document-constructor-expected.txt: Added.
+ * fast/dom/Document/document-constructor.html: Added.
+ * fast/dom/dom-constructors-expected.txt:
+ * fast/dom/dom-constructors.html:
+
2014-02-13 Javier Fernandez <[email protected]>
[CSS Grid Layout] Rename named areas property
Added: trunk/LayoutTests/fast/dom/Document/document-constructor-expected.txt (0 => 164036)
--- trunk/LayoutTests/fast/dom/Document/document-constructor-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/dom/Document/document-constructor-expected.txt 2014-02-13 18:31:45 UTC (rev 164036)
@@ -0,0 +1,14 @@
+This tests that Document is constructable.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS typeof new Document is "object"
+PASS Object.prototype.toString.call(new Document) is "[object Document]"
+PASS new Document instanceof Document is true
+PASS Object.getPrototypeOf(new Document) is Document.prototype
+PASS document.origin is new Document().origin
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/fast/dom/Document/document-constructor.html (0 => 164036)
--- trunk/LayoutTests/fast/dom/Document/document-constructor.html (rev 0)
+++ trunk/LayoutTests/fast/dom/Document/document-constructor.html 2014-02-13 18:31:45 UTC (rev 164036)
@@ -0,0 +1,14 @@
+<!DOCTYPE html>
+<script src=""
+<script>
+
+description('This tests that Document is constructable.');
+
+shouldBe('typeof new Document', '"object"');
+shouldBe('Object.prototype.toString.call(new Document)', '"[object Document]"');
+shouldBeTrue('new Document instanceof Document');
+shouldBe('Object.getPrototypeOf(new Document)', 'Document.prototype');
+shouldBe('document.origin', 'new Document().origin');
+
+</script>
+<script src=""
Modified: trunk/LayoutTests/fast/dom/dom-constructors-expected.txt (164035 => 164036)
--- trunk/LayoutTests/fast/dom/dom-constructors-expected.txt 2014-02-13 18:07:05 UTC (rev 164035)
+++ trunk/LayoutTests/fast/dom/dom-constructors-expected.txt 2014-02-13 18:31:45 UTC (rev 164036)
@@ -6,7 +6,6 @@
PASS TryAllocate('Attr') is 'exception'
PASS TryAllocate('CharacterData') is 'exception'
PASS TryAllocate('CDATASection') is 'exception'
-PASS TryAllocate('Document') is 'exception'
PASS TryAllocate('DocumentType') is 'exception'
PASS TryAllocate('Element') is 'exception'
PASS TryAllocate('Entity') is 'exception'
@@ -131,6 +130,9 @@
PASS TryAllocate('DOMParser') is '[object DOMParser]'
PASS TryAllocate('DOMParser') is '[object DOMParser]'
PASS TryAllocate('DOMParser') is '[object DOMParser]'
+PASS TryAllocate('Document') is '[object Document]'
+PASS TryAllocate('Document') is '[object Document]'
+PASS TryAllocate('Document') is '[object Document]'
PASS TryAllocate('DocumentFragment') is '[object DocumentFragment]'
PASS TryAllocate('DocumentFragment') is '[object DocumentFragment]'
PASS TryAllocate('DocumentFragment') is '[object DocumentFragment]'
Modified: trunk/LayoutTests/fast/dom/dom-constructors.html (164035 => 164036)
--- trunk/LayoutTests/fast/dom/dom-constructors.html 2014-02-13 18:07:05 UTC (rev 164035)
+++ trunk/LayoutTests/fast/dom/dom-constructors.html 2014-02-13 18:31:45 UTC (rev 164036)
@@ -16,7 +16,6 @@
'Attr',
'CharacterData',
'CDATASection',
- 'Document',
'DocumentType',
'Element',
'Entity',
@@ -135,6 +134,7 @@
var objects_constructor = [
'Comment',
'DOMParser',
+ 'Document',
'DocumentFragment',
'Range',
'Text',
Modified: trunk/Source/WebCore/ChangeLog (164035 => 164036)
--- trunk/Source/WebCore/ChangeLog 2014-02-13 18:07:05 UTC (rev 164035)
+++ trunk/Source/WebCore/ChangeLog 2014-02-13 18:31:45 UTC (rev 164036)
@@ -1,3 +1,22 @@
+2014-02-13 László Langó <[email protected]>
+
+ Document should be constructable
+ https://bugs.webkit.org/show_bug.cgi?id=115643
+
+ Reviewed by Darin Adler.
+
+ http://www.w3.org/TR/2014/WD-dom-20140204/#interface-document
+ Make Document constructable so that one can do "new Document"
+ instead of "document.implementation.createHTMLDocument('')".
+
+ Test: fast/dom/Document/document-constructor.html
+
+ * dom/Document.cpp:
+ (WebCore::Document::create):
+ (WebCore::Document::origin):
+ * dom/Document.h:
+ * dom/Document.idl:
+
2014-02-13 Javier Fernandez <[email protected]>
[CSS Grid Layout] Rename named areas property
Modified: trunk/Source/WebCore/dom/Document.cpp (164035 => 164036)
--- trunk/Source/WebCore/dom/Document.cpp 2014-02-13 18:07:05 UTC (rev 164035)
+++ trunk/Source/WebCore/dom/Document.cpp 2014-02-13 18:31:45 UTC (rev 164036)
@@ -559,6 +559,13 @@
}
#endif
+PassRefPtr<Document> Document::create(ScriptExecutionContext& context)
+{
+ RefPtr<Document> document = adoptRef(new Document(nullptr, URL()));
+ document->setSecurityOrigin(context.securityOrigin());
+ return document;
+}
+
Document::~Document()
{
ASSERT(!renderView());
@@ -3757,6 +3764,11 @@
return String();
}
+String Document::origin() const
+{
+ return securityOrigin()->databaseIdentifier();
+}
+
String Document::domain() const
{
return securityOrigin()->domain();
Modified: trunk/Source/WebCore/dom/Document.h (164035 => 164036)
--- trunk/Source/WebCore/dom/Document.h 2014-02-13 18:07:05 UTC (rev 164035)
+++ trunk/Source/WebCore/dom/Document.h 2014-02-13 18:31:45 UTC (rev 164036)
@@ -259,6 +259,8 @@
{
return adoptRef(new Document(frame, url, DefaultDocumentClass, NonRenderedPlaceholder));
}
+ static PassRefPtr<Document> create(ScriptExecutionContext&);
+
virtual ~Document();
MediaQueryMatcher& mediaQueryMatcher();
@@ -841,6 +843,8 @@
String referrer() const;
+ String origin() const;
+
String domain() const;
void setDomain(const String& newDomain, ExceptionCode&);
Modified: trunk/Source/WebCore/dom/Document.idl (164035 => 164036)
--- trunk/Source/WebCore/dom/Document.idl 2014-02-13 18:07:05 UTC (rev 164035)
+++ trunk/Source/WebCore/dom/Document.idl 2014-02-13 18:31:45 UTC (rev 164036)
@@ -19,6 +19,8 @@
*/
[
+ Constructor,
+ ConstructorCallWith=ScriptExecutionContext,
CustomToJSObject,
JSGenerateToNativeObject,
] interface Document : Node {
@@ -351,5 +353,8 @@
// currentscript API: http://www.whatwg.org/specs/web-apps/current-work/multipage/dom.html#dom-document-currentscript
readonly attribute HTMLScriptElement currentScript;
+
+ // http://www.w3.org/TR/2014/WD-dom-20140204/#dom-document-origin
+ readonly attribute DOMString origin;
};