https://trac.webkit.org/changeset/275262/webkit changed the injected scripts to have the "//# sourceURL=__InjectedScript_*.js" header. This led to about 1.5k WebDriver tests to fail. Most (all?) of them with the following error: E JavascriptErrorException: javascript error (500): Unexpected keyword 'function'. Expected ')' to end a compound expression. body = {'using': 'css selector', 'value': 'input'} err = <JavascriptErrorException http_status=500> method = 'POST' response = <Response status=500 error=<JavascriptErrorException http_status=500>> self = <Session bb6344e1-8a15-487d-b05c-0cdc06fc85ce> timeout = None url = 'session/bb6344e1-8a15-487d-b05c-0cdc06fc85ce/element' When evaluating the following expression in the test: element = session.find.css("input", all=False) The issue happens due to WebAutomationSessionProxy.js wrapping the executing code in "(async <CODE>)". With the header, this resulted in the following code: ``` (async //# __injectedScript... function (...) {...}) ``` And the "Unexpected keyword" error appeared. A candidate fix is to skip the header lines from the function code before wrapping it in async. Patch in the next comment.
Created attachment 425718 [details] Patch
Comment on attachment 425718 [details] Patch Is that comment useful tor WebDriver scripts? Maybe we could add an option to make-js-file-arrays.py not to include the directive and use that for WebDriver scripts?
(In reply to Carlos Garcia Campos from comment #2) > Comment on attachment 425718 [details] > Patch > > Is that comment useful tor WebDriver scripts? Maybe we could add an option > to make-js-file-arrays.py not to include the directive and use that for > WebDriver scripts? I think it's not directly used by the WebDriver code, but intended for the inspector UI, so there is the scenario of pausing a webdriver session to inspect the code in the browser. In this case, IIUC, the directive should be present in the source.
Comment on attachment 425718 [details] Patch the //# directive is a source map directive. It labels these evaluations, which is essential when debugging WebAutomationSessionProxy code via Web Inspector. Perhaps you could search for the first non-comment line and wrap the remainder of the evaluation there, lifting any initial comments outside the async statement.
Created attachment 425789 [details] Patch
Comment on attachment 425789 [details] Patch r=me
Committed r275915 (236479@main): <https://commits.webkit.org/236479@main> All reviewed patches have been landed. Closing bug and clearing flags on attachment 425789 [details].
<rdar://problem/76614329>