OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <html> |
| 3 <head> |
| 4 <title>Document, created with createHTMLDocument or createDocument with HTML nam
espace, should share registry with the associated document</title> |
| 5 <meta name="author" title="Sergey G. Grekhov" href="mailto:sgrekhov@unipro.ru"> |
| 6 <meta name="assert" content="When DOMImplementation's createDocument method is i
nvoked with namespace set to HTML Namespace or when the createHTMLDocument metho
d is invoked, use the registry of the associated document to the new instance."> |
| 7 <link rel="help" href="http://www.w3.org/TR/custom-elements/#creating-and-passin
g-registries"> |
| 8 <script src="../../../../resources/testharness.js"></script> |
| 9 <script src="../../../../resources/testharnessreport.js"></script> |
| 10 <script src="../testcommon.js"></script> |
| 11 <link rel="stylesheet" href="../../../../resources/testharness.css"> |
| 12 </head> |
| 13 <body> |
| 14 <div id="log"></div> |
| 15 <script> |
| 16 test(function() { |
| 17 var doc = newHTMLDocument(); |
| 18 var name = 'x-frame'; |
| 19 |
| 20 var GeneratedConstructor = doc.registerElement(name); |
| 21 var doc2 = doc.implementation.createHTMLDocument('Document 2'); |
| 22 assert_throws( |
| 23 'NotSupportedError', |
| 24 function() { doc2.registerElement(name); }, |
| 25 'Registering a custom element type name that is already registered in a
shared ' + |
| 26 'registry should throw an exception'); |
| 27 |
| 28 var xframe = doc2.createElement(name); |
| 29 assert_true(xframe instanceof GeneratedConstructor, |
| 30 'Created element should be x-frame instance'); |
| 31 }, 'Document created by createHTMLDocument should share an existing registry'); |
| 32 |
| 33 |
| 34 test(function() { |
| 35 var doc = newHTMLDocument(); |
| 36 var name = 'x-frame-1'; |
| 37 |
| 38 var GeneratedConstructor = doc.registerElement(name); |
| 39 var doc2 = doc.implementation.createDocument(HTML_NAMESPACE, 'html', null); |
| 40 assert_throws( |
| 41 'NotSupportedError', |
| 42 function() { doc2.registerElement(name); }, |
| 43 'Exception should be thrown for custom element, ' + |
| 44 'which is already registered in shared registry'); |
| 45 |
| 46 var xframe = doc2.createElement(name); |
| 47 assert_true(xframe instanceof GeneratedConstructor, |
| 48 'Created element should be x-frame instance'); |
| 49 }, 'Document created by createDocument with HTML namespace should share an exist
ing registry'); |
| 50 </script> |
| 51 </body> |
| 52 </html> |
OLD | NEW |