1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
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>
|