OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <meta charset=utf-8> | 2 <meta charset=utf-8> |
3 <title>Attributes tests</title> | 3 <title>Attributes tests</title> |
4 <link rel=help href="https://dom.spec.whatwg.org/#attr"> | 4 <link rel=help href="https://dom.spec.whatwg.org/#attr"> |
5 <link rel=help href="https://dom.spec.whatwg.org/#dom-element-setattribute"> | 5 <link rel=help href="https://dom.spec.whatwg.org/#dom-element-setattribute"> |
6 <link rel=help href="https://dom.spec.whatwg.org/#dom-element-setattributens"> | 6 <link rel=help href="https://dom.spec.whatwg.org/#dom-element-setattributens"> |
7 <script src="/resources/testharness.js"></script> | 7 <script src="/resources/testharness.js"></script> |
8 <script src="/resources/testharnessreport.js"></script> | 8 <script src="/resources/testharnessreport.js"></script> |
9 <script src="attributes.js"></script> | 9 <script src="attributes.js"></script> |
10 <script src="productions.js"></script> | 10 <script src="productions.js"></script> |
11 <div id="log"></div> | 11 <div id="log"></div> |
12 <span id="test1"></span> | 12 <span id="test1"></span> |
13 <span class="&<>foo"></span> | 13 <span class="&<>foo"></span> |
14 <span id="test2"> | 14 <span id="test2"> |
15 <span ~=""></span> | 15 <span ~=""></span> |
16 <span ~></span> | 16 <span ~></span> |
17 <span></span> | 17 <span></span> |
18 </span> | 18 </span> |
19 <script> | 19 <script> |
20 var XML = "http://www.w3.org/XML/1998/namespace" | 20 var XML = "http://www.w3.org/XML/1998/namespace" |
21 var XMLNS = "http://www.w3.org/2000/xmlns/" | 21 var XMLNS = "http://www.w3.org/2000/xmlns/" |
22 | 22 |
23 // AttrExodus | |
24 test(function() { | |
25 document.body.setAttribute("abc", "pass") | |
26 var attr = document.body.attributes[0] | |
27 assert_true(attr instanceof Attr, "should be an Attr") | |
28 assert_false(attr instanceof Node, "should not be a Node") | |
29 var removed_members = [ | |
30 "appendChild", | |
31 "insertBefore", | |
32 "childNodes", | |
33 ] | |
34 removed_members.forEach(function(m) { | |
35 assert_false(m in attr, m + " should not be supported") | |
36 }) | |
37 assert_equals(attr.value, "pass") | |
38 }, "AttrExodus") | |
39 | |
40 // setAttribute exhaustive tests | 23 // setAttribute exhaustive tests |
41 // Step 1 | 24 // Step 1 |
42 test(function() { | 25 test(function() { |
43 var el = document.createElement("foo") | 26 var el = document.createElement("foo") |
44 for (var i = 0; i < invalid_names.length; i++) { | 27 for (var i = 0; i < invalid_names.length; i++) { |
45 assert_throws("INVALID_CHARACTER_ERR", function() { el.setAttribute(invalid_
names[i], "test") }) | 28 assert_throws("INVALID_CHARACTER_ERR", function() { el.setAttribute(invalid_
names[i], "test") }) |
46 } | 29 } |
47 }, "When qualifiedName does not match the Name production, an " + | 30 }, "When qualifiedName does not match the Name production, an " + |
48 "INVALID_CHARACTER_ERR exception is to be thrown. (setAttribute)") | 31 "INVALID_CHARACTER_ERR exception is to be thrown. (setAttribute)") |
49 test(function() { | 32 test(function() { |
(...skipping 670 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
720 el.setAttributeNS("", "I", ""); | 703 el.setAttributeNS("", "I", ""); |
721 el.setAttributeNS("", "j", ""); | 704 el.setAttributeNS("", "j", ""); |
722 assert_array_equals(Object.getOwnPropertyNames(el.attributes), | 705 assert_array_equals(Object.getOwnPropertyNames(el.attributes), |
723 ["0", "1", "2", "3", "4", "5", "A:B", "c:D", "e:F", "g:h",
"I", "j"]) | 706 ["0", "1", "2", "3", "4", "5", "A:B", "c:D", "e:F", "g:h",
"I", "j"]) |
724 for (var propName of Object.getOwnPropertyNames(el.attributes)) { | 707 for (var propName of Object.getOwnPropertyNames(el.attributes)) { |
725 assert_true(el.attributes[propName] instanceof Attr, | 708 assert_true(el.attributes[propName] instanceof Attr, |
726 "el.attributes has an Attr for property name " + propName); | 709 "el.attributes has an Attr for property name " + propName); |
727 } | 710 } |
728 }, "Own property names should include all qualified names for an HTML element in
a non-HTML document"); | 711 }, "Own property names should include all qualified names for an HTML element in
a non-HTML document"); |
729 </script> | 712 </script> |
OLD | NEW |