gecko-dev/testing/web-platform/tests/dom/nodes/DOMImplementation-createDocument.html
James Graham 62afd489a0 Bug 1410245 - Update web-platform-tests to revision a372dce582c21c911056273eec042fd9073cbd60, a=testonly
MozReview-Commit-ID: CQzdR66hsXZ


--HG--
rename : testing/web-platform/tests/progress-events/interface.html => testing/web-platform/tests/XMLHttpRequest/progressevent-interface.html
rename : testing/web-platform/tests/cssom/MediaList.xhtml => testing/web-platform/tests/cssom/MediaList2.xhtml
rename : testing/web-platform/tests/old-tests/submission/Microsoft/dragdrop/dragdrop_support.js => testing/web-platform/tests/html/editing/dnd/resources/dragdrop_support.js
rename : testing/web-platform/tests/old-tests/submission/Microsoft/structuredclone/echo.js => testing/web-platform/tests/html/infrastructure/safe-passing-of-structured-data/echo.js
rename : testing/web-platform/tests/old-tests/submission/Microsoft/sandbox/sandbox_011.htm => testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/sandbox_011.htm
rename : testing/web-platform/tests/old-tests/submission/Microsoft/sandbox/iframe_sandbox_002.htm => testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/support/iframe_sandbox_002.htm
rename : testing/web-platform/tests/old-tests/submission/Microsoft/sandbox/iframe_sandbox_003.htm => testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/support/iframe_sandbox_003.htm
rename : testing/web-platform/tests/old-tests/submission/Microsoft/sandbox/iframe_sandbox_006.htm => testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/support/iframe_sandbox_006.htm
rename : testing/web-platform/tests/old-tests/submission/Microsoft/sandbox/iframe_sandbox_007.htm => testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/support/iframe_sandbox_007.htm
rename : testing/web-platform/tests/old-tests/submission/Microsoft/sandbox/iframe_sandbox_012.htm => testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/support/iframe_sandbox_012.htm
rename : testing/web-platform/tests/old-tests/submission/Microsoft/sandbox/iframe_sandbox_023.htm => testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/support/iframe_sandbox_023.htm
rename : testing/web-platform/tests/old-tests/submission/Microsoft/sandbox/iframe_sandbox_024.htm => testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/support/iframe_sandbox_024.htm
rename : testing/web-platform/tests/old-tests/submission/Microsoft/sandbox/iframe_sandbox_028.htm => testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/support/iframe_sandbox_028.htm
rename : testing/web-platform/tests/old-tests/submission/Microsoft/sandbox/iframe_sandbox_029.htm => testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/support/iframe_sandbox_029.htm
rename : testing/web-platform/tests/old-tests/submission/Microsoft/sandbox/sandbox.pdf => testing/web-platform/tests/html/semantics/embedded-content/the-iframe-element/support/sandbox.pdf
rename : testing/web-platform/tests/old-tests/submission/Opera/script_scheduling/023.html => testing/web-platform/tests/html/semantics/scripting-1/the-script-element/execution-timing/023.html
rename : testing/web-platform/tests/old-tests/submission/Opera/script_scheduling/050.html => testing/web-platform/tests/html/semantics/scripting-1/the-script-element/execution-timing/050.html
rename : testing/web-platform/tests/old-tests/submission/Opera/script_scheduling/067.html => testing/web-platform/tests/html/semantics/scripting-1/the-script-element/execution-timing/067.html
rename : testing/web-platform/tests/old-tests/submission/Opera/script_scheduling/069.html => testing/web-platform/tests/html/semantics/scripting-1/the-script-element/execution-timing/069.html
rename : testing/web-platform/tests/old-tests/submission/Opera/script_scheduling/075.html => testing/web-platform/tests/html/semantics/scripting-1/the-script-element/execution-timing/075.html
rename : testing/web-platform/tests/old-tests/submission/Opera/script_scheduling/077.html => testing/web-platform/tests/html/semantics/scripting-1/the-script-element/execution-timing/077.html
rename : testing/web-platform/tests/old-tests/submission/Opera/script_scheduling/078.html => testing/web-platform/tests/html/semantics/scripting-1/the-script-element/execution-timing/078.html
rename : testing/web-platform/tests/old-tests/submission/Opera/script_scheduling/079.html => testing/web-platform/tests/html/semantics/scripting-1/the-script-element/execution-timing/079.html
rename : testing/web-platform/tests/old-tests/submission/Opera/script_scheduling/101.html => testing/web-platform/tests/html/semantics/scripting-1/the-script-element/execution-timing/101.html
rename : testing/web-platform/tests/old-tests/submission/Opera/script_scheduling/106-import.html => testing/web-platform/tests/html/semantics/scripting-1/the-script-element/execution-timing/106-import.html
rename : testing/web-platform/tests/old-tests/submission/Opera/script_scheduling/106-noimport.html => testing/web-platform/tests/html/semantics/scripting-1/the-script-element/execution-timing/106-noimport.html
rename : testing/web-platform/tests/old-tests/submission/Opera/script_scheduling/107-import.html => testing/web-platform/tests/html/semantics/scripting-1/the-script-element/execution-timing/107-import.html
rename : testing/web-platform/tests/old-tests/submission/Opera/script_scheduling/107-noimport.html => testing/web-platform/tests/html/semantics/scripting-1/the-script-element/execution-timing/107-noimport.html
rename : testing/web-platform/tests/old-tests/submission/Opera/script_scheduling/111.html => testing/web-platform/tests/html/semantics/scripting-1/the-script-element/execution-timing/111.html
rename : testing/web-platform/tests/old-tests/submission/Opera/script_scheduling/112.html => testing/web-platform/tests/html/semantics/scripting-1/the-script-element/execution-timing/112.html
rename : testing/web-platform/tests/old-tests/submission/Opera/script_scheduling/119.html => testing/web-platform/tests/html/semantics/scripting-1/the-script-element/execution-timing/119.html
rename : testing/web-platform/tests/old-tests/submission/Opera/script_scheduling/css/background.css => testing/web-platform/tests/html/semantics/scripting-1/the-script-element/execution-timing/css/background.css
rename : testing/web-platform/tests/old-tests/submission/Opera/script_scheduling/css/import.css => testing/web-platform/tests/html/semantics/scripting-1/the-script-element/execution-timing/css/import.css
rename : testing/web-platform/tests/old-tests/submission/Opera/script_scheduling/scripts/count-script-tags.js => testing/web-platform/tests/html/semantics/scripting-1/the-script-element/execution-timing/scripts/count-script-tags.js
rename : testing/web-platform/tests/old-tests/submission/Opera/script_scheduling/scripts/find-body.js => testing/web-platform/tests/html/semantics/scripting-1/the-script-element/execution-timing/scripts/find-body.js
rename : testing/web-platform/tests/old-tests/submission/Opera/script_scheduling/scripts/find-foo.js => testing/web-platform/tests/html/semantics/scripting-1/the-script-element/execution-timing/scripts/find-foo.js
rename : testing/web-platform/tests/old-tests/submission/Opera/script_scheduling/scripts/include-1.js => testing/web-platform/tests/html/semantics/scripting-1/the-script-element/execution-timing/scripts/include-1.js
rename : testing/web-platform/tests/old-tests/submission/Opera/script_scheduling/scripts/include-10.js => testing/web-platform/tests/html/semantics/scripting-1/the-script-element/execution-timing/scripts/include-10.js
rename : testing/web-platform/tests/old-tests/submission/Opera/script_scheduling/scripts/include-11.js => testing/web-platform/tests/html/semantics/scripting-1/the-script-element/execution-timing/scripts/include-11.js
rename : testing/web-platform/tests/old-tests/submission/Opera/script_scheduling/scripts/include-2.js => testing/web-platform/tests/html/semantics/scripting-1/the-script-element/execution-timing/scripts/include-2.js
rename : testing/web-platform/tests/old-tests/submission/Opera/script_scheduling/scripts/include-3.js => testing/web-platform/tests/html/semantics/scripting-1/the-script-element/execution-timing/scripts/include-3.js
rename : testing/web-platform/tests/old-tests/submission/Opera/script_scheduling/scripts/include-4.js => testing/web-platform/tests/html/semantics/scripting-1/the-script-element/execution-timing/scripts/include-4.js
rename : testing/web-platform/tests/old-tests/submission/Opera/script_scheduling/scripts/include-5.js => testing/web-platform/tests/html/semantics/scripting-1/the-script-element/execution-timing/scripts/include-5.js
rename : testing/web-platform/tests/old-tests/submission/Opera/script_scheduling/scripts/include-6.js => testing/web-platform/tests/html/semantics/scripting-1/the-script-element/execution-timing/scripts/include-6.js
rename : testing/web-platform/tests/old-tests/submission/Opera/script_scheduling/scripts/include-7.js => testing/web-platform/tests/html/semantics/scripting-1/the-script-element/execution-timing/scripts/include-7.js
rename : testing/web-platform/tests/old-tests/submission/Opera/script_scheduling/scripts/include-8.js => testing/web-platform/tests/html/semantics/scripting-1/the-script-element/execution-timing/scripts/include-8.js
rename : testing/web-platform/tests/old-tests/submission/Opera/script_scheduling/scripts/include-9.js => testing/web-platform/tests/html/semantics/scripting-1/the-script-element/execution-timing/scripts/include-9.js
rename : testing/web-platform/tests/assumptions/OWNERS => testing/web-platform/tests/infrastructure/assumptions/OWNERS
rename : testing/web-platform/tests/assumptions/canvas-background-ref.html => testing/web-platform/tests/infrastructure/assumptions/canvas-background-ref.html
rename : testing/web-platform/tests/assumptions/canvas-background.html => testing/web-platform/tests/infrastructure/assumptions/canvas-background.html
rename : testing/web-platform/tests/assumptions/html-elements.html => testing/web-platform/tests/infrastructure/assumptions/html-elements.html
rename : testing/web-platform/tests/assumptions/initial-color-ref.html => testing/web-platform/tests/infrastructure/assumptions/initial-color-ref.html
rename : testing/web-platform/tests/assumptions/initial-color.html => testing/web-platform/tests/infrastructure/assumptions/initial-color.html
rename : testing/web-platform/tests/assumptions/medium-font-size-ref.html => testing/web-platform/tests/infrastructure/assumptions/medium-font-size-ref.html
rename : testing/web-platform/tests/assumptions/medium-font-size.html => testing/web-platform/tests/infrastructure/assumptions/medium-font-size.html
rename : testing/web-platform/tests/assumptions/min-font-size-ref.html => testing/web-platform/tests/infrastructure/assumptions/min-font-size-ref.html
rename : testing/web-platform/tests/assumptions/min-font-size.html => testing/web-platform/tests/infrastructure/assumptions/min-font-size.html
rename : testing/web-platform/tests/assumptions/tools/build.sh => testing/web-platform/tests/infrastructure/assumptions/tools/build.sh
rename : testing/web-platform/tests/infrastructure/failing-test.html => testing/web-platform/tests/infrastructure/expected-fail/failing-test.html
rename : testing/web-platform/tests/html/webappapis/idle-callbacks/callback-exception.html => testing/web-platform/tests/requestidlecallback/callback-exception.html
rename : testing/web-platform/tests/html/webappapis/idle-callbacks/callback-idle-periods.html => testing/web-platform/tests/requestidlecallback/callback-idle-periods.html
rename : testing/web-platform/tests/html/webappapis/idle-callbacks/callback-iframe.html => testing/web-platform/tests/requestidlecallback/callback-iframe.html
rename : testing/web-platform/tests/html/webappapis/idle-callbacks/callback-invoked.html => testing/web-platform/tests/requestidlecallback/callback-invoked.html
rename : testing/web-platform/tests/html/webappapis/idle-callbacks/callback-multiple-calls.html => testing/web-platform/tests/requestidlecallback/callback-multiple-calls.html
rename : testing/web-platform/tests/html/webappapis/idle-callbacks/callback-removed-frame.html => testing/web-platform/tests/requestidlecallback/callback-removed-frame.html
rename : testing/web-platform/tests/html/webappapis/idle-callbacks/callback-timeout-with-raf.html => testing/web-platform/tests/requestidlecallback/callback-timeout-with-raf.html
rename : testing/web-platform/tests/html/webappapis/idle-callbacks/callback-timeout.html => testing/web-platform/tests/requestidlecallback/callback-timeout.html
rename : testing/web-platform/tests/html/webappapis/idle-callbacks/callback-xhr-sync.html => testing/web-platform/tests/requestidlecallback/callback-xhr-sync.html
rename : testing/web-platform/tests/html/webappapis/idle-callbacks/cancel-invoked.html => testing/web-platform/tests/requestidlecallback/cancel-invoked.html
rename : testing/web-platform/tests/html/webappapis/idle-callbacks/idlharness.html => testing/web-platform/tests/requestidlecallback/idlharness.html
rename : testing/web-platform/tests/html/webappapis/idle-callbacks/resources/post_name_on_load.html => testing/web-platform/tests/requestidlecallback/resources/post_name_on_load.html
rename : testing/web-platform/tests/webrtc/RTCDTMFSender-insertDTMF.html => testing/web-platform/tests/webrtc/RTCDTMFSender-insertDTMF.https.html
rename : testing/web-platform/tests/webrtc/RTCDTMFSender-ontonechange-long.html => testing/web-platform/tests/webrtc/RTCDTMFSender-ontonechange-long.https.html
rename : testing/web-platform/tests/webrtc/RTCDTMFSender-ontonechange.html => testing/web-platform/tests/webrtc/RTCDTMFSender-ontonechange.https.html
rename : testing/web-platform/tests/webrtc/RTCPeerConnection-addTrack.html => testing/web-platform/tests/webrtc/RTCPeerConnection-addTrack.https.html
rename : testing/web-platform/tests/webrtc/RTCPeerConnection-ontrack.html => testing/web-platform/tests/webrtc/RTCPeerConnection-ontrack.https.html
rename : testing/web-platform/tests/webrtc/RTCPeerConnection-removeTrack.html => testing/web-platform/tests/webrtc/RTCPeerConnection-removeTrack.https.html
rename : testing/web-platform/tests/webrtc/RTCRtpReceiver-getContributingSources.html => testing/web-platform/tests/webrtc/RTCRtpReceiver-getContributingSources.https.html
rename : testing/web-platform/tests/webrtc/RTCRtpReceiver-getSynchronizationSources.html => testing/web-platform/tests/webrtc/RTCRtpReceiver-getSynchronizationSources.https.html
2017-10-25 10:45:59 +01:00

