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 b
oolean 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 var AddEventListenerNoArguments = 656; | |
17 shouldBeFalse('internals.isUseCounted(document, AddEventListenerNoArguments)'); | |
18 shouldBe('document.addEventListener()', 'undefined'); | |
19 shouldBeTrue('internals.isUseCounted(document, AddEventListenerNoArguments)'); | |
20 var AddEventListenerOneArgument = 657; | |
21 shouldBeFalse('internals.isUseCounted(document, AddEventListenerOneArgument)'); | |
22 shouldBe('document.addEventListener("foo")', 'undefined'); | |
23 shouldBeTrue('internals.isUseCounted(document, AddEventListenerOneArgument)'); | |
24 shouldNotThrow('document.addEventListener("foo", listener)'); | 15 shouldNotThrow('document.addEventListener("foo", listener)'); |
25 shouldNotThrow('document.addEventListener("", listener)'); | 16 shouldNotThrow('document.addEventListener("", listener)'); |
26 shouldNotThrow('document.addEventListener("", function(){})'); | 17 shouldNotThrow('document.addEventListener("", function(){})'); |
27 shouldNotThrow('document.addEventListener("bar", listener, false)'); | 18 shouldNotThrow('document.addEventListener("bar", listener, false)'); |
28 shouldNotThrow('document.addEventListener("bar", listener, true)'); | 19 shouldNotThrow('document.addEventListener("bar", listener, true)'); |
29 // null | 20 // null |
30 shouldBe('document.addEventListener(null)', 'undefined'); | 21 shouldNotThrow('document.addEventListener(null, listener)'); |
31 shouldNotThrow('document.addEventListener(null, listener)'); // converted to "nu
ll" | 22 shouldNotThrow('document.addEventListener("foo", null)'); |
32 // FIXME: throw on |null|: http://crbug.com/249598 | |
33 // shouldThrow('document.addEventListener("foo", null)'); | |
34 shouldBe('document.addEventListener("foo", null)', 'undefined'); | |
35 shouldNotThrow('document.addEventListener("zork", listener, null)'); | 23 shouldNotThrow('document.addEventListener("zork", listener, null)'); |
36 // undefined | 24 // undefined |
37 // FIXME: behavior of undefined for mandatory arguments is unclear, but | 25 shouldNotThrow('document.addEventListener(undefined, listener)'); |
38 // probably should throw | 26 shouldNotThrow('document.addEventListener("foo", undefined)'); |
39 // https://www.w3.org/Bugs/Public/show_bug.cgi?id=23532 | |
40 shouldBe('document.addEventListener(undefined)', 'undefined'); | |
41 // shouldThrow('document.addEventListener(undefined, listener)'); | |
42 // shouldThrow('document.addEventListener("foo", undefined)'); | |
43 shouldBe('document.addEventListener(undefined, listener)', 'undefined'); | |
44 shouldBe('document.addEventListener("foo", undefined)', 'undefined'); | |
45 shouldNotThrow('document.addEventListener("zork", listener, undefined)'); | 27 shouldNotThrow('document.addEventListener("zork", listener, undefined)'); |
46 | 28 |
47 debug(''); | 29 debug(''); |
48 debug('Signature:'); | 30 debug('Signature:'); |
49 debug('void removeEventListener(DOMString type, EventListener listener, optional
boolean useCapture)'); | 31 debug('void removeEventListener(DOMString type, EventListener? listener, optiona
l boolean useCapture)'); |
50 // FIXME: should throw on missing arguments: http://crbug.com/353484 | 32 shouldThrow('document.removeEventListener()'); |
51 // shouldThrow('document.removeEventListener()'); | 33 shouldThrow('document.removeEventListener("foo")'); |
52 // shouldThrow('document.removeEventListener("foo")'); | |
53 var RemoveEventListenerNoArguments = 658; | |
54 shouldBeFalse('internals.isUseCounted(document, RemoveEventListenerNoArguments)'
); | |
55 shouldBe('document.removeEventListener()', 'undefined'); | |
56 shouldBeTrue('internals.isUseCounted(document, RemoveEventListenerNoArguments)')
; | |
57 var RemoveEventListenerOneArgument = 659; | |
58 shouldBeFalse('internals.isUseCounted(document, RemoveEventListenerOneArgument)'
); | |
59 shouldBe('document.removeEventListener("foo")', 'undefined'); | |
60 shouldBeTrue('internals.isUseCounted(document, RemoveEventListenerOneArgument)')
; | |
61 shouldNotThrow('document.removeEventListener("foo", listener)'); | 34 shouldNotThrow('document.removeEventListener("foo", listener)'); |
62 shouldNotThrow('document.removeEventListener("foo", listener, true)'); | 35 shouldNotThrow('document.removeEventListener("foo", listener, true)'); |
63 shouldNotThrow('document.removeEventListener("bar", listener, false)'); | 36 shouldNotThrow('document.removeEventListener("bar", listener, false)'); |
64 shouldNotThrow('document.removeEventListener("bar", listener, false)'); | 37 shouldNotThrow('document.removeEventListener("bar", listener, false)'); |
65 shouldNotThrow('document.removeEventListener("bar", listener, true)'); | 38 shouldNotThrow('document.removeEventListener("bar", listener, true)'); |
66 // null | 39 // null |
67 shouldBe('document.removeEventListener(null)', 'undefined'); | 40 shouldNotThrow('document.removeEventListener(null, listener)'); |
68 shouldNotThrow('document.removeEventListener(null, listener)'); // converted to
"null" | 41 shouldNotThrow('document.removeEventListener("foo", null)'); |
69 // FIXME: throw on |null|: http://crbug.com/249598 | |
70 // shouldThrow('document.removeEventListener("foo", null)'); | |
71 shouldBe('document.removeEventListener("foo", null)', 'undefined'); | |
72 shouldNotThrow('document.removeEventListener("zork", listener, null)'); | 42 shouldNotThrow('document.removeEventListener("zork", listener, null)'); |
73 // undefined | 43 // undefined |
74 // FIXME: behavior of undefined for mandatory arguments is unclear, but | 44 shouldNotThrow('document.removeEventListener(undefined, listener)'); |
75 // probably should throw | 45 shouldNotThrow('document.removeEventListener("foo", undefined)'); |
76 // https://www.w3.org/Bugs/Public/show_bug.cgi?id=23532 | |
77 shouldBe('document.removeEventListener(undefined)', 'undefined'); | |
78 // shouldthrow('document.removeeventlistener("foo", undefined)'); | |
79 // shouldthrow('document.removeeventlistener(undefined, listener)'); | |
80 shouldBe('document.removeEventListener(undefined, listener)', 'undefined'); | |
81 shouldBe('document.removeEventListener("foo", undefined)', 'undefined'); | |
82 shouldNotThrow('document.removeEventListener("zork", listener, undefined)'); | 46 shouldNotThrow('document.removeEventListener("zork", listener, undefined)'); |
83 </script> | 47 </script> |
OLD | NEW |