@@ -56,6 +56,21 @@ let asyncTest = Promise.resolve();
5656ev . preventDefault ( ) ;
5757strictEqual ( ev . defaultPrevented , false ) ;
5858}
59+ {
60+ [
61+ 'foo' ,
62+ 1 ,
63+ false ,
64+ function ( ) { } ,
65+ ] . forEach ( ( i ) => (
66+ throws ( ( ) => new Event ( 'foo' , i ) , {
67+ code : 'ERR_INVALID_ARG_TYPE' ,
68+ name : 'TypeError' ,
69+ message : 'The "options" argument must be of type object.' +
70+ common . invalidArgTypeHelper ( i )
71+ } )
72+ ) ) ;
73+ }
5974{
6075const ev = new Event ( 'foo' ) ;
6176strictEqual ( ev . cancelBubble , false ) ;
@@ -221,31 +236,33 @@ let asyncTest = Promise.resolve();
221236false
222237] . forEach ( ( i ) => {
223238throws ( ( ) => target . dispatchEvent ( i ) , {
224- code : 'ERR_INVALID_ARG_TYPE'
239+ code : 'ERR_INVALID_ARG_TYPE' ,
240+ name : 'TypeError' ,
241+ message : 'The "event" argument must be an instance of Event.' +
242+ common . invalidArgTypeHelper ( i )
225243} ) ;
226244} ) ;
227245
246+ const err = ( arg ) => ( {
247+ code : 'ERR_INVALID_ARG_TYPE' ,
248+ name : 'TypeError' ,
249+ message : 'The "listener" argument must be an instance of EventListener.' +
250+ common . invalidArgTypeHelper ( arg )
251+ } ) ;
252+
228253[
229254'foo' ,
2302551 ,
231256{ } , // No handleEvent function
232- false ,
233- ] . forEach ( ( i ) => {
234- throws ( ( ) => target . addEventListener ( 'foo' , i ) , {
235- code : 'ERR_INVALID_ARG_TYPE'
236- } ) ;
237- } ) ;
257+ false
258+ ] . forEach ( ( i ) => throws ( ( ) => target . addEventListener ( 'foo' , i ) , err ( i ) ) ) ;
238259
239260[
240261'foo' ,
2412621 ,
242263{ } , // No handleEvent function
243264false
244- ] . forEach ( ( i ) => {
245- throws ( ( ) => target . removeEventListener ( 'foo' , i ) , {
246- code : 'ERR_INVALID_ARG_TYPE'
247- } ) ;
248- } ) ;
265+ ] . forEach ( ( i ) => throws ( ( ) => target . addEventListener ( 'foo' , i ) , err ( i ) ) ) ;
249266}
250267
251268{
0 commit comments