summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/custom-elements/v0/instantiating/extensions-to-document-interface/create-element-interface-type-is-a-type-extension.html
blob: 3df042676277d2aff56d0059883c815c35ee4fb0 (plain)
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<!DOCTYPE html>
<html>
<head>
<title>Document.createElement() and Document.createElementNS() create custom element of type, specified by typeExtension argument</title>
<meta name="author" title="Sergey G. Grekhov" href="mailto:sgrekhov@unipro.ru">
<meta name="assert" content="If an element definition with matching localName, namespace, and TYPE is registered then typeExtension is a TYPE">
<link rel="help" href="http://www.w3.org/TR/custom-elements/#extensions-to-document-interface-to-instantiate">
<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 name1 = 'x-a';
    var GeneratedConstructor1 = doc.registerElement(name1);
    var name2 = 'x-b';
    var GeneratedConstructor2 = doc.registerElement(name2);
    var customElement = doc.createElement(name1, name2);

    assert_equals(Object.getPrototypeOf(customElement), GeneratedConstructor2.prototype,
        'Custom element type should be the type extension of the custom element');
}, 'Test Document.createElement() creates custom element of type, ' +
    'specified by typeExtension argument');


test(function() {
    var doc = newHTMLDocument();
    var name1 = 'x-c';
    var GeneratedConstructor1 = doc.registerElement(name1);
    var name2 = 'x-d';
    var GeneratedConstructor2 = doc.registerElement(name2);
    var customElement = doc.createElementNS(HTML_NAMESPACE, name1, name2);

    assert_equals(Object.getPrototypeOf(customElement), GeneratedConstructor2.prototype,
        'Custom element type should be the type extension of the custom element');
}, 'Test Document.createElementNS() creates custom element of type, ' +
    'specified by typeExtension argument');


test(function() {
    var doc = newHTMLDocument();
    var name1 = 'x-e';
    var name2 = 'x-f';
    var GeneratedConstructor2 = doc.registerElement(name2);
    var customElement = doc.createElement(name1, name2);

    assert_equals(Object.getPrototypeOf(customElement), GeneratedConstructor2.prototype,
        'Custom element type should be the type extension of the custom element');
}, 'Test Document.createElement() creates custom element of type, ' +
    'specified by typeExtension argument. Definition for localName is absent');


test(function() {
    var doc = newHTMLDocument();
    var name1 = 'x-g';
    var name2 = 'x-h';
    var GeneratedConstructor2 = doc.registerElement(name2);
    var customElement = doc.createElementNS(HTML_NAMESPACE, name1, name2);

    assert_equals(Object.getPrototypeOf(customElement), GeneratedConstructor2.prototype,
        'Custom element type should be the type extension of the custom element');
}, 'Test Document.createElementNS() creates custom element of type, ' +
    'specified by typeExtension argument. Definition for localName is absent');
</script>
</body>
</html>