OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <!-- |
| 3 Distributed under both the W3C Test Suite License [1] and the W3C |
| 4 3-clause BSD License [2]. To contribute to a W3C Test Suite, see the |
| 5 policies and contribution forms [3]. |
| 6 |
| 7 [1] http://www.w3.org/Consortium/Legal/2008/04-testsuite-license |
| 8 [2] http://www.w3.org/Consortium/Legal/2008/03-bsd-license |
| 9 [3] http://www.w3.org/2004/10/27-testcases |
| 10 --> |
| 11 <html> |
| 12 <head> |
| 13 <title>Shadow DOM Test: A_08_02_02</title> |
| 14 <link rel="author" title="Sergey G. Grekhov" href="mailto:sgrekhov@unipro.ru"> |
| 15 <link rel="help" href="http://www.w3.org/TR/2013/WD-shadow-dom-20130514/#html-fo
rms"> |
| 16 <meta name="assert" content="HTML Elements in shadow trees: Form elements and fo
rm-associated elements in shadow tree must be accessible using shadow tree acces
sors"> |
| 17 <script src="../../../../../resources/testharness.js"></script> |
| 18 <script src="../../../../../resources/testharnessreport.js"></script> |
| 19 <script src="../../testcommon.js"></script> |
| 20 <link rel="stylesheet" href="../../../../../resources/testharness.css"> |
| 21 </head> |
| 22 <body> |
| 23 <div id="log"></div> |
| 24 <script> |
| 25 //test form-associated elements |
| 26 test(function () { |
| 27 var d = newHTMLDocument(); |
| 28 |
| 29 var form = d.createElement('form'); |
| 30 form.setAttribute('id', 'form_id'); |
| 31 d.body.appendChild(form); |
| 32 |
| 33 var div = d.createElement('div'); |
| 34 d.body.appendChild(div); |
| 35 var s = div.createShadowRoot(); |
| 36 |
| 37 |
| 38 HTML5_FORM_ASSOCIATED_ELEMENTS.forEach(function (tagName) { |
| 39 |
| 40 var el = d.createElement(tagName); |
| 41 el.setAttribute('form', 'form_id'); |
| 42 el.setAttribute('id', tagName + '_id'); |
| 43 s.appendChild(el); |
| 44 |
| 45 assert_true(s.querySelector('#' + tagName + '_id') != null, 'Form-associ
ated element ' + tagName + |
| 46 ' in shadow tree must be accessible shadow tree accessor
s'); |
| 47 assert_equals(s.querySelector('#' + tagName + '_id').getAttribute('id'),
tagName + '_id', |
| 48 'Form-associated element ' + tagName + ' in shadow tree must be
accessible shadow tree accessors'); |
| 49 }); |
| 50 }, 'A_08_02_02_T01'); |
| 51 |
| 52 |
| 53 //test form elements |
| 54 test(function () { |
| 55 var d = newHTMLDocument(); |
| 56 |
| 57 var form = d.createElement('form'); |
| 58 d.body.appendChild(form); |
| 59 |
| 60 var div = d.createElement('div'); |
| 61 form.appendChild(div); |
| 62 var s = div.createShadowRoot(); |
| 63 |
| 64 HTML5_FORM_ASSOCIATED_ELEMENTS.forEach(function (tagName) { |
| 65 |
| 66 var el = d.createElement(tagName); |
| 67 el.setAttribute('id', tagName + '_id'); |
| 68 s.appendChild(el); |
| 69 |
| 70 assert_true(s.querySelector('#' + tagName + '_id') != null, 'Form-associ
ated element ' + tagName + |
| 71 ' in shadow tree must be accessible shadow tree accessors'); |
| 72 assert_equals(s.querySelector('#' + tagName + '_id').getAttribute('id'),
tagName + '_id', |
| 73 'Form element ' + tagName + ' in shadow tree must be accessi
ble shadow tree accessors'); |
| 74 }); |
| 75 }, 'A_08_02_02_T02'); |
| 76 |
| 77 |
| 78 //test distributed form elements |
| 79 test(function () { |
| 80 var d = newHTMLDocument(); |
| 81 |
| 82 HTML5_FORM_ASSOCIATED_ELEMENTS.forEach(function (tagName) { |
| 83 |
| 84 var form = d.createElement('form'); |
| 85 d.body.appendChild(form); |
| 86 |
| 87 var div = d.createElement('div'); |
| 88 form.appendChild(div); |
| 89 |
| 90 var el = d.createElement(tagName); |
| 91 el.setAttribute('id', tagName + '_id'); |
| 92 div.appendChild(el); |
| 93 |
| 94 var s = div.createShadowRoot(); |
| 95 s.innerHTML = '<content select="' + tagName + '"></content>'; |
| 96 |
| 97 assert_true(s.querySelector('#' + tagName + '_id') == null, 'Distributed
form-associated element ' + tagName + |
| 98 ' in shadow tree must not be accessible shadow tree accessors'); |
| 99 }); |
| 100 }, 'A_08_02_02_T03'); |
| 101 </script> |
| 102 </body> |
| 103 </html> |
OLD | NEW |