Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(16)

Side by Side Diff: LayoutTests/fast/dom/Window/get-set-properties.html

Issue 22687002: Treat non-callable input as null for EventHandler attributes (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fix nit Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | LayoutTests/fast/dom/Window/get-set-properties-expected.txt » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 <p>This page tests getting and setting window properties and functions.</p> 1 <p>This page tests getting and setting window properties and functions.</p>
2 <pre id="console"></pre> 2 <pre id="console"></pre>
3 3
4 <script> 4 <script>
5 function log(s) 5 function log(s)
6 { 6 {
7 document.getElementById("console").appendChild(document.createTextNode(s + " \n")); 7 document.getElementById("console").appendChild(document.createTextNode(s + " \n"));
8 } 8 }
9 9
10 function shouldBe(a, b) 10 function shouldBe(a, b)
(...skipping 25 matching lines...) Expand all
36 function canGet(keyPath) 36 function canGet(keyPath)
37 { 37 {
38 try { 38 try {
39 return eval("window." + keyPath) !== undefined; 39 return eval("window." + keyPath) !== undefined;
40 } catch(e) { 40 } catch(e) {
41 return false; 41 return false;
42 } 42 }
43 } 43 }
44 44
45 window.marker = { "foo": "bar", toString: function(){ return "window.marker.toSt ring()"; } }; 45 window.marker = { "foo": "bar", toString: function(){ return "window.marker.toSt ring()"; } };
46 window.callableMarker = function() { return "window.callableMarker.toString()"; };
46 47
47 function canSet(keyPath) 48 function canSet(keyPath)
48 { 49 {
49 var valuePath = "window.marker"; 50 var valuePath = "window.marker";
50 51
51 try { 52 try {
52 eval("window." + keyPath + " = " + valuePath); 53 eval("window." + keyPath + " = " + valuePath);
53 return eval("window." + keyPath) === eval("window." + valuePath); 54 return eval("window." + keyPath) === eval("window." + valuePath);
54 } catch(e) { 55 } catch(e) {
55 return false; 56 return false;
56 } 57 }
57 } 58 }
58 59
59 function canSetWithTypeConversion(keyPath) 60 function canSetWithTypeConversion(keyPath)
60 { 61 {
61 var valuePath = "window.marker"; 62 var valuePath = "window.marker";
62 63
63 try { 64 try {
64 eval("window." + keyPath + " = " + valuePath); 65 eval("window." + keyPath + " = " + valuePath);
65 return eval("window." + keyPath) == eval("window." + valuePath); 66 return eval("window." + keyPath) == eval("window." + valuePath);
66 } catch(e) { 67 } catch(e) {
67 return false; 68 return false;
68 } 69 }
69 } 70 }
70 71
72 function canSetWithCallable(keyPath)
73 {
74 var valuePath = "window.callableMarker";
75
76 try {
77 eval("window." + keyPath + " = " + valuePath);
78 return eval("window." + keyPath) === eval("window." + valuePath);
79 } catch(e) {
80 return false;
81 }
82 }
83
71 var windowReadWriteProperties = [ 84 var windowReadWriteProperties = [
72 "Attr", 85 "Attr",
73 "CDATASection", 86 "CDATASection",
74 "CSSPrimitiveValue", 87 "CSSPrimitiveValue",
75 "CSSRule", 88 "CSSRule",
76 "CSSStyleDeclaration", 89 "CSSStyleDeclaration",
77 "CSSValue", 90 "CSSValue",
78 "CharacterData", 91 "CharacterData",
79 "Comment", 92 "Comment",
80 "DOMException", 93 "DOMException",
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 "blur", 231 "blur",
219 "close", 232 "close",
220 "confirm", 233 "confirm",
221 "find", 234 "find",
222 "focus", 235 "focus",
223 "getComputedStyle", 236 "getComputedStyle",
224 "getMatchedCSSRules", 237 "getMatchedCSSRules",
225 "getSelection", 238 "getSelection",
226 "moveBy", 239 "moveBy",
227 "moveTo", 240 "moveTo",
241 "open",
242 "print",
243 "prompt",
244 "releaseEvents",
245 "removeEventListener",
246 "resizeBy",
247 "resizeTo",
248 "scroll",
249 "scrollBy",
250 "scrollTo",
251 "setInterval",
252 "setTimeout",
253 "stop"
254 ];
255
256 var windowEventHandlers = [
228 "onabort", 257 "onabort",
229 "onbeforeunload", 258 "onbeforeunload",
230 "onblur", 259 "onblur",
231 "onchange", 260 "onchange",
232 "onclick", 261 "onclick",
233 "ondblclick", 262 "ondblclick",
234 "onerror", 263 "onerror",
235 "onfocus", 264 "onfocus",
236 "onkeydown", 265 "onkeydown",
237 "onkeypress", 266 "onkeypress",
238 "onkeyup", 267 "onkeyup",
239 "onload", 268 "onload",
240 "onmousedown", 269 "onmousedown",
241 "onmousemove", 270 "onmousemove",
242 "onmouseout", 271 "onmouseout",
243 "onmouseover", 272 "onmouseover",
244 "onmouseup", 273 "onmouseup",
245 "onmousewheel", 274 "onmousewheel",
246 "onreset", 275 "onreset",
247 "onresize", 276 "onresize",
248 "onscroll", 277 "onscroll",
249 "onsearch", 278 "onsearch",
250 "onselect", 279 "onselect",
251 "onsubmit", 280 "onsubmit",
252 "onunload", 281 "onunload"
253 "open",
254 "print",
255 "prompt",
256 "releaseEvents",
257 "removeEventListener",
258 "resizeBy",
259 "resizeTo",
260 "scroll",
261 "scrollBy",
262 "scrollTo",
263 "setInterval",
264 "setTimeout",
265 "stop"
266 ]; 282 ];
267 283
268 window.onload = function() 284 window.onload = function()
269 { 285 {
270 if (window.testRunner) 286 if (window.testRunner)
271 testRunner.dumpAsText(); 287 testRunner.dumpAsText();
272 288
273 log("\n----- tests for getting/setting read-write properties -----\n"); 289 log("\n----- tests for getting/setting read-write properties -----\n");
274 290
275 for (var i = 0; i < windowReadWriteProperties.length; i++) { //> 291 for (var i = 0; i < windowReadWriteProperties.length; i++) {
276 var property = windowReadWriteProperties[i]; 292 var property = windowReadWriteProperties[i];
277 shouldBeTrue("canGet('" + property + "')"); 293 shouldBeTrue("canGet('" + property + "')");
278 shouldBeTrue("canSet('" + property + "')"); 294 shouldBeTrue("canSet('" + property + "')");
279 } 295 }
280 296
281 log("\n----- tests for getting/setting readonly properties -----\n"); 297 log("\n----- tests for getting/setting readonly properties -----\n");
282 298
283 for (var i = 0; i < windowReadOnlyProperties.length; i++) { //> 299 for (var i = 0; i < windowReadOnlyProperties.length; i++) {
284 var property = windowReadOnlyProperties[i]; 300 var property = windowReadOnlyProperties[i];
285 shouldBeTrue("canGet('" + property + "')"); 301 shouldBeTrue("canGet('" + property + "')");
286 shouldBeFalse("canSet('" + property + "')"); 302 shouldBeFalse("canSet('" + property + "')");
287 } 303 }
288 304
289 log("\n----- tests for getting/setting string properties -----\n"); 305 log("\n----- tests for getting/setting string properties -----\n");
290 for (var i = 0; i < windowReadWriteStringProperties.length; i++) { //> 306 for (var i = 0; i < windowReadWriteStringProperties.length; i++) {
291 var property = windowReadWriteStringProperties[i]; 307 var property = windowReadWriteStringProperties[i];
292 shouldBeTrue("canGet('" + property + "')"); 308 shouldBeTrue("canGet('" + property + "')");
293 shouldBeTrue("canSetWithTypeConversion('" + property + "')"); 309 shouldBeTrue("canSetWithTypeConversion('" + property + "')");
294 310
295 } 311 }
296 312
297 log("\n----- tests for getting/setting functions -----\n"); 313 log("\n----- tests for getting/setting functions -----\n");
298 314
299 for (var i = 0; i < windowFunctions.length; i++) { //> 315 for (var i = 0; i < windowFunctions.length; i++) {
300 var property = windowFunctions[i]; 316 var property = windowFunctions[i];
301 shouldBeTrue("canGet('" + property + "')"); 317 shouldBeTrue("canGet('" + property + "')");
302 shouldBeTrue("canSet('" + property + "')"); 318 shouldBeTrue("canSet('" + property + "')");
303 } 319 }
320
321 log("\n----- tests for getting/setting event handlers -----\n");
322
323 for (var i = 0; i < windowEventHandlers.length; i++) {
324 var property = windowEventHandlers[i];
325 shouldBeTrue("canGet('" + property + "')");
326 shouldBeTrue("canSetWithCallable('" + property + "')");
327 }
304 } 328 }
305 </script> 329 </script>
OLDNEW
« no previous file with comments | « no previous file | LayoutTests/fast/dom/Window/get-set-properties-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698