OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <title>GlobalEventHandlers test</title> | 2 <title>GlobalEventHandlers test</title> |
3 <script src="../../resources/testharness.js"></script> | 3 <script src="../../resources/testharness.js"></script> |
4 <script src="../../resources/testharnessreport.js"></script> | 4 <script src="../../resources/testharnessreport.js"></script> |
5 <script> | 5 <script> |
6 // attribute list from WHATWG HTML Living Standard r8212 | 6 // attribute list from WHATWG HTML Living Standard r8212 |
7 var attributes = [ | 7 var attributes = [ |
8 "onabort", | 8 "onabort", |
9 "onblur", | 9 "onblur", |
10 "onerror", | 10 "onerror", |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 var e = document.createElementNS("http://example.com/", "example"); | 71 var e = document.createElementNS("http://example.com/", "example"); |
72 assert_true(e instanceof Element); | 72 assert_true(e instanceof Element); |
73 assert_false(e instanceof HTMLElement); | 73 assert_false(e instanceof HTMLElement); |
74 assert_false(e instanceof SVGElement); | 74 assert_false(e instanceof SVGElement); |
75 return e; | 75 return e; |
76 case "HTMLElement": | 76 case "HTMLElement": |
77 var e = document.createElement("html"); | 77 var e = document.createElement("html"); |
78 assert_true(e instanceof HTMLElement); | 78 assert_true(e instanceof HTMLElement); |
79 return e; | 79 return e; |
80 case "SVGElement": | 80 case "SVGElement": |
81 var e = document.createElementNS("http://www.w3.org/2000/svg", "svg"
); | 81 var e = document.createElementNS("http://www.w3.org/2000/svg", "rect
"); |
82 assert_true(e instanceof SVGElement); | 82 assert_true(e instanceof SVGElement); |
83 return e; | 83 return e; |
84 case "Document": | 84 case "Document": |
85 assert_true(document instanceof Document); | 85 assert_true(document instanceof Document); |
86 return document; | 86 return document; |
87 case "Window": | 87 case "Window": |
88 assert_true(window instanceof Window); | 88 assert_true(window instanceof Window); |
89 return window; | 89 return window; |
90 } | 90 } |
91 assert_unreached(); | 91 assert_unreached(); |
92 } | 92 } |
93 function testSet(interface, attribute) { | 93 function testSet(interface, attribute) { |
94 test(function() { | 94 test(function() { |
95 var object = getObject(interface); | 95 var object = getObject(interface); |
96 function nop() {} | 96 function nop() {} |
97 assert_equals(object[attribute], null, "Initially null"); | 97 assert_equals(object[attribute], null, "Initially null"); |
98 object[attribute] = nop; | 98 object[attribute] = nop; |
99 assert_equals(object[attribute], nop, "Return same function"); | 99 assert_equals(object[attribute], nop, "Return same function"); |
100 document[attribute] = ""; | 100 document[attribute] = ""; |
101 assert_equals(document[attribute], null, "Return null after setting stri
ng"); | 101 assert_equals(document[attribute], null, "Return null after setting stri
ng"); |
102 }, "Set " + interface + "." + attribute); | 102 }, "Set " + interface + "." + attribute); |
103 } | 103 } |
104 function testReflect(interface, attribute) { | 104 function testReflect(interface, attribute) { |
105 test(function() { | 105 test(function() { |
106 var element = getObject(interface); | 106 var element = getObject(interface); |
107 assert_equals(element.getAttribute(attribute), null, "Initially null"); | 107 assert_equals(element.getAttribute(attribute), null, "Initially null"); |
108 element.setAttribute(attribute, "return"); | 108 element.setAttribute(attribute, "return"); |
109 assert_equals(element.getAttribute(attribute), "return", "Return same st
ring"); | 109 assert_equals(element.getAttribute(attribute), "return", "Return same st
ring"); |
110 assert_equals(typeof element[attribute], "function", "Convert to functio
n"); | 110 assert_equals(typeof element[attribute], "function", "Convert to functio
n"); |
111 }, "Reflect " + interface + "." + attribute); | 111 }, "Reflect " + interface + "." + attribute); |
112 } | 112 } |
113 // Object.propertyIsEnumerable cannot be used because it doesn't | 113 // Object.propertyIsEnumerable cannot be used because it doesn't |
114 // work with properties inherited through the prototype chain. | 114 // work with properties inherited through the prototype chain. |
115 var enumerable = { | 115 var enumerable = { |
(...skipping 13 matching lines...) Expand all Loading... |
129 assert_true(enumerable[interface][attribute]); | 129 assert_true(enumerable[interface][attribute]); |
130 }, "Enumerate " + interface + "." + attribute); | 130 }, "Enumerate " + interface + "." + attribute); |
131 } | 131 } |
132 attributes.forEach(function(attribute) { | 132 attributes.forEach(function(attribute) { |
133 test(function() { | 133 test(function() { |
134 assert_false(attribute in getObject("Element")); | 134 assert_false(attribute in getObject("Element")); |
135 }, "No Element." + attribute); | 135 }, "No Element." + attribute); |
136 testSet("HTMLElement", attribute); | 136 testSet("HTMLElement", attribute); |
137 testEnumerate("HTMLElement", attribute); | 137 testEnumerate("HTMLElement", attribute); |
138 testReflect("HTMLElement", attribute); | 138 testReflect("HTMLElement", attribute); |
| 139 testSet("SVGElement", attribute); |
| 140 testEnumerate("SVGElement", attribute); |
| 141 testReflect("SVGElement", attribute); |
139 testSet("Document", attribute); | 142 testSet("Document", attribute); |
140 testEnumerate("Document", attribute); | 143 testEnumerate("Document", attribute); |
141 testSet("Window", attribute); | 144 testSet("Window", attribute); |
142 testEnumerate("Window", attribute); | 145 testEnumerate("Window", attribute); |
143 }); | 146 }); |
144 </script> | 147 </script> |
145 <div id="log"></div> | 148 <div id="log"></div> |
OLD | NEW |