WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED WONTFIX
208420
Web Inspector: introduce a proxy-based protocol test harness
https://bugs.webkit.org/show_bug.cgi?id=208420
Summary
Web Inspector: introduce a proxy-based protocol test harness
Pavel Feldman
Reported
2020-02-29 16:41:40 PST
Here is how it looks: const protocol = InspectorProtocol.protocol; // Setup interception. await Promise.all([protocol.Runtime.enable(), protocol.Network.enable()]); await protocol.Network.setInterceptionEnabled({ enabled: true }); // Get URL to override and override it. const { result } = await protocol.Runtime.evaluate({ expression: "document.URL" }); const url = result.value.substring(0, result.value.lastIndexOf("/")) + "/resources/data.json"; await protocol.Network.addInterception({ url, stage: "response" }); // Fetch URL and intercept it. protocol.Runtime.evaluate({ expression: "fetch('resources/data.json').then(r => r.text())"}); const event = await protocol.Network.onceResponseIntercepted(); ProtocolTest.pass("Intercepted response."); // // Let the load continue. await Promise.all([ protocol.Network.onceResponseReceived(), protocol.Network.interceptContinue({ requestId: event.params.requestId }) ]); ProtocolTest.pass("Response received."); await protocol.Network.removeInterception({ url, stage: "response" }); WDYT?
Attachments
Patch
(6.48 KB, patch)
2020-02-29 16:45 PST
,
Pavel Feldman
hi
: review-
Details
Formatted Diff
Diff
View All
Add attachment
proposed patch, testcase, etc.
Pavel Feldman
Comment 1
2020-02-29 16:45:41 PST
Created
attachment 392080
[details]
Patch
Devin Rousso
Comment 2
2020-03-02 11:33:50 PST
Comment on
attachment 392080
[details]
Patch r-, I _really_ don't like this approach. It now means that code is no longer searchable. Most (if not all) IDEs will be unable to "Jump to Definition". Why is this needed? Personally, I don't think the code is any more readable than it was before (and I didn't have a problem before).
Pavel Feldman
Comment 3
2020-03-02 16:22:52 PST
No worries. We used to have what you have and then added this proxy mode and that boosted the number of protocol tests that we were able to produce. Basically we went from 10s to 100s. Protocol tests are cheap and fast, so all the means that improve their readability were bug wins. Third-parties were also able to finally read our tests as well. While I obviously don't insist, I find it much more readable and I would encourage you do to a little poll among your colleagues - maybe someone likes it like myself...
>> It now means that code is no longer searchable.
There was no way to jump to the definition before either, so it is not that we are losing much here.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug