OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <title>GlobalEventHandlers test</title> |
| 3 <script src="../../resources/testharness.js"></script> |
| 4 <script src="../../resources/testharnessreport.js"></script> |
| 5 <script> |
| 6 // attribute list from WHATWG HTML Living Standard r8212 |
| 7 var attributes = [ |
| 8 "onabort", |
| 9 "onblur", |
| 10 "onerror", |
| 11 "onfocus", |
| 12 "oncancel", |
| 13 "oncanplay", |
| 14 "oncanplaythrough", |
| 15 "onchange", |
| 16 "onclick", |
| 17 "onclose", |
| 18 "oncontextmenu", |
| 19 "oncuechange", |
| 20 "ondblclick", |
| 21 "ondrag", |
| 22 "ondragend", |
| 23 "ondragenter", |
| 24 "ondragexit", |
| 25 "ondragleave", |
| 26 "ondragover", |
| 27 "ondragstart", |
| 28 "ondrop", |
| 29 "ondurationchange", |
| 30 "onemptied", |
| 31 "onended", |
| 32 "oninput", |
| 33 "oninvalid", |
| 34 "onkeydown", |
| 35 "onkeypress", |
| 36 "onkeyup", |
| 37 "onload", |
| 38 "onloadeddata", |
| 39 "onloadedmetadata", |
| 40 "onloadstart", |
| 41 "onmousedown", |
| 42 "onmouseenter", |
| 43 "onmouseleave", |
| 44 "onmousemove", |
| 45 "onmouseout", |
| 46 "onmouseover", |
| 47 "onmouseup", |
| 48 "onmousewheel", |
| 49 "onpause", |
| 50 "onplay", |
| 51 "onplaying", |
| 52 "onprogress", |
| 53 "onratechange", |
| 54 "onreset", |
| 55 "onscroll", |
| 56 "onseeked", |
| 57 "onseeking", |
| 58 "onselect", |
| 59 "onshow", |
| 60 "onsort", |
| 61 "onstalled", |
| 62 "onsubmit", |
| 63 "onsuspend", |
| 64 "ontimeupdate", |
| 65 "onvolumechange", |
| 66 "onwaiting" |
| 67 ]; |
| 68 function testSet(object, attribute, name) { |
| 69 function nop() {} |
| 70 test(function() { |
| 71 assert_equals(object[attribute], null, "Initially null"); |
| 72 object[attribute] = nop; |
| 73 assert_equals(object[attribute], nop, "Return same function"); |
| 74 document[attribute] = ""; |
| 75 assert_equals(document[attribute], null, "Return null after setting stri
ng"); |
| 76 }, "Set " + name + "." + attribute); |
| 77 } |
| 78 function testEnumerate(object, name) { |
| 79 // Object.propertyIsEnumerable cannot be used because it doesn't |
| 80 // work with properties inherited through the prototype chain. |
| 81 test(function() { |
| 82 var seen = {}; |
| 83 attributes.forEach(function(attribute) { |
| 84 seen[attribute] = false; |
| 85 }); |
| 86 for (var attribute in object) { |
| 87 seen[attribute] = true; |
| 88 } |
| 89 attributes.forEach(function(attribute) { |
| 90 assert_true(seen[attribute], "Found " + attribute); |
| 91 }); |
| 92 }, "Enumerate " + name + ".on*"); |
| 93 } |
| 94 attributes.forEach(function(attribute) { |
| 95 testSet(document.createElement('div'), attribute, "element"); |
| 96 test(function() { |
| 97 var element = document.createElement('div'); |
| 98 assert_equals(element.getAttribute(attribute), null, "Initially null"); |
| 99 element.setAttribute(attribute, "return"); |
| 100 assert_equals(element.getAttribute(attribute), "return", "Return same st
ring"); |
| 101 assert_equals(typeof element[attribute], "function", "Convert to functio
n"); |
| 102 }, "Reflect element." + attribute); |
| 103 testSet(document, attribute, "document"); |
| 104 testSet(window, attribute, "window"); |
| 105 }); |
| 106 testEnumerate(document.createElement('div'), "element"); |
| 107 testEnumerate(document, "document"); |
| 108 testEnumerate(window, "window"); |
| 109 </script> |
| 110 <div id="log"></div> |
OLD | NEW |