OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <meta charset=utf-8> |
| 3 <title>Document.createEvent</title> |
| 4 <link rel=help href="https://dom.spec.whatwg.org/#dom-document-createevent"> |
| 5 <script src="../../../../resources/testharness.js"></script> |
| 6 <script src="../../../../resources/testharnessreport.js"></script> |
| 7 <script src="Document-createEvent.js"></script> |
| 8 <div id="log"></div> |
| 9 <script> |
| 10 function testAlias(arg, iface) { |
| 11 var ev; |
| 12 test(function() { |
| 13 ev = document.createEvent(arg); |
| 14 assert_true(ev instanceof window[iface]); |
| 15 assert_true(ev instanceof Event); |
| 16 }, arg + " should be an alias for " + iface + "."); |
| 17 test(function() { |
| 18 assert_equals(ev.type, "", |
| 19 "type should be initialized to the empty string"); |
| 20 assert_equals(ev.target, null, |
| 21 "target should be initialized to null"); |
| 22 assert_equals(ev.currentTarget, null, |
| 23 "currentTarget should be initialized to null"); |
| 24 assert_equals(ev.eventPhase, 0, |
| 25 "eventPhase should be initialized to NONE (0)"); |
| 26 assert_equals(ev.bubbles, false, |
| 27 "bubbles should be initialized to false"); |
| 28 assert_equals(ev.cancelable, false, |
| 29 "cancelable should be initialized to false"); |
| 30 assert_equals(ev.defaultPrevented, false, |
| 31 "defaultPrevented should be initialized to false"); |
| 32 assert_equals(ev.isTrusted, false, |
| 33 "isTrusted should be initialized to false"); |
| 34 }, "createEvent('" + arg + "') should be initialized correctly."); |
| 35 } |
| 36 aliases.forEach(function(alias) { |
| 37 testAlias(alias[0], alias[1]); |
| 38 testAlias(alias[0].toLowerCase(), alias[1]); |
| 39 testAlias(alias[0].toUpperCase(), alias[1]); |
| 40 }); |
| 41 |
| 42 test(function() { |
| 43 assert_throws("NOT_SUPPORTED_ERR", function() { |
| 44 var evt = document.createEvent("foo"); |
| 45 }); |
| 46 assert_throws("NOT_SUPPORTED_ERR", function() { |
| 47 // 'LATIN CAPITAL LETTER I WITH DOT ABOVE' (U+0130) |
| 48 var evt = document.createEvent("U\u0130Event"); |
| 49 }); |
| 50 assert_throws("NOT_SUPPORTED_ERR", function() { |
| 51 // 'LATIN SMALL LETTER DOTLESS I' (U+0131) |
| 52 var evt = document.createEvent("U\u0131Event"); |
| 53 }); |
| 54 }, "Should throw NOT_SUPPORTED_ERR for unrecognized arguments"); |
| 55 </script> |
OLD | NEW |