summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/custom-elements/v0/instantiating/extensions-to-document-interface/create-element-type-extension-unresolved.html
blob: 3eaadf31251d92217954948e82dd357777312fab (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
<!DOCTYPE html>
<html>
<head>
<title>Document.createElement() and Document.createElementNS() create custom element of type, specified by localName 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 not registered with token's document, set TYPE to localName">
<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();
    HTML5_ELEMENTS.forEach(function(tagName) {
        var obj = doc.createElement(tagName);
        var name = 'x-a-' + tagName;
        var proto = Object.create(obj.constructor.prototype);
        var customElement = doc.createElement(tagName, name);
        assert_equals(Object.getPrototypeOf(customElement), Object.getPrototypeOf(obj),
            'Unregistered custom element type should be a local name');

        var GeneratedConstructor = doc.registerElement(name, {prototype: proto, extends: tagName});
        assert_equals(Object.getPrototypeOf(customElement), GeneratedConstructor.prototype,
            'Registered custom element type should be the type extension');
    });
}, 'If typeExtension is unresolved when createElement called then local name is a type');


test (function() {
    var doc = newHTMLDocument();
    HTML5_ELEMENTS.forEach(function(tagName) {
        var obj = doc.createElement(tagName);
        var name = 'x-b-' + tagName;
        var proto = Object.create(obj.constructor.prototype);
        var customElement = doc.createElementNS(HTML_NAMESPACE, tagName, name);
        assert_equals(Object.getPrototypeOf(customElement), Object.getPrototypeOf(obj),
            'Custom element type should be a local name');

        var GeneratedConstructor = doc.registerElement(name, {prototype: proto, extends: tagName});
        assert_equals(Object.getPrototypeOf(customElement), GeneratedConstructor.prototype,
            'Custom element type should be the type extension');
    });
}, 'If typeExtension is unresolved when createElementNS called then local name is a type');
</script>
</body>
</html>