Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / forms / form-attribute-elements.html
blobd510bd7a258929644199faa547052f58de1c07b1
1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
2 <html>
3 <head>
4 <script src="../../resources/js-test.js"></script>
5 </head>
6 <body>
7 <p id="description"></p>
8 <div id="console"></div>
9 <script>
10 description("This test checks a form element can handle elements of which form attribute points the form element even if elements are outside of the form.");
12 if (window.testRunner)
13 testRunner.waitUntilDone();
15 var container = document.createElement('div');
16 document.body.appendChild(container);
18 container.innerHTML = '<input type=hidden name=key1 value=value1 id=outer-before form=owner />' +
19 '<form id=owner action="" method="GET">' +
20 ' <input type=hidden name=key2 value=value2 id=inner form=owner />' +
21 '</form>' +
22 '<input type=hidden name=submitted value=true id=outer-after form=owner />';
24 var owner = document.getElementById('owner');
25 var outerBefore = document.getElementById('outer-before');
26 var inner = document.getElementById('inner');
27 var outerAfter = document.getElementById('outer-after');
28 var query = window.location.search;
30 if (query.indexOf('submitted=true') == -1) {
31 owner.submit();
32 } else {
33 debug('- Ensures that elements attribute of the form contains elements which are outside of the form.');
35 shouldBe('owner.elements.length', '3');
36 shouldBe('owner.elements[0]', 'outerBefore');
37 shouldBe('owner.elements[1]', 'inner');
38 shouldBe('owner.elements[2]', 'outerAfter');
40 debug('');
41 debug('- Ensures that form submission contains name and value pairs for such elements.');
42 var pairs = query.substr(1).split('&');
43 shouldBe('pairs.length', '3');
44 shouldBeEqualToString('pairs[0]', 'key1=value1');
45 shouldBeEqualToString('pairs[1]', 'key2=value2');
46 shouldBeEqualToString('pairs[2]', 'submitted=true');
47 if (window.testRunner)
48 testRunner.notifyDone();
50 </script>
51 </body>
52 </html>