RESOLVED FIXED224422
REGRESSION(r275262) [WebDriver] Make automation JS code aware of injected script headers
https://bugs.webkit.org/show_bug.cgi?id=224422
Summary REGRESSION(r275262) [WebDriver] Make automation JS code aware of injected scr...
Lauro Moura
Reported 2021-04-11 21:08:15 PDT
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.
Attachments
Patch (2.20 KB, patch)
2021-04-11 21:16 PDT, Lauro Moura
no flags
Patch (2.56 KB, patch)
2021-04-12 14:13 PDT, Lauro Moura
no flags
Lauro Moura
Comment 1 2021-04-11 21:16:15 PDT
Carlos Garcia Campos
Comment 2 2021-04-12 01:15:09 PDT
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?
Lauro Moura
Comment 3 2021-04-12 10:29:55 PDT
(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.
Blaze Burg
Comment 4 2021-04-12 13:50:00 PDT
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.
Lauro Moura
Comment 5 2021-04-12 14:13:27 PDT
Blaze Burg
Comment 6 2021-04-13 09:02:30 PDT
Comment on attachment 425789 [details] Patch r=me
EWS
Comment 7 2021-04-13 15:42:43 PDT
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].
Radar WebKit Bug Importer
Comment 8 2021-04-13 15:43:15 PDT
Note You need to log in before you can comment on or make changes to this bug.