I have a test web page that warns me if I press a key in the input field:
<!doctype html> <html> <head> <script type="text/javascript" src="jquery-1.9.1.min.js"></script> <script> $( document ).ready( function() { $( '#foo' ).keydown( function() { alert( "debug" ); } ); }); </script> </head> <body> <input id='foo' type='type'/> </body> </html>
And I have this chrome extension that changes the input text and fires the keydown event:
$( document ).ready( function() { window.setTimeout( function() { $( '#foo' ).val( "foo" ); $( '#foo' ).keydown(); }, 2000 ); });
If I install the extension, after 2 seconds (as expected) the text changes, but the warning does not appear, so I can assume that the keydown event keydown not being sent from the extension sandbox to the javascript JavaScript handler. Is there any way I can change my code so that the extension can emulate keydown that javascript can see on the page? I am automating a third-party website using the chrome extension, and one of the inputs requires keyup to detect a value change (page automation I am poorly written - but I have no control over other source code).
google-chrome-extension
grigoryvp
source share