summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/shadow-dom/untriaged/shadow-trees/upper-boundary-encapsulation/test-007.html
blob: 0cfe169b441ceab9e681ed4cd63ce7266e82468f (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
<!DOCTYPE html>
<html>
<head>
<title>Shadow DOM Test: A_04_01_07</title>
<link rel="author" title="Sergey G. Grekhov" href="mailto:sgrekhov@unipro.ru">
<link rel="help" href="http://www.w3.org/TR/2013/WD-shadow-dom-20130514/#upper-boundary-encapsulation">
<meta name="assert" content="Upper-boundary encapsulation:The nodes with a unique id and named elements are addressable from any attributes of elements in the same shadow DOM subtree">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="../../../../html/resources/common.js"></script>
</head>
<body>
<div id="log"></div>
<script>
// check for label.control
test(function () {
    var d = newHTMLDocument();
    var div = d.createElement('div');
    d.body.appendChild(div);
    var s = div.attachShadow({mode: 'open'});

    var input = d.createElement('input');
    input.setAttribute('type', 'text');
    input.setAttribute('id', 'input_id');
    d.body.appendChild(input);

    var label = d.createElement('label');
    label.setAttribute('for', 'input_id');
    s.appendChild(label);
    s.appendChild(input);

    assert_equals(label.control, input, 'Elements in shadow DOM must be accessible from ' +
        'shadow document label.for attribute');

}, 'A_04_01_07_T01');

// check for elem.form associated elements
test(function () {

    HTML5_FORM_ASSOCIATED_ELEMENTS.forEach(function (tagName) {
        d = newHTMLDocument();

        var form = d.createElement('form');
        var el = d.createElement(tagName);

        d.body.appendChild(form);
        d.body.appendChild(el);

        form.setAttribute('id', 'form_id');
        el.setAttribute('form', 'form_id');

        div = d.createElement('div');
        d.body.appendChild(div);

        var s = div.attachShadow({mode: 'open'});
        s.appendChild(form);
        s.appendChild(el);

        assert_equals(el.form, form, 'Elements in shadow DOM must be accessible from ' +
            'shadow document ' + tagName + '.form attribute');
    });
}, 'A_04_01_07_T02');
</script>
</body>
</html>