Commit ef4b834e authored by tkent's avatar tkent Committed by Commit bot

Support Document constructor.

|new Document()| creates a new Document instance.

Intent-to-implement-and-ship:
https://groups.google.com/a/chromium.org/forum/#!msg/Blink-dev/IxyBdzkSU98/LJ12LwjKAAAJ

This CL fixes 168 failures in external/wpt/.

WPT changes:
* Adds 'origin' check to dom/nodes/Document-constructor.html.
* Adds dom/nodes/Document-constructor-svg.svg
* Adds dom/nodes/Document-constructor-xml.xml

BUG=238234, 643043

Review-Url: https://codereview.chromium.org/2881323002
Cr-Commit-Position: refs/heads/master@{#473931}
parent b8b1cbad
This is a testharness.js-based test.
Found 187 tests; 156 PASS, 31 FAIL, 0 TIMEOUT, 0 NOTRUN.
Found 187 tests; 159 PASS, 28 FAIL, 0 TIMEOUT, 0 NOTRUN.
PASS Document interface: attribute styleSheets
FAIL Document must be primary interface of document assert_equals: document's prototype is not Document.prototype expected object "[object Document]" but got object "[object HTMLDocument]"
FAIL Stringification of document assert_equals: class string of document expected "[object Document]" but got "[object HTMLDocument]"
PASS Document interface: document must inherit property "styleSheets" with the proper type (0)
FAIL Document must be primary interface of new Document() assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: Illegal constructor"
FAIL Stringification of new Document() assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: Illegal constructor"
FAIL Document interface: new Document() must inherit property "styleSheets" with the proper type (0) assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: Illegal constructor"
PASS Document must be primary interface of new Document()
PASS Stringification of new Document()
PASS Document interface: new Document() must inherit property "styleSheets" with the proper type (0)
PASS ProcessingInstruction interface: attribute sheet
PASS HTMLElement interface: attribute style
PASS SVGElement interface: attribute style
......
This is a testharness.js-based test.
Found 57 tests; 49 PASS, 8 FAIL, 0 TIMEOUT, 0 NOTRUN.
PASS Inserting a custom element into the owner document must not enqueue and invoke adoptedCallback
PASS Inserting a custom element into the document of the template elements must enqueue and invoke adoptedCallback
PASS Moving a custom element from the owner document into the document of the template elements must enqueue and invoke adoptedCallback
PASS Inserting an ancestor of custom element into the document of the template elements must enqueue and invoke adoptedCallback
PASS Moving an ancestor of custom element from the owner document into the document of the template elements must enqueue and invoke adoptedCallback
PASS Inserting a custom element into a shadow tree in the document of the template elements must enqueue and invoke adoptedCallback
PASS Inserting the shadow host of a custom element into the document of the template elements must enqueue and invoke adoptedCallback
PASS Moving the shadow host of a custom element from the owner document into the document of the template elements must enqueue and invoke adoptedCallback
PASS Inserting a custom element into a detached shadow tree that belongs to the document of the template elements must enqueue and invoke adoptedCallback
FAIL Inserting a custom element into a new document must enqueue and invoke adoptedCallback promise_test: Unhandled rejection with value: object "TypeError: Illegal constructor"
FAIL Moving a custom element from the owner document into a new document must enqueue and invoke adoptedCallback promise_test: Unhandled rejection with value: object "TypeError: Illegal constructor"
FAIL Inserting an ancestor of custom element into a new document must enqueue and invoke adoptedCallback promise_test: Unhandled rejection with value: object "TypeError: Illegal constructor"
FAIL Moving an ancestor of custom element from the owner document into a new document must enqueue and invoke adoptedCallback promise_test: Unhandled rejection with value: object "TypeError: Illegal constructor"
FAIL Inserting a custom element into a shadow tree in a new document must enqueue and invoke adoptedCallback promise_test: Unhandled rejection with value: object "TypeError: Illegal constructor"
FAIL Inserting the shadow host of a custom element into a new document must enqueue and invoke adoptedCallback promise_test: Unhandled rejection with value: object "TypeError: Illegal constructor"
FAIL Moving the shadow host of a custom element from the owner document into a new document must enqueue and invoke adoptedCallback promise_test: Unhandled rejection with value: object "TypeError: Illegal constructor"
FAIL Inserting a custom element into a detached shadow tree that belongs to a new document must enqueue and invoke adoptedCallback promise_test: Unhandled rejection with value: object "TypeError: Illegal constructor"
PASS Inserting a custom element into a cloned document must enqueue and invoke adoptedCallback
PASS Moving a custom element from the owner document into a cloned document must enqueue and invoke adoptedCallback
PASS Inserting an ancestor of custom element into a cloned document must enqueue and invoke adoptedCallback
PASS Moving an ancestor of custom element from the owner document into a cloned document must enqueue and invoke adoptedCallback
PASS Inserting a custom element into a shadow tree in a cloned document must enqueue and invoke adoptedCallback
PASS Inserting the shadow host of a custom element into a cloned document must enqueue and invoke adoptedCallback
PASS Moving the shadow host of a custom element from the owner document into a cloned document must enqueue and invoke adoptedCallback
PASS Inserting a custom element into a detached shadow tree that belongs to a cloned document must enqueue and invoke adoptedCallback
PASS Inserting a custom element into a document created by createHTMLDocument must enqueue and invoke adoptedCallback
PASS Moving a custom element from the owner document into a document created by createHTMLDocument must enqueue and invoke adoptedCallback
PASS Inserting an ancestor of custom element into a document created by createHTMLDocument must enqueue and invoke adoptedCallback
PASS Moving an ancestor of custom element from the owner document into a document created by createHTMLDocument must enqueue and invoke adoptedCallback
PASS Inserting a custom element into a shadow tree in a document created by createHTMLDocument must enqueue and invoke adoptedCallback
PASS Inserting the shadow host of a custom element into a document created by createHTMLDocument must enqueue and invoke adoptedCallback
PASS Moving the shadow host of a custom element from the owner document into a document created by createHTMLDocument must enqueue and invoke adoptedCallback
PASS Inserting a custom element into a detached shadow tree that belongs to a document created by createHTMLDocument must enqueue and invoke adoptedCallback
PASS Inserting a custom element into an HTML document created by createDocument must enqueue and invoke adoptedCallback
PASS Moving a custom element from the owner document into an HTML document created by createDocument must enqueue and invoke adoptedCallback
PASS Inserting an ancestor of custom element into an HTML document created by createDocument must enqueue and invoke adoptedCallback
PASS Moving an ancestor of custom element from the owner document into an HTML document created by createDocument must enqueue and invoke adoptedCallback
PASS Inserting a custom element into a shadow tree in an HTML document created by createDocument must enqueue and invoke adoptedCallback
PASS Inserting the shadow host of a custom element into an HTML document created by createDocument must enqueue and invoke adoptedCallback
PASS Moving the shadow host of a custom element from the owner document into an HTML document created by createDocument must enqueue and invoke adoptedCallback
PASS Inserting a custom element into a detached shadow tree that belongs to an HTML document created by createDocument must enqueue and invoke adoptedCallback
PASS Inserting a custom element into the document of an iframe must enqueue and invoke adoptedCallback
PASS Moving a custom element from the owner document into the document of an iframe must enqueue and invoke adoptedCallback
PASS Inserting an ancestor of custom element into the document of an iframe must enqueue and invoke adoptedCallback
PASS Moving an ancestor of custom element from the owner document into the document of an iframe must enqueue and invoke adoptedCallback
PASS Inserting a custom element into a shadow tree in the document of an iframe must enqueue and invoke adoptedCallback
PASS Inserting the shadow host of a custom element into the document of an iframe must enqueue and invoke adoptedCallback
PASS Moving the shadow host of a custom element from the owner document into the document of an iframe must enqueue and invoke adoptedCallback
PASS Inserting a custom element into a detached shadow tree that belongs to the document of an iframe must enqueue and invoke adoptedCallback
PASS Inserting a custom element into an HTML document fetched by XHR must enqueue and invoke adoptedCallback
PASS Moving a custom element from the owner document into an HTML document fetched by XHR must enqueue and invoke adoptedCallback
PASS Inserting an ancestor of custom element into an HTML document fetched by XHR must enqueue and invoke adoptedCallback
PASS Moving an ancestor of custom element from the owner document into an HTML document fetched by XHR must enqueue and invoke adoptedCallback
PASS Inserting a custom element into a shadow tree in an HTML document fetched by XHR must enqueue and invoke adoptedCallback
PASS Inserting the shadow host of a custom element into an HTML document fetched by XHR must enqueue and invoke adoptedCallback
PASS Moving the shadow host of a custom element from the owner document into an HTML document fetched by XHR must enqueue and invoke adoptedCallback
PASS Inserting a custom element into a detached shadow tree that belongs to an HTML document fetched by XHR must enqueue and invoke adoptedCallback
Harness: the test ran to completion.
This is a testharness.js-based test.
PASS Inserting a custom element into the document must enqueue and invoke connectedCallback
PASS Inserting an ancestor of custom element into the document must enqueue and invoke connectedCallback
PASS Inserting a custom element into a shadow tree in the document must enqueue and invoke connectedCallback
PASS Inserting the shadow host of a custom element into the document must enqueue and invoke connectedCallback
PASS Inserting a custom element into a detached shadow tree that belongs to the document must not enqueue and invoke connectedCallback
PASS Inserting a custom element into the document of the template elements must enqueue and invoke connectedCallback
PASS Inserting an ancestor of custom element into the document of the template elements must enqueue and invoke connectedCallback
PASS Inserting a custom element into a shadow tree in the document of the template elements must enqueue and invoke connectedCallback
PASS Inserting the shadow host of a custom element into the document of the template elements must enqueue and invoke connectedCallback
PASS Inserting a custom element into a detached shadow tree that belongs to the document of the template elements must not enqueue and invoke connectedCallback
FAIL Inserting a custom element into a new document must enqueue and invoke connectedCallback promise_test: Unhandled rejection with value: object "TypeError: Illegal constructor"
FAIL Inserting an ancestor of custom element into a new document must enqueue and invoke connectedCallback promise_test: Unhandled rejection with value: object "TypeError: Illegal constructor"
FAIL Inserting a custom element into a shadow tree in a new document must enqueue and invoke connectedCallback promise_test: Unhandled rejection with value: object "TypeError: Illegal constructor"
FAIL Inserting the shadow host of a custom element into a new document must enqueue and invoke connectedCallback promise_test: Unhandled rejection with value: object "TypeError: Illegal constructor"
FAIL Inserting a custom element into a detached shadow tree that belongs to a new document must not enqueue and invoke connectedCallback promise_test: Unhandled rejection with value: object "TypeError: Illegal constructor"
PASS Inserting a custom element into a cloned document must enqueue and invoke connectedCallback
PASS Inserting an ancestor of custom element into a cloned document must enqueue and invoke connectedCallback
PASS Inserting a custom element into a shadow tree in a cloned document must enqueue and invoke connectedCallback
PASS Inserting the shadow host of a custom element into a cloned document must enqueue and invoke connectedCallback
PASS Inserting a custom element into a detached shadow tree that belongs to a cloned document must not enqueue and invoke connectedCallback
PASS Inserting a custom element into a document created by createHTMLDocument must enqueue and invoke connectedCallback
PASS Inserting an ancestor of custom element into a document created by createHTMLDocument must enqueue and invoke connectedCallback
PASS Inserting a custom element into a shadow tree in a document created by createHTMLDocument must enqueue and invoke connectedCallback
PASS Inserting the shadow host of a custom element into a document created by createHTMLDocument must enqueue and invoke connectedCallback
PASS Inserting a custom element into a detached shadow tree that belongs to a document created by createHTMLDocument must not enqueue and invoke connectedCallback
PASS Inserting a custom element into an HTML document created by createDocument must enqueue and invoke connectedCallback
PASS Inserting an ancestor of custom element into an HTML document created by createDocument must enqueue and invoke connectedCallback
PASS Inserting a custom element into a shadow tree in an HTML document created by createDocument must enqueue and invoke connectedCallback
PASS Inserting the shadow host of a custom element into an HTML document created by createDocument must enqueue and invoke connectedCallback
PASS Inserting a custom element into a detached shadow tree that belongs to an HTML document created by createDocument must not enqueue and invoke connectedCallback
PASS Inserting a custom element into the document of an iframe must enqueue and invoke connectedCallback
PASS Inserting an ancestor of custom element into the document of an iframe must enqueue and invoke connectedCallback
PASS Inserting a custom element into a shadow tree in the document of an iframe must enqueue and invoke connectedCallback
PASS Inserting the shadow host of a custom element into the document of an iframe must enqueue and invoke connectedCallback
PASS Inserting a custom element into a detached shadow tree that belongs to the document of an iframe must not enqueue and invoke connectedCallback
PASS Inserting a custom element into an HTML document fetched by XHR must enqueue and invoke connectedCallback
PASS Inserting an ancestor of custom element into an HTML document fetched by XHR must enqueue and invoke connectedCallback
PASS Inserting a custom element into a shadow tree in an HTML document fetched by XHR must enqueue and invoke connectedCallback
PASS Inserting the shadow host of a custom element into an HTML document fetched by XHR must enqueue and invoke connectedCallback
PASS Inserting a custom element into a detached shadow tree that belongs to an HTML document fetched by XHR must not enqueue and invoke connectedCallback
Harness: the test ran to completion.
This is a testharness.js-based test.
PASS Removing a custom element from the document must enqueue and invoke disconnectedCallback
PASS Removing an ancestor of custom element from the document must enqueue and invoke disconnectedCallback
PASS Removing a custom element from a shadow tree in the document must enqueue and invoke disconnectedCallback
PASS Removing the shadow host of a custom element from athe document must enqueue and invoke disconnectedCallback
PASS Removing a custom element from a detached shadow tree that belongs to the document must not enqueue and invoke disconnectedCallback
PASS Removing a custom element from the document of the template elements must enqueue and invoke disconnectedCallback
PASS Removing an ancestor of custom element from the document of the template elements must enqueue and invoke disconnectedCallback
PASS Removing a custom element from a shadow tree in the document of the template elements must enqueue and invoke disconnectedCallback
PASS Removing the shadow host of a custom element from athe document of the template elements must enqueue and invoke disconnectedCallback
PASS Removing a custom element from a detached shadow tree that belongs to the document of the template elements must not enqueue and invoke disconnectedCallback
FAIL Removing a custom element from a new document must enqueue and invoke disconnectedCallback promise_test: Unhandled rejection with value: object "TypeError: Illegal constructor"
FAIL Removing an ancestor of custom element from a new document must enqueue and invoke disconnectedCallback promise_test: Unhandled rejection with value: object "TypeError: Illegal constructor"
FAIL Removing a custom element from a shadow tree in a new document must enqueue and invoke disconnectedCallback promise_test: Unhandled rejection with value: object "TypeError: Illegal constructor"
FAIL Removing the shadow host of a custom element from aa new document must enqueue and invoke disconnectedCallback promise_test: Unhandled rejection with value: object "TypeError: Illegal constructor"
FAIL Removing a custom element from a detached shadow tree that belongs to a new document must not enqueue and invoke disconnectedCallback promise_test: Unhandled rejection with value: object "TypeError: Illegal constructor"
PASS Removing a custom element from a cloned document must enqueue and invoke disconnectedCallback
PASS Removing an ancestor of custom element from a cloned document must enqueue and invoke disconnectedCallback
PASS Removing a custom element from a shadow tree in a cloned document must enqueue and invoke disconnectedCallback
PASS Removing the shadow host of a custom element from aa cloned document must enqueue and invoke disconnectedCallback
PASS Removing a custom element from a detached shadow tree that belongs to a cloned document must not enqueue and invoke disconnectedCallback
PASS Removing a custom element from a document created by createHTMLDocument must enqueue and invoke disconnectedCallback
PASS Removing an ancestor of custom element from a document created by createHTMLDocument must enqueue and invoke disconnectedCallback
PASS Removing a custom element from a shadow tree in a document created by createHTMLDocument must enqueue and invoke disconnectedCallback
PASS Removing the shadow host of a custom element from aa document created by createHTMLDocument must enqueue and invoke disconnectedCallback
PASS Removing a custom element from a detached shadow tree that belongs to a document created by createHTMLDocument must not enqueue and invoke disconnectedCallback
PASS Removing a custom element from an HTML document created by createDocument must enqueue and invoke disconnectedCallback
PASS Removing an ancestor of custom element from an HTML document created by createDocument must enqueue and invoke disconnectedCallback
PASS Removing a custom element from a shadow tree in an HTML document created by createDocument must enqueue and invoke disconnectedCallback
PASS Removing the shadow host of a custom element from aan HTML document created by createDocument must enqueue and invoke disconnectedCallback
PASS Removing a custom element from a detached shadow tree that belongs to an HTML document created by createDocument must not enqueue and invoke disconnectedCallback
PASS Removing a custom element from the document of an iframe must enqueue and invoke disconnectedCallback
PASS Removing an ancestor of custom element from the document of an iframe must enqueue and invoke disconnectedCallback
PASS Removing a custom element from a shadow tree in the document of an iframe must enqueue and invoke disconnectedCallback
PASS Removing the shadow host of a custom element from athe document of an iframe must enqueue and invoke disconnectedCallback
PASS Removing a custom element from a detached shadow tree that belongs to the document of an iframe must not enqueue and invoke disconnectedCallback
PASS Removing a custom element from an HTML document fetched by XHR must enqueue and invoke disconnectedCallback
PASS Removing an ancestor of custom element from an HTML document fetched by XHR must enqueue and invoke disconnectedCallback
PASS Removing a custom element from a shadow tree in an HTML document fetched by XHR must enqueue and invoke disconnectedCallback
PASS Removing the shadow host of a custom element from aan HTML document fetched by XHR must enqueue and invoke disconnectedCallback
PASS Removing a custom element from a detached shadow tree that belongs to an HTML document fetched by XHR must not enqueue and invoke disconnectedCallback
Harness: the test ran to completion.
......@@ -5,7 +5,7 @@ PASS HTML parser must use the registry of the content document inside an iframe
PASS HTML parser must not instantiate a custom element defined inside an frame in frame element's owner document
PASS HTML parser must use the registry of window.document in a document created by document.implementation.createHTMLDocument()
FAIL HTML parser must use the registry of window.document in a document created by document.implementation.createXHTMLDocument() assert_true: expected true got false
FAIL HTML parser must use the registry of window.document in a document created by new Document Illegal constructor
PASS HTML parser must use the registry of window.document in a document created by new Document
PASS HTML parser must use the registry of window.document in a document created by XMLHttpRequest
Harness: the test ran to completion.
This is a testharness.js-based test.
PASS Creating an element in the document of the template elements must not enqueue a custom element upgrade reaction because the document does not have a browsing context
PASS Creating an element in the document of the template elements and inserting into the document must not enqueue a custom element upgrade reaction
PASS Creating an element in the document of the template elements and adopting back to a document with browsing context must enqueue a custom element upgrade reaction
FAIL Creating an element in a new document must not enqueue a custom element upgrade reaction because the document does not have a browsing context promise_test: Unhandled rejection with value: object "TypeError: Illegal constructor"
FAIL Creating an element in a new document and inserting into the document must not enqueue a custom element upgrade reaction promise_test: Unhandled rejection with value: object "TypeError: Illegal constructor"
FAIL Creating an element in a new document and adopting back to a document with browsing context must enqueue a custom element upgrade reaction promise_test: Unhandled rejection with value: object "TypeError: Illegal constructor"
PASS Creating an element in a cloned document must not enqueue a custom element upgrade reaction because the document does not have a browsing context
PASS Creating an element in a cloned document and inserting into the document must not enqueue a custom element upgrade reaction
PASS Creating an element in a cloned document and adopting back to a document with browsing context must enqueue a custom element upgrade reaction
PASS Creating an element in a document created by createHTMLDocument must not enqueue a custom element upgrade reaction because the document does not have a browsing context
PASS Creating an element in a document created by createHTMLDocument and inserting into the document must not enqueue a custom element upgrade reaction
PASS Creating an element in a document created by createHTMLDocument and adopting back to a document with browsing context must enqueue a custom element upgrade reaction
PASS Creating an element in an HTML document created by createDocument must not enqueue a custom element upgrade reaction because the document does not have a browsing context
PASS Creating an element in an HTML document created by createDocument and inserting into the document must not enqueue a custom element upgrade reaction
PASS Creating an element in an HTML document created by createDocument and adopting back to a document with browsing context must enqueue a custom element upgrade reaction
PASS Creating an element in an HTML document fetched by XHR must not enqueue a custom element upgrade reaction because the document does not have a browsing context
PASS Creating an element in an HTML document fetched by XHR and inserting into the document must not enqueue a custom element upgrade reaction
PASS Creating an element in an HTML document fetched by XHR and adopting back to a document with browsing context must enqueue a custom element upgrade reaction
PASS Creating an element in the document of an iframe must not enqueue a custom element upgrade reaction if there is no matching definition
PASS Creating an element in the document of an iframe must enqueue a custom element upgrade reaction if there is a matching definition
PASS "define" in the document of an iframe must not enqueue a custom element upgrade reaction on a disconnected unresolved custom element
PASS Inserting an unresolved custom element into the document of an iframe must enqueue a custom element upgrade reaction
PASS "define" in the document of an iframe must enqueue a custom element upgrade reaction on a connected unresolved custom element
PASS Adopting (and leaving disconnceted) an unresolved custom element into the document of an iframe must not enqueue a custom element upgrade reaction
PASS Adopting and inserting an unresolved custom element into the document of an iframe must enqueue a custom element upgrade reaction
Harness: the test ran to completion.
......@@ -2,7 +2,7 @@ This is a testharness.js-based test.
PASS In window.document with click event
PASS In window.document with load event
FAIL In window.document.cloneNode(true) assert_array_equals: targets lengths differ, expected 8 got 0
FAIL In new Document() Illegal constructor
PASS In new Document()
PASS In DOMImplementation.createHTMLDocument()
Harness: the test ran to completion.
......@@ -2,7 +2,7 @@ This is a testharness.js-based test.
PASS In window.document with click event
PASS In window.document with load event
FAIL In window.document.cloneNode(true) assert_array_equals: targets lengths differ, expected 14 got 0
FAIL In new Document() Illegal constructor
PASS In new Document()
PASS In DOMImplementation.createHTMLDocument()
Harness: the test ran to completion.
This is a testharness.js-based test.
FAIL new Document(): interfaces Illegal constructor
FAIL new Document(): children Illegal constructor
FAIL new Document(): metadata Illegal constructor
FAIL new Document(): characterSet aliases Illegal constructor
FAIL new Document(): URL parsing Illegal constructor
PASS new Document(): interfaces
PASS new Document(): children
PASS new Document(): metadata
PASS new Document(): characterSet aliases
FAIL new Document(): URL parsing assert_equals: expected "http://example.org/?%C3%A4" but got "http://example.org/?ä"
Harness: the test ran to completion.
<?xml version="1.0" encoding="windows-1252"?>
<!-- Using windows-1252 to ensure that new Document() doesn't inherit utf-8
from the parent document. -->
<svg xmlns="http://www.w3.org/2000/svg" xmlns:html="http://www.w3.org/1999/xhtml"
width="100%" height="100%" viewBox="0 0 800 600">
<title>Document constructor</title>
<html:script src="/resources/testharness.js"></html:script>
<html:script src="/resources/testharnessreport.js"></html:script>
<html:script><![CDATA[
test(function() {
var doc = new Document();
assert_true(doc instanceof Node, "Should be a Node");
assert_true(doc instanceof Document, "Should be a Document");
assert_false(doc instanceof XMLDocument, "Should not be an XMLDocument");
assert_equals(Object.getPrototypeOf(doc), Document.prototype,
"Document should be the primary interface");
}, "new Document(): interfaces")
test(function() {
var doc = new Document();
assert_equals(doc.firstChild, null, "firstChild");
assert_equals(doc.lastChild, null, "lastChild");
assert_equals(doc.doctype, null, "doctype");
assert_equals(doc.documentElement, null, "documentElement");
assert_array_equals(doc.childNodes, [], "childNodes");
}, "new Document(): children")
test(function() {
var doc = new Document();
assert_equals(doc.URL, "about:blank");
assert_equals(doc.documentURI, "about:blank");
assert_equals(doc.compatMode, "CSS1Compat");
assert_equals(doc.characterSet, "UTF-8");
assert_equals(doc.contentType, "application/xml");
assert_equals(doc.origin, document.origin);
assert_equals(doc.createElement("DIV").localName, "DIV");
}, "new Document(): metadata")
test(function() {
var doc = new Document();
assert_equals(doc.characterSet, "UTF-8", "characterSet");
assert_equals(doc.charset, "UTF-8", "charset");
assert_equals(doc.inputEncoding, "UTF-8", "inputEncoding");
}, "new Document(): characterSet aliases")
]]></html:script>
</svg>
<?xml version="1.0" encoding="windows-1252"?>
<!-- Using windows-1252 to ensure that new Document() doesn't inherit utf-8
from the parent document. -->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Document constructor</title>
<link rel="help" href="https://dom.spec.whatwg.org/#dom-document" />
</head>
<body>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script><![CDATA[
test(function() {
var doc = new Document();
assert_true(doc instanceof Node, "Should be a Node");
assert_true(doc instanceof Document, "Should be a Document");
assert_false(doc instanceof XMLDocument, "Should not be an XMLDocument");
assert_equals(Object.getPrototypeOf(doc), Document.prototype,
"Document should be the primary interface");
}, "new Document(): interfaces")
test(function() {
var doc = new Document();
assert_equals(doc.firstChild, null, "firstChild");
assert_equals(doc.lastChild, null, "lastChild");
assert_equals(doc.doctype, null, "doctype");
assert_equals(doc.documentElement, null, "documentElement");
assert_array_equals(doc.childNodes, [], "childNodes");
}, "new Document(): children")
test(function() {
var doc = new Document();
assert_equals(doc.URL, "about:blank");
assert_equals(doc.documentURI, "about:blank");
assert_equals(doc.compatMode, "CSS1Compat");
assert_equals(doc.characterSet, "UTF-8");
assert_equals(doc.contentType, "application/xml");
assert_equals(doc.origin, document.origin);
assert_equals(doc.createElement("DIV").localName, "DIV");
}, "new Document(): metadata")
test(function() {
var doc = new Document();
assert_equals(doc.characterSet, "UTF-8", "characterSet");
assert_equals(doc.charset, "UTF-8", "charset");
assert_equals(doc.inputEncoding, "UTF-8", "inputEncoding");
}, "new Document(): characterSet aliases")
]]></script>
</body>
</html>
......@@ -33,6 +33,7 @@ test(function() {
assert_equals(doc.compatMode, "CSS1Compat");
assert_equals(doc.characterSet, "UTF-8");
assert_equals(doc.contentType, "application/xml");
assert_equals(doc.origin, document.origin);
assert_equals(doc.createElement("DIV").localName, "DIV");
}, "new Document(): metadata")
......
This is a testharness.js-based test.
PASS Window document with doctype
FAIL new Document() Illegal constructor
Harness: the test ran to completion.
This is a testharness.js-based test.
PASS Caching of Node.childNodes
PASS Node.childNodes on an Element.
PASS Node.childNodes on a DocumentFragment.
FAIL Node.childNodes on a Document. Illegal constructor
PASS Iterator behavior of Node.childNodes
Harness: the test ran to completion.
......@@ -6,14 +6,14 @@ FAIL Document interface: operation exitFullscreen() assert_unreached: Throws "Ty
PASS Document interface: attribute onfullscreenchange
PASS Document interface: attribute onfullscreenerror
FAIL Document interface: attribute fullscreenElement assert_equals: setter must be function for PutForwards, Replaceable, or non-readonly attributes expected "function" but got "undefined"
FAIL Document must be primary interface of new Document assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: Illegal constructor"
FAIL Stringification of new Document assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: Illegal constructor"
FAIL Document interface: new Document must inherit property "fullscreenEnabled" with the proper type (29) assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: Illegal constructor"
FAIL Document interface: new Document must inherit property "fullscreen" with the proper type (30) assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: Illegal constructor"
FAIL Document interface: new Document must inherit property "exitFullscreen" with the proper type (31) assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: Illegal constructor"
FAIL Document interface: new Document must inherit property "onfullscreenchange" with the proper type (32) assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: Illegal constructor"
FAIL Document interface: new Document must inherit property "onfullscreenerror" with the proper type (33) assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: Illegal constructor"
FAIL Document interface: new Document must inherit property "fullscreenElement" with the proper type (35) assert_equals: Unexpected exception when evaluating object expected null but got object "TypeError: Illegal constructor"
PASS Document must be primary interface of new Document
PASS Stringification of new Document
PASS Document interface: new Document must inherit property "fullscreenEnabled" with the proper type (29)
FAIL Document interface: new Document must inherit property "fullscreen" with the proper type (30) assert_inherits: property "fullscreen" not found in prototype chain
PASS Document interface: new Document must inherit property "exitFullscreen" with the proper type (31)
PASS Document interface: new Document must inherit property "onfullscreenchange" with the proper type (32)
PASS Document interface: new Document must inherit property "onfullscreenerror" with the proper type (33)
PASS Document interface: new Document must inherit property "fullscreenElement" with the proper type (35)
FAIL ShadowRoot interface: attribute fullscreenElement assert_equals: setter must be function for PutForwards, Replaceable, or non-readonly attributes expected "function" but got "undefined"
FAIL Element interface: operation requestFullscreen() assert_unreached: Throws "TypeError: Illegal invocation" instead of rejecting promise Reached unreachable code
PASS Element must be primary interface of document.createElementNS(null, "test")
......
This is a testharness.js-based test.
PASS sanity checks
PASS current document
FAIL new document Illegal constructor
FAIL new document assert_equals: new document has empty domain expected "" but got "web-platform.test"
Harness: the test ran to completion.
This is a testharness.js-based test.
PASS Document in a browsing context
FAIL Document created with the Document constructor Illegal constructor
PASS Document created with createDocument
PASS Document created with createHTMLDocument
PASS Document created with XML DOMParser
PASS Document created with HTML DOMParser
Harness: the test ran to completion.
......@@ -6,7 +6,6 @@ On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE
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('EventTarget') is 'exception'
......@@ -121,6 +120,9 @@ PASS TryAllocate('DataTransfer') is '[object DataTransfer]'
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]'
......
......@@ -16,7 +16,6 @@ var objects_exception = [
'Attr',
'CharacterData',
'CDATASection',
'Document',
'DocumentType',
'Element',
'EventTarget',
......@@ -124,6 +123,7 @@ var objects_constructor = [
'Comment',
'DataTransfer',
'DOMParser',
'Document',
'DocumentFragment',
'Range',
'Text',
......
......@@ -491,6 +491,14 @@ class Document::NetworkStateObserver final
DEFINE_INLINE_VIRTUAL_TRACE() { ContextLifecycleObserver::Trace(visitor); }
};
Document* Document::Create(const Document& document) {
Document* new_document = new Document(
DocumentInit::FromContext(const_cast<Document*>(&document), BlankURL()));
new_document->SetSecurityOrigin(document.GetSecurityOrigin());
new_document->SetContextFeatures(document.GetContextFeatures());
return new_document;
}
Document::Document(const DocumentInit& initializer,
DocumentClassFlags document_classes)
: ContainerNode(0, kCreateDocument),
......
......@@ -261,6 +261,11 @@ class CORE_EXPORT Document : public ContainerNode,
static Document* Create(const DocumentInit& initializer = DocumentInit()) {
return new Document(initializer);
}
// Factory for web-exposed Document constructor. The argument document must be
// a document instance representing window.document, and it works as the
// source of ExecutionContext and security origin of the new document.
// https://dom.spec.whatwg.org/#dom-document-document
static Document* Create(const Document&);
~Document() override;
MediaQueryMatcher& GetMediaQueryMatcher();
......
......@@ -34,8 +34,10 @@ typedef (HTMLScriptElement or SVGScriptElement) HTMLOrSVGScriptElement;
// https://dom.spec.whatwg.org/#interface-document
// FIXME: Document should have a constructor. crbug.com/238234
interface Document : Node {
[
Constructor(),
ConstructorCallWith=Document,
] interface Document : Node {
[SameObject] readonly attribute DOMImplementation implementation;
[ImplementedAs=urlForBinding] readonly attribute DOMString URL;
// FIXME: documentURI should not be nullable.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment