-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PlzDedicatedWorker: support DevTools for browser-initiated dedicated …
…workers PlzDedicatedWorker makes the worker script fetch a browser-initiated and dedicated workers will be real service worker clients. Before the feature, the worker script fetch was a renderer-initiated and dedicated workers are treated as a subresource in the parent frame. I2S: https://groups.google.com/a/chromium.org/g/blink-dev/c/FhGd1AqB3ng/ This CL 1) Removes http/tests/inspector-protocol/fetch/dedicated-worker-main-script.js because `dp.Fetch.onRequestPaused` intercepts a renderer-initiated request in the frame, but after PlzDedicatedWorker, the worker script fetch runs on the browser process. 2) Instead, adds http/tests/inspector-protocol/fetch/worker-interception.js that observes browser-initiated requests via `globalFetcher`. 3) Implements the DevTools integration for PlzDedicatedWorker. 3-1) Creates WorkerDevToolsAgentHost in DedicatedWorkerHostFactoryImpl. 3-2) Sets a callback to TargetHandler as `worker_throttle_`. 3-3) Resumes the script fetch in DedicatedWorkerHost::StartScriptLoad(). The worker script fetch of `worker.js` is not observed without the implementation (3) and the worker-interception.js test fails: > Tests that dedicated worker requests are intercepted. > [browser] Request to http://127.0.0.1:8000/inspector-protocol/fetch/resources/empty.html, type: Document > -[browser] Request to http://127.0.0.1:8000/inspector-protocol/fetch/resources/worker.js, type: Other > [browser] Request to http://127.0.0.1:8000/inspector-protocol/fetch/resources/fetch-data.txt, type: XHR > -Response after Fetch.fulfillRequest: Fetched for real! > +Response after Fetch.fulfillRequest: overridden response body See the test result of http/tests/inspector-protocol/fetch/worker-interception.js in https://ci.chromium.org/ui/p/chromium/builders/try/linux_layout_tests_composite_after_paint/55826/test-results Bug: 1143102 Change-Id: I9d2f23ed4076f9fa36805da599daac06bc2b163d Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3068908 Reviewed-by: Koji Ishii <kojii@chromium.org> Reviewed-by: Andrey Kosyakov <caseq@chromium.org> Reviewed-by: Hiroki Nakagawa <nhiroki@chromium.org> Commit-Queue: Asami Doi <asamidoi@chromium.org> Cr-Commit-Position: refs/heads/main@{#933339} NOKEYCHECK=True GitOrigin-RevId: 1ee5fb813d06cfb948ba4d71929b954db1971754
- Loading branch information
1 parent
089bc7f
commit 3548686
Showing
11 changed files
with
54 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 0 additions & 33 deletions
33
blink/web_tests/http/tests/inspector-protocol/fetch/dedicated-worker-main-script.js
This file was deleted.
Oops, something went wrong.
File renamed without changes.
6 changes: 6 additions & 0 deletions
6
blink/web_tests/http/tests/inspector-protocol/fetch/resources/shared-worker.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
self.testToken = 'FAIL: original value'; | ||
|
||
self.addEventListener('connect', e => { | ||
e.ports[0].postMessage('ready'); | ||
}); | ||
|
7 changes: 3 additions & 4 deletions
7
blink/web_tests/http/tests/inspector-protocol/fetch/resources/worker.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
self.testToken = 'FAIL: original value'; | ||
console.log("Worker"); | ||
|
||
self.addEventListener('connect', e => { | ||
e.ports[0].postMessage('ready'); | ||
self.addEventListener('message', e => { | ||
self.postMessage('ready'); | ||
}); | ||
|
6 changes: 3 additions & 3 deletions
6
blink/web_tests/http/tests/inspector-protocol/fetch/service-worker-interception-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
blink/web_tests/http/tests/inspector-protocol/fetch/worker-interception-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Tests that dedicated worker requests are intercepted. | ||
[browser] Request to http://127.0.0.1:8000/inspector-protocol/fetch/resources/empty.html, type: Document | ||
[browser] Request to http://127.0.0.1:8000/inspector-protocol/fetch/resources/worker.js, type: Other | ||
worker is ready | ||
|
33 changes: 33 additions & 0 deletions
33
blink/web_tests/http/tests/inspector-protocol/fetch/worker-interception.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
(async function(testRunner) { | ||
const {page, session, dp} = await testRunner.startBlank( | ||
`Tests that dedicated worker requests are intercepted.`); | ||
|
||
const FetchHelper = await testRunner.loadScript("resources/fetch-test.js"); | ||
const globalFetcher = new FetchHelper(testRunner, testRunner.browserP()); | ||
globalFetcher.setLogPrefix("[browser] "); | ||
await globalFetcher.enable(); | ||
|
||
globalFetcher.onRequest().continueRequest({}); | ||
|
||
await dp.Target.setAutoAttach({ | ||
autoAttach: true, waitForDebuggerOnStart: true, flatten: true}); | ||
dp.Target.onAttachedToTarget(async event => { | ||
const wdp = session.createChild(event.params.sessionId).protocol; | ||
await wdp.Runtime.runIfWaitingForDebugger(); | ||
}); | ||
|
||
await dp.Page.enable(); | ||
await session.navigate("resources/empty.html"); | ||
|
||
const result = await session.evaluateAsync(` | ||
const w = new Worker('/inspector-protocol/fetch/resources/worker.js'); | ||
new Promise((resolve, reject) => { | ||
w.onmessage = e => resolve('worker is ready'); | ||
w.onerror = e => reject(e.message); | ||
w.postMessage('start a worker'); | ||
}) | ||
`); | ||
|
||
testRunner.log(result); | ||
testRunner.completeTest(); | ||
}); |