| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <script src="../../resources/js-test.js"></script> | 2 <script src="../../resources/js-test.js"></script> |
| 3 <body> | 3 <body> |
| 4 <script> | 4 <script> |
| 5 description('EventTarget.addEventListener and EventTarget.removeEventLister shou
ld throw on invalid arguments.'); | 5 description('EventTarget.addEventListener and EventTarget.removeEventLister shou
ld throw on invalid arguments.'); |
| 6 | 6 |
| 7 function listener(event) | 7 function listener(event) |
| 8 { | 8 { |
| 9 } | 9 } |
| 10 | 10 |
| 11 debug('Signature:') | 11 debug('Signature:') |
| 12 debug('void addEventListener(DOMString type, EventListener listener, optional bo
olean useCapture)'); | 12 debug('void addEventListener(DOMString type, EventListener listener, optional bo
olean useCapture)'); |
| 13 // FIXME: should throw on missing arguments: http://crbug.com/353484 | 13 shouldThrow('document.addEventListener()'); |
| 14 // shouldThrow('document.addEventListener()'); | 14 shouldThrow('document.addEventListener("foo")'); |
| 15 // shouldThrow('document.addEventListener("foo")'); | |
| 16 shouldBe('document.addEventListener()', 'undefined'); | |
| 17 shouldBe('document.addEventListener("foo")', 'undefined'); | |
| 18 shouldNotThrow('document.addEventListener("foo", listener)'); | 15 shouldNotThrow('document.addEventListener("foo", listener)'); |
| 19 shouldNotThrow('document.addEventListener("", listener)'); | 16 shouldNotThrow('document.addEventListener("", listener)'); |
| 20 shouldNotThrow('document.addEventListener("", function(){})'); | 17 shouldNotThrow('document.addEventListener("", function(){})'); |
| 21 shouldNotThrow('document.addEventListener("bar", listener, false)'); | 18 shouldNotThrow('document.addEventListener("bar", listener, false)'); |
| 22 shouldNotThrow('document.addEventListener("bar", listener, true)'); | 19 shouldNotThrow('document.addEventListener("bar", listener, true)'); |
| 23 // null | 20 // null |
| 24 shouldBe('document.addEventListener(null)', 'undefined'); | 21 shouldThrow('document.addEventListener(null)'); |
| 25 shouldNotThrow('document.addEventListener(null, listener)'); // converted to "nu
ll" | 22 shouldNotThrow('document.addEventListener(null, listener)'); // converted to "nu
ll" |
| 26 // FIXME: throw on |null|: http://crbug.com/249598 | |
| 27 // shouldThrow('document.addEventListener("foo", null)'); | |
| 28 shouldBe('document.addEventListener("foo", null)', 'undefined'); | 23 shouldBe('document.addEventListener("foo", null)', 'undefined'); |
| 29 shouldNotThrow('document.addEventListener("zork", listener, null)'); | 24 shouldNotThrow('document.addEventListener("zork", listener, null)'); |
| 30 // undefined | 25 // undefined |
| 26 shouldThrow('document.addEventListener(undefined)'); |
| 31 // FIXME: behavior of undefined for mandatory arguments is unclear, but | 27 // FIXME: behavior of undefined for mandatory arguments is unclear, but |
| 32 // probably should throw | 28 // probably should throw |
| 33 // https://www.w3.org/Bugs/Public/show_bug.cgi?id=23532 | 29 // https://www.w3.org/Bugs/Public/show_bug.cgi?id=23532 |
| 34 shouldBe('document.addEventListener(undefined)', 'undefined'); | 30 // As of 2014 June, IE and Firefox do not throw here, however: |
| 31 // http://lists.w3.org/Archives/Public/public-script-coord/2014AprJun/0166.html |
| 35 // shouldThrow('document.addEventListener(undefined, listener)'); | 32 // shouldThrow('document.addEventListener(undefined, listener)'); |
| 36 // shouldThrow('document.addEventListener("foo", undefined)'); | 33 // shouldThrow('document.addEventListener("foo", undefined)'); |
| 37 shouldBe('document.addEventListener(undefined, listener)', 'undefined'); | 34 shouldBe('document.addEventListener(undefined, listener)', 'undefined'); |
| 38 shouldBe('document.addEventListener("foo", undefined)', 'undefined'); | 35 shouldBe('document.addEventListener("foo", undefined)', 'undefined'); |
| 39 shouldNotThrow('document.addEventListener("zork", listener, undefined)'); | 36 shouldNotThrow('document.addEventListener("zork", listener, undefined)'); |
| 40 | 37 |
| 41 debug(''); | 38 debug(''); |
| 42 debug('Signature:'); | 39 debug('Signature:'); |
| 43 debug('void removeEventListener(DOMString type, EventListener listener, optional
boolean useCapture)'); | 40 debug('void removeEventListener(DOMString type, EventListener listener, optional
boolean useCapture)'); |
| 44 // FIXME: should throw on missing arguments: http://crbug.com/353484 | 41 shouldThrow('document.removeEventListener()'); |
| 45 // shouldThrow('document.removeEventListener()'); | 42 shouldThrow('document.removeEventListener("foo")'); |
| 46 // shouldThrow('document.removeEventListener("foo")'); | |
| 47 shouldBe('document.removeEventListener()', 'undefined'); | |
| 48 shouldBe('document.removeEventListener("foo")', 'undefined'); | |
| 49 shouldNotThrow('document.removeEventListener("foo", listener)'); | 43 shouldNotThrow('document.removeEventListener("foo", listener)'); |
| 50 shouldNotThrow('document.removeEventListener("foo", listener, true)'); | 44 shouldNotThrow('document.removeEventListener("foo", listener, true)'); |
| 51 shouldNotThrow('document.removeEventListener("bar", listener, false)'); | 45 shouldNotThrow('document.removeEventListener("bar", listener, false)'); |
| 52 shouldNotThrow('document.removeEventListener("bar", listener, false)'); | 46 shouldNotThrow('document.removeEventListener("bar", listener, false)'); |
| 53 shouldNotThrow('document.removeEventListener("bar", listener, true)'); | 47 shouldNotThrow('document.removeEventListener("bar", listener, true)'); |
| 54 // null | 48 // null |
| 55 shouldBe('document.removeEventListener(null)', 'undefined'); | 49 shouldThrow('document.removeEventListener(null)'); |
| 56 shouldNotThrow('document.removeEventListener(null, listener)'); // converted to
"null" | 50 shouldNotThrow('document.removeEventListener(null, listener)'); // converted to
"null" |
| 57 // FIXME: throw on |null|: http://crbug.com/249598 | |
| 58 // shouldThrow('document.removeEventListener("foo", null)'); | |
| 59 shouldBe('document.removeEventListener("foo", null)', 'undefined'); | 51 shouldBe('document.removeEventListener("foo", null)', 'undefined'); |
| 60 shouldNotThrow('document.removeEventListener("zork", listener, null)'); | 52 shouldNotThrow('document.removeEventListener("zork", listener, null)'); |
| 61 // undefined | 53 // undefined |
| 54 shouldThrow('document.removeEventListener(undefined)'); |
| 62 // FIXME: behavior of undefined for mandatory arguments is unclear, but | 55 // FIXME: behavior of undefined for mandatory arguments is unclear, but |
| 63 // probably should throw | 56 // probably should throw |
| 64 // https://www.w3.org/Bugs/Public/show_bug.cgi?id=23532 | 57 // https://www.w3.org/Bugs/Public/show_bug.cgi?id=23532 |
| 65 shouldBe('document.removeEventListener(undefined)', 'undefined'); | 58 // As of 2014 June, IE and Firefox do not throw here, however: |
| 59 // http://lists.w3.org/Archives/Public/public-script-coord/2014AprJun/0166.html |
| 66 // shouldthrow('document.removeeventlistener("foo", undefined)'); | 60 // shouldthrow('document.removeeventlistener("foo", undefined)'); |
| 67 // shouldthrow('document.removeeventlistener(undefined, listener)'); | 61 // shouldthrow('document.removeeventlistener(undefined, listener)'); |
| 68 shouldBe('document.removeEventListener(undefined, listener)', 'undefined'); | 62 shouldBe('document.removeEventListener(undefined, listener)', 'undefined'); |
| 69 shouldBe('document.removeEventListener("foo", undefined)', 'undefined'); | 63 shouldBe('document.removeEventListener("foo", undefined)', 'undefined'); |
| 70 shouldNotThrow('document.removeEventListener("zork", listener, undefined)'); | 64 shouldNotThrow('document.removeEventListener("zork", listener, undefined)'); |
| 71 </script> | 65 </script> |
| OLD | NEW |