{"ScriptPreparationCode":"const input1 = document.getElementById(\u0027input1\u0027);\r\nconst input2 = document.getElementById(\u0027input2\u0027);\r\nconst input3 = document.getElementById(\u0027input3\u0027);\r\nconst input4 = document.getElementById(\u0027input4\u0027);\r\nconst input5 = document.getElementById(\u0027input5\u0027);\r\nconst input6 = document.getElementById(\u0027input6\u0027);\r\nconst input7 = document.getElementById(\u0027input7\u0027);\r\nconst input8 = document.getElementById(\u0027input8\u0027);\r\nconst input9 = document.getElementById(\u0027input9\u0027);\r\nconst input10 = document.getElementById(\u0027input10\u0027);","TestCases":[{"Name":"Single window handler","Code":"\r\nconst onKeyDown = (e) =\u003E console.log({e});\r\nconst handlers = new Map();\r\nconst multiListener = (e) =\u003E {\r\n if (handlers.has(e.target)) {\r\n handlers.get(e.target)(e)\r\n }\r\n}\r\n\r\nwindow.addEventListener(\u0027keydown\u0027, multiListener, false);\r\n\r\nhandlers.set(input1, onKeyDown);\r\nhandlers.set(input2, onKeyDown);\r\nhandlers.set(input3, onKeyDown);\r\nhandlers.set(input4, onKeyDown);\r\nhandlers.set(input5, onKeyDown);\r\nhandlers.set(input6, onKeyDown);\r\nhandlers.set(input7, onKeyDown);\r\nhandlers.set(input8, onKeyDown);\r\nhandlers.set(input9, onKeyDown);\r\nhandlers.set(input10, onKeyDown);\r\n\r\nfor(var i=0; i\u003C100; i\u002B\u002B){\r\n input1.dispatchEvent(new Event(\u0027focus\u0027));\r\n input1.dispatchEvent(new KeyboardEvent(\u0027keydown\u0027,{\u0027key\u0027:\u0027a\u0027}));\r\n input2.dispatchEvent(new Event(\u0027focus\u0027));\r\n input2.dispatchEvent(new KeyboardEvent(\u0027keydown\u0027,{\u0027key\u0027:\u0027a\u0027}));\r\n input3.dispatchEvent(new Event(\u0027focus\u0027));\r\n input3.dispatchEvent(new KeyboardEvent(\u0027keydown\u0027,{\u0027key\u0027:\u0027a\u0027}));\r\n input4.dispatchEvent(new Event(\u0027focus\u0027));\r\n input4.dispatchEvent(new KeyboardEvent(\u0027keydown\u0027,{\u0027key\u0027:\u0027a\u0027}));\r\n input5.dispatchEvent(new Event(\u0027focus\u0027));\r\n input5.dispatchEvent(new KeyboardEvent(\u0027keydown\u0027,{\u0027key\u0027:\u0027a\u0027}));\r\n input6.dispatchEvent(new Event(\u0027focus\u0027));\r\n input6.dispatchEvent(new KeyboardEvent(\u0027keydown\u0027,{\u0027key\u0027:\u0027a\u0027}));\r\n input7.dispatchEvent(new Event(\u0027focus\u0027));\r\n input7.dispatchEvent(new KeyboardEvent(\u0027keydown\u0027,{\u0027key\u0027:\u0027a\u0027}));\r\n input8.dispatchEvent(new Event(\u0027focus\u0027));\r\n input8.dispatchEvent(new KeyboardEvent(\u0027keydown\u0027,{\u0027key\u0027:\u0027a\u0027}));\r\n input9.dispatchEvent(new Event(\u0027focus\u0027));\r\n input9.dispatchEvent(new KeyboardEvent(\u0027keydown\u0027,{\u0027key\u0027:\u0027a\u0027}));\r\n input10.dispatchEvent(new Event(\u0027focus\u0027));\r\n input10.dispatchEvent(new KeyboardEvent(\u0027keydown\u0027,{\u0027key\u0027:\u0027a\u0027}));\r\n}\r\n","IsDeferred":false},{"Name":"Multiple input handlers","Code":"\r\nconst onKeyDown = (e) =\u003E console.log({e});\r\ninput1.addEventListener(\u0027keydown\u0027, onKeyDown, false);\r\ninput2.addEventListener(\u0027keydown\u0027, onKeyDown, false);\r\ninput3.addEventListener(\u0027keydown\u0027, onKeyDown, false);\r\ninput4.addEventListener(\u0027keydown\u0027, onKeyDown, false);\r\ninput5.addEventListener(\u0027keydown\u0027, onKeyDown, false);\r\ninput6.addEventListener(\u0027keydown\u0027, onKeyDown, false);\r\ninput7.addEventListener(\u0027keydown\u0027, onKeyDown, false);\r\ninput8.addEventListener(\u0027keydown\u0027, onKeyDown, false);\r\ninput9.addEventListener(\u0027keydown\u0027, onKeyDown, false);\r\ninput10.addEventListener(\u0027keydown\u0027, onKeyDown, false);\r\n\r\nfor(var i=0; i\u003C100; i\u002B\u002B){\r\n input1.dispatchEvent(new Event(\u0027focus\u0027));\r\n input1.dispatchEvent(new KeyboardEvent(\u0027keydown\u0027,{\u0027key\u0027:\u0027a\u0027}));\r\n input2.dispatchEvent(new Event(\u0027focus\u0027));\r\n input2.dispatchEvent(new KeyboardEvent(\u0027keydown\u0027,{\u0027key\u0027:\u0027a\u0027}));\r\n input3.dispatchEvent(new Event(\u0027focus\u0027));\r\n input3.dispatchEvent(new KeyboardEvent(\u0027keydown\u0027,{\u0027key\u0027:\u0027a\u0027}));\r\n input4.dispatchEvent(new Event(\u0027focus\u0027));\r\n input4.dispatchEvent(new KeyboardEvent(\u0027keydown\u0027,{\u0027key\u0027:\u0027a\u0027}));\r\n input5.dispatchEvent(new Event(\u0027focus\u0027));\r\n input5.dispatchEvent(new KeyboardEvent(\u0027keydown\u0027,{\u0027key\u0027:\u0027a\u0027}));\r\n input6.dispatchEvent(new Event(\u0027focus\u0027));\r\n input6.dispatchEvent(new KeyboardEvent(\u0027keydown\u0027,{\u0027key\u0027:\u0027a\u0027}));\r\n input7.dispatchEvent(new Event(\u0027focus\u0027));\r\n input7.dispatchEvent(new KeyboardEvent(\u0027keydown\u0027,{\u0027key\u0027:\u0027a\u0027}));\r\n input8.dispatchEvent(new Event(\u0027focus\u0027));\r\n input8.dispatchEvent(new KeyboardEvent(\u0027keydown\u0027,{\u0027key\u0027:\u0027a\u0027}));\r\n input9.dispatchEvent(new Event(\u0027focus\u0027));\r\n input9.dispatchEvent(new KeyboardEvent(\u0027keydown\u0027,{\u0027key\u0027:\u0027a\u0027}));\r\n input10.dispatchEvent(new Event(\u0027focus\u0027));\r\n input10.dispatchEvent(new KeyboardEvent(\u0027keydown\u0027,{\u0027key\u0027:\u0027a\u0027}));\r\n}\r\n","IsDeferred":false}]}