diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /testing/web-platform/tests/custom-elements/v0/creating-and-passing-registries | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'testing/web-platform/tests/custom-elements/v0/creating-and-passing-registries')
4 files changed, 233 insertions, 0 deletions
diff --git a/testing/web-platform/tests/custom-elements/v0/creating-and-passing-registries/new-registry-test.html b/testing/web-platform/tests/custom-elements/v0/creating-and-passing-registries/new-registry-test.html new file mode 100644 index 000000000..597f15c21 --- /dev/null +++ b/testing/web-platform/tests/custom-elements/v0/creating-and-passing-registries/new-registry-test.html @@ -0,0 +1,39 @@ +<!DOCTYPE html> +<html> +<head> +<title>When an HTML Document is loaded in a browsing context, a new registry must be created and associated with this document</title> +<meta name="author" title="Aleksei Yu. Semenov" href="mailto:a.semenov@unipro.ru"> +<meta name="author" title="Sergey G. Grekhov" href="mailto:sgrekhov@unipro.ru"> +<meta name="assert" content="When an HTML Document is loaded in a browsing context, a new registry must be created and associated with this document."> +<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> +testInIFrame('../resources/blank.html', function(doc) { + try { + doc.registerElement('x-element'); + } catch (e) { + assert_unreached('Unexpected exception, while registering a valid custom element'); + } +}, 'Document, loaded into browsing context, must have a new empty registry'); + + +testInIFrame('../resources/blank.html', function(loadedDocument) { + var createdDocument = document.implementation.createHTMLDocument('Test Document'); + // Let's check that loadedDocument and createdDocument use different registeries. + createdDocument.registerElement('x-element'); + try { + loadedDocument.registerElement('x-element'); + } catch (e) { + assert_unreached('Unexpected exception while registering a custom element ' + + 'in a document, which has it\'s own registry'); + } +}, 'Document, loaded into browsing context, must have a new empty registry, ' + + 'which is different from other documents\' registries'); +</script> +</body> +</html> diff --git a/testing/web-platform/tests/custom-elements/v0/creating-and-passing-registries/no-registry-test.html b/testing/web-platform/tests/custom-elements/v0/creating-and-passing-registries/no-registry-test.html new file mode 100644 index 000000000..d936fd34f --- /dev/null +++ b/testing/web-platform/tests/custom-elements/v0/creating-and-passing-registries/no-registry-test.html @@ -0,0 +1,48 @@ +<!DOCTYPE html> +<html> +<head> +<title>New document without browsing context must not have a registry</title> +<meta name="author" title="Aleksei Yu. Semenov" href="mailto:a.semenov@unipro.ru"> +<meta name="author" title="Sergey G. Grekhov" href="mailto:sgrekhov@unipro.ru"> +<meta name="assert" content="In all other cases, new documents must not have a registry."> +<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 = document.implementation.createDocument(null, 'test', null); + assert_throws( + 'NotSupportedError', + function() { doc.registerElement('x-element'); }, + 'Registering valid custom element in a document ' + + 'without registry should fail'); +}, 'Document of type other than HTML, not loaded into browsing context, must not have a registry'); + +async_test(function(t) { + var request = new XMLHttpRequest(); + request.onreadystatechange = t.step_func(function() { + if (request.readyState == 4){ + assert_equals(200, request.status, 'Test document is not loaded correctly'); + var doc = request.response; + assert_true(doc instanceof HTMLDocument, + 'XMLHttpRequest\'s asynchronous response should be HTML document'); + assert_throws( + 'NotSupportedError', + function() { doc.registerElement('x-element'); }, + 'Registering valid custom element in ' + + 'an XMLHttpRequest\'s response document should fail'); + t.done(); + } + }); + + request.open('GET', '../resources/blank.html', true); + request.responseType = 'document'; + request.send(); +}, 'XMLHttpRequest\'s asynchronous response HTML document must not have a registry'); +</script> +</body> +</html> 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> diff --git a/testing/web-platform/tests/custom-elements/v0/creating-and-passing-registries/share-registry-import-document.html b/testing/web-platform/tests/custom-elements/v0/creating-and-passing-registries/share-registry-import-document.html new file mode 100644 index 000000000..251e4f123 --- /dev/null +++ b/testing/web-platform/tests/custom-elements/v0/creating-and-passing-registries/share-registry-import-document.html @@ -0,0 +1,95 @@ +<!DOCTYPE html> +<html> +<head> +<title>When creating an import, use the registry of the master document</title> +<meta name="author" title="Sergey G. Grekhov" href="mailto:sgrekhov@unipro.ru"> +<meta name="assert" content="When creating an import, use the registry of the master document."> +<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> +var test1 = async_test('Registry of the imported document should be shared with master document. ' + + 'Import is asynchronous'); +test1.step(function() { + var iframe = newIFrame('../resources/import-master-async.html'); + document.body.appendChild(iframe); + iframe.onload = test1.step_func(function() { + var doc = iframe.contentDocument; + var link = doc.querySelector('link[rel=import]'); + link.onload = test1.step_func(function() { + try { + var doc2 = link.import; + var name = 'x-frame'; + doc.registerElement(name); + 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'); + test1.done(); + } finally { + iframe.remove(); + } + }); + }); +}); + + +var test2 = async_test('Registry of the master document should be shared with imported document. ' + + 'Import is asynchronous'); +test2.step(function() { + var iframe = newIFrame('../resources/import-master-async.html'); + document.body.appendChild(iframe); + iframe.onload = test2.step_func(function() { + var doc = iframe.contentDocument; + var link = doc.querySelector('link[rel=import]'); + link.onload = test2.step_func(function() { + try { + var doc2 = link.import; + var name = 'x-frame'; + doc2.registerElement(name); + assert_throws( + 'NotSupportedError', + function() { doc.registerElement(name); }, + 'Registering a custom element type name that is already registered in a shared ' + + 'registry should throw an exception'); + test2.done(); + } finally { + iframe.remove(); + } + }); + }); +}); + + +testInIFrame('../resources/import-master.html', function(doc) { + var link = doc.querySelector('link[rel=import]'); + var doc2 = link.import; + var name = 'x-frame'; + doc.registerElement(name); + 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'); +}, 'Registry of the imported document should be shared with master document. Import is syncronous'); + + +testInIFrame('../resources/import-master.html', function(doc) { + var link = doc.querySelector('link[rel=import]'); + var doc2 = link.import; + var name = 'x-frame'; + doc2.registerElement(name); + assert_throws( + 'NotSupportedError', + function() { doc.registerElement(name); }, + 'Registering a custom element type name that is already registered in a shared ' + + 'registry should throw an exception'); +}, 'Registry of the master document should be shared with imported document. Import is syncronous'); +</script> +</body> +</html> |