diff options
Diffstat (limited to 'testing/web-platform/tests/custom-elements/v0/creating-and-passing-registries/share-registry-create-document.html')
-rw-r--r-- | testing/web-platform/tests/custom-elements/v0/creating-and-passing-registries/share-registry-create-document.html | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/testing/web-platform/tests/custom-elements/v0/creating-and-passing-registries/share-registry-create-document.html b/testing/web-platform/tests/custom-elements/v0/creating-and-passing-registries/share-registry-create-document.html new file mode 100644 index 000000000..64244f169 --- /dev/null +++ b/testing/web-platform/tests/custom-elements/v0/creating-and-passing-registries/share-registry-create-document.html @@ -0,0 +1,51 @@ +<!DOCTYPE html> +<html> +<head> +<title>Document, created with createHTMLDocument or createDocument with HTML namespace, should share registry with the associated document</title> +<meta name="author" title="Sergey G. Grekhov" href="mailto:sgrekhov@unipro.ru"> +<meta name="assert" content="When DOMImplementation's createDocument method is invoked with namespace set to HTML Namespace or when the createHTMLDocument method is invoked, use the registry of the associated document to the new instance."> +<link rel="help" href="http://www.w3.org/TR/custom-elements/#creating-and-passing-registries"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="../testcommon.js"></script> +</head> +<body> +<div id="log"></div> +<script> +test(function() { + var doc = newHTMLDocument(); + var name = 'x-frame'; + + var GeneratedConstructor = doc.registerElement(name); + var doc2 = doc.implementation.createHTMLDocument('Document 2'); + assert_throws( + 'NotSupportedError', + function() { doc2.registerElement(name); }, + 'Registering a custom element type name that is already registered in a shared ' + + 'registry should throw an exception'); + + var xframe = doc2.createElement(name); + assert_true(xframe instanceof GeneratedConstructor, + 'Created element should be x-frame instance'); +}, 'Document created by createHTMLDocument should share an existing registry'); + + +test(function() { + var doc = newHTMLDocument(); + var name = 'x-frame-1'; + + var GeneratedConstructor = doc.registerElement(name); + var doc2 = doc.implementation.createDocument(HTML_NAMESPACE, 'html', null); + assert_throws( + 'NotSupportedError', + function() { doc2.registerElement(name); }, + 'Exception should be thrown for custom element, ' + + 'which is already registered in shared registry'); + + var xframe = doc2.createElement(name); + assert_true(xframe instanceof GeneratedConstructor, + 'Created element should be x-frame instance'); +}, 'Document created by createDocument with HTML namespace should share an existing registry'); +</script> +</body> +</html> |