166 lines
7.4 KiB
HTML

<!doctype html>
<meta charset=utf-8>
<title>DOMImplementation.createDocument(namespace, qualifiedName, doctype)</title>
<link rel=help href="https://dom.spec.whatwg.org/#dom-domimplementation-createdocument">
<link rel=help href="https://dom.spec.whatwg.org/#dom-document-createelementns">
<link rel=help href="https://dom.spec.whatwg.org/#dom-node-nodetype">
<link rel=help href="https://dom.spec.whatwg.org/#dom-document-documentelement">
<link rel=help href="https://dom.spec.whatwg.org/#dom-document-doctype">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="Document-createElementNS.js"></script>
<div id="log"></div>
<script>
var htmlNamespace = "http://www.w3.org/1999/xhtml"
var svgNamespace = "http://www.w3.org/2000/svg"
var mathMLNamespace = "http://www.w3.org/1998/Math/MathML"
// Make DocumentTypes distinct
function my_format_value(val) {
if (val instanceof DocumentType) {
return "DocumentType node <!DOCTYPE " + val.name
+ (val.publicId ? " " + val.publicId : "")
+ (val.systemId ? " " + val.systemId : "")
+ ">";
}
return format_value(val);
}
test(function() {
var tests = createElementNS_tests.map(function(t) {
return [t[0], t[1], null, t[2]]
}).concat([
/* Arrays with four elements:
* the namespace argument
* the qualifiedName argument
* the doctype argument
* the expected exception, or null if none
*/
[null, null, false, new TypeError()],
[null, "", null, null],
[undefined, null, undefined, null],
[undefined, undefined, undefined, null],
[undefined, "", undefined, null],
["http://example.com/", null, null, null],
["http://example.com/", "", null, null],
["/", null, null, null],
["/", "", null, null],
["http://www.w3.org/XML/1998/namespace", null, null, null],
["http://www.w3.org/XML/1998/namespace", "", null, null],
["http://www.w3.org/2000/xmlns/", null, null, null],
["http://www.w3.org/2000/xmlns/", "", null, null],
["foo:", null, null, null],
["foo:", "", null, null],
[null, null, document.implementation.createDocumentType("foo", "", ""), null],
[null, null, document.doctype, null], // This causes a horrible WebKit bug (now fixed in trunk).
[null, null, function() {
var foo = document.implementation.createDocumentType("bar", "", "");
document.implementation.createDocument(null, null, foo);
return foo;
}(), null], // DOCTYPE already associated with a document.
[null, null, function() {
var bar = document.implementation.createDocument(null, null, null);
return bar.implementation.createDocumentType("baz", "", "");
}(), null], // DOCTYPE created by a different implementation.
[null, null, function() {
var bar = document.implementation.createDocument(null, null, null);
var magic = bar.implementation.createDocumentType("quz", "", "");
bar.implementation.createDocument(null, null, magic);
return magic;
}(), null], // DOCTYPE created by a different implementation and already associated with a document.
[null, "foo", document.implementation.createDocumentType("foo", "", ""), null],
["foo", null, document.implementation.createDocumentType("foo", "", ""), null],
["foo", "bar", document.implementation.createDocumentType("foo", "", ""), null],
[htmlNamespace, "", null, null],
[svgNamespace, "", null, null],
[mathMLNamespace, "", null, null],
[null, "html", null, null],
[null, "svg", null, null],
[null, "math", null, null],
[null, "", document.implementation.createDocumentType("html",
"-//W3C//DTD XHTML 1.0 Transitional//EN",
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd")],
[null, "", document.implementation.createDocumentType("svg",
"-//W3C//DTD SVG 1.1//EN",
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd")],
[null, "", document.implementation.createDocumentType("math",
"-//W3C//DTD MathML 2.0//EN",
"http://www.w3.org/Math/DTD/mathml2/mathml2.dtd")],
])
tests.forEach(function(t, i) {
var namespace = t[0], qualifiedName = t[1], doctype = t[2], expected = t[3]
test(function() {
if (expected != null) {
assert_throws(expected, function() { document.implementation.createDocument(namespace, qualifiedName, doctype) })
} else {
var doc = document.implementation.createDocument(namespace, qualifiedName, doctype)
assert_equals(doc.nodeType, Node.DOCUMENT_NODE)
assert_equals(doc.nodeType, doc.DOCUMENT_NODE)
assert_equals(doc.nodeName, "#document")
assert_equals(doc.nodeValue, null)
assert_equals(Object.getPrototypeOf(doc), XMLDocument.prototype)
var omitRootElement = qualifiedName === null || String(qualifiedName) === ""
if (omitRootElement) {
assert_equals(doc.documentElement, null)
} else {
var element = doc.documentElement
assert_not_equals(element, null)
assert_equals(element.nodeType, Node.ELEMENT_NODE)
assert_equals(element.ownerDocument, doc)
var qualified = String(qualifiedName), names = []
if (qualified.indexOf(":") >= 0) {
names = qualified.split(":", 2)
} else {
names = [null, qualified]
}
assert_equals(element.prefix, names[0])
assert_equals(element.localName, names[1])
assert_equals(element.namespaceURI, namespace === undefined ? null : namespace)
}
if (!doctype) {
assert_equals(doc.doctype, null)
} else {
assert_equals(doc.doctype, doctype)
assert_equals(doc.doctype.ownerDocument, doc)
}
assert_equals(doc.childNodes.length, !omitRootElement + !!doctype)
}
}, "createDocument test: " + t.map(my_format_value))
if (expected === null) {
test(function() {
var doc = document.implementation.createDocument(namespace, qualifiedName, doctype)
assert_equals(doc.location, null)
assert_equals(doc.compatMode, "CSS1Compat")
assert_equals(doc.characterSet, "UTF-8")
assert_equals(doc.contentType, namespace == htmlNamespace ? "application/xhtml+xml"
: namespace == svgNamespace ? "image/svg+xml"
: "application/xml")
assert_equals(doc.URL, "about:blank")
assert_equals(doc.documentURI, "about:blank")
assert_equals(doc.createElement("DIV").localName, "DIV");
}, "createDocument test: metadata for " +
[namespace, qualifiedName, doctype].map(my_format_value))
test(function() {
var doc = document.implementation.createDocument(namespace, qualifiedName, doctype)
assert_equals(doc.characterSet, "UTF-8", "characterSet");
assert_equals(doc.charset, "UTF-8", "charset");
assert_equals(doc.inputEncoding, "UTF-8", "inputEncoding");
}, "createDocument test: characterSet aliases for " +
[namespace, qualifiedName, doctype].map(my_format_value))
}
})
})
test(function() {
assert_throws(new TypeError(), function() {
document.implementation.createDocument()
}, "createDocument() should throw")
assert_throws(new TypeError(), function() {
document.implementation.createDocument('')
}, "createDocument('') should throw")
}, "createDocument with missing arguments");
</script>