RESOLVED FIXED 195310
Web Inspector: Protocol: add type checking when commands are called via invoke
https://bugs.webkit.org/show_bug.cgi?id=195310
Summary Web Inspector: Protocol: add type checking when commands are called via invoke
Devin Rousso
Reported 2019-03-04 20:39:55 PST
Right now we only do type checking for when it is called like a normal function.
Attachments
Patch (4.36 KB, patch)
2019-03-04 21:20 PST, Devin Rousso
no flags
Archive of layout-test-results from ews121 for ios-simulator-wk2 (8.85 MB, application/zip)
2019-03-05 03:07 PST, EWS Watchlist
no flags
Patch (24.90 KB, patch)
2019-03-05 13:22 PST, Devin Rousso
no flags
Patch (27.81 KB, patch)
2019-03-07 11:40 PST, Devin Rousso
no flags
Radar WebKit Bug Importer
Comment 1 2019-03-04 20:41:48 PST
Devin Rousso
Comment 2 2019-03-04 21:20:24 PST
EWS Watchlist
Comment 3 2019-03-04 21:22:26 PST Comment hidden (obsolete)
EWS Watchlist
Comment 4 2019-03-05 03:07:26 PST Comment hidden (obsolete)
EWS Watchlist
Comment 5 2019-03-05 03:07:28 PST Comment hidden (obsolete)
Blaze Burg
Comment 6 2019-03-05 09:18:59 PST
Comment on attachment 363596 [details] Patch Good change but.. it needs to be tested. Please update inspector-backend-invocation-return-value.html to exercise the invoke() code paths.
Devin Rousso
Comment 7 2019-03-05 13:22:02 PST
EWS Watchlist
Comment 8 2019-03-05 13:34:41 PST Comment hidden (obsolete)
Joseph Pecoraro
Comment 9 2019-03-07 11:28:58 PST
Comment on attachment 363678 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=363678&action=review > Source/WebInspectorUI/UserInterface/Protocol/InspectorBackend.js:428 > + if (typeof commandArguments !== "object") { > + if (!optional) > + return deliverFailure(`Invalid number of arguments for command '${instance.qualifiedName}'.`); > + continue; > + } > + > + if (!(name in commandArguments) && !optional) > + return deliverFailure(`Missing argument '${name}' for command '${instance.qualifiedName}'.`); Could we just require the first argument is always an object to simplify this a bit: if (typeof commandArguments !== "object") return deliverFailure(`invoke expects an object for command arguments but it was a '${typeof commandArguments}'.`); let parameters = {}; for (let {name, type, optional} of instance.callSignature) { if ((!name in commandArguments && !optional) return deliverFailure(`Missing argument '${name}' for command '${instance.qualifiedName}'.`); ... } > LayoutTests/inspector/protocol/inspector-backend-invocation-return-value.html:122 > + let result = RuntimeAgent.evaluate.invoke(); In other words I don't think we should allow calling invoke with no object (even if there are no required arguments).
Devin Rousso
Comment 10 2019-03-07 11:30:47 PST
Comment on attachment 363678 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=363678&action=review >> LayoutTests/inspector/protocol/inspector-backend-invocation-return-value.html:122 >> + let result = RuntimeAgent.evaluate.invoke(); > > In other words I don't think we should allow calling invoke with no object (even if there are no required arguments). I'm fine with that. I wasn't sure which approach we wanted to take, so I just matched the existing functionality.
Devin Rousso
Comment 11 2019-03-07 11:40:19 PST
EWS Watchlist
Comment 12 2019-03-07 11:42:14 PST Comment hidden (obsolete)
Joseph Pecoraro
Comment 13 2019-03-07 11:53:42 PST
Comment on attachment 363905 [details] Patch r=me
WebKit Commit Bot
Comment 14 2019-03-07 12:40:19 PST
Comment on attachment 363905 [details] Patch Clearing flags on attachment: 363905 Committed r242606: <https://trac.webkit.org/changeset/242606>
WebKit Commit Bot
Comment 15 2019-03-07 12:40:21 PST
All reviewed patches have been landed. Closing bug.
Note You need to log in before you can comment on or make changes to this bug.