diff options
Diffstat (limited to 'testing/web-platform/tests/dom/parts/dom-parts-valid-node-types.tentative.html')
-rw-r--r-- | testing/web-platform/tests/dom/parts/dom-parts-valid-node-types.tentative.html | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/testing/web-platform/tests/dom/parts/dom-parts-valid-node-types.tentative.html b/testing/web-platform/tests/dom/parts/dom-parts-valid-node-types.tentative.html new file mode 100644 index 0000000000..f9ed167e60 --- /dev/null +++ b/testing/web-platform/tests/dom/parts/dom-parts-valid-node-types.tentative.html @@ -0,0 +1,55 @@ +<!DOCTYPE html> +<title>DOM Parts: Valid node types for constructors</title> +<meta name="author" href="mailto:masonf@chromium.org"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="./resources/domparts-utils.js"></script> + +<body> +<template foo></template> +<script> + const root = document.getPartRoot(); + const xml = new DOMParser().parseFromString("<xml></xml>", "application/xml"); + const cdata = xml.createCDATASection('cdata'); + document.body.appendChild(cdata); + const pi = document.createProcessingInstruction('processing','instruction'); + document.body.appendChild(pi); + const invalidNodes = { + document: document.documentElement, + documentType: document.doctype, + attributeNode: document.querySelector('[foo]').attributes[0], + cdataSection: cdata, + processingInstruction: pi, + documentFragment: document.querySelector('[foo]').content, + }; + + const types = Object.keys(invalidNodes); + for(let i=0;i<types.length;++i) { + const type = types[i]; + const obj = invalidNodes[types[i]]; + const otherObj = invalidNodes[types[(i+1) % types.length]]; + test((t) => { + assert_throws_dom("INVALID_NODE_TYPE_ERR", () => { + new NodePart(root, obj, {}); + }); + assert_throws_dom("INVALID_NODE_TYPE_ERR", () => { + new ChildNodePart(root, obj, otherObj, {}); + }); + assert_throws_dom("INVALID_NODE_TYPE_ERR", () => { + new ChildNodePart(root, otherObj, obj, {}); + }); + },`Invalid node types (${type})`); + } + + test((t) => { + try { + const cnp = new ChildNodePart(root, invalidNodes.documentType, invalidNodes.document, {}); + cnp.clone(); + } catch {}; + try { + const np = new NodePart(root, invalidNodes.documentType, {}); + np.clone(); + } catch {}; + // This test passes if it does not crash. + },'Crash test'); +</script> |