-
Notifications
You must be signed in to change notification settings - Fork 5.9k
fix(chromium): do not hang connectOverCDP on a page stuck loading #41128
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
yury-s
wants to merge
5
commits into
microsoft:main
Choose a base branch
from
yury-s:fix-41093
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+63
−5
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
95d1644
fix(chromium): do not hang connectOverCDP on a page stuck loading
yury-s b9fee6e
test(chromium): assert the previously-stuck page is usable after connect
yury-s 222be5d
chore(chromium): drop redundant comment on _attachingPreExistingTargets
yury-s e28d90b
fix(chromium): skip page-init wait when connecting over CDP
yury-s 3c04379
fix(chromium): only wait for committed pages when connecting over CDP
yury-s File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -224,6 +224,53 @@ test('should connect to existing page with iframe and navigate', async ({ browse | |
| } | ||
| }); | ||
|
|
||
| test('should connect to a browser with a page stuck loading its first navigation', { | ||
| annotation: { | ||
| type: 'issue', | ||
| description: 'https://github.com/microsoft/playwright/issues/41093' | ||
| } | ||
| }, async ({ browserType, server, childProcess, waitForPort, mode }, testInfo) => { | ||
| test.skip(mode !== 'default', 'Spawns the browser executable directly'); | ||
|
|
||
| // Hold the response so the tab's first navigation never commits; release it later. | ||
| let releaseHang = () => {}; | ||
| server.setRoute('/hang', (req, res) => { | ||
| releaseHang = () => { | ||
| res.writeHead(200, { 'content-type': 'text/html' }); | ||
| res.end('<html></html>'); | ||
| }; | ||
| }); | ||
|
|
||
| const port = 9339 + testInfo.workerIndex; | ||
| // Launch the browser directly (not via Playwright) so that we are the only CDP client. | ||
| childProcess({ | ||
| command: [browserType.executablePath(), | ||
| `--remote-debugging-port=${port}`, | ||
| `--user-data-dir=${testInfo.outputPath('cdp-user-data-dir')}`, | ||
| '--headless=new', | ||
| '--no-first-run', | ||
| '--no-default-browser-check', | ||
| 'about:blank', | ||
| ], | ||
| }); | ||
| await waitForPort(port); | ||
|
|
||
| // Open a tab whose very first navigation never commits. | ||
| await Promise.all([ | ||
| server.waitForRequest('/hang'), | ||
| fetch(`http://127.0.0.1:${port}/json/new?${server.PREFIX}/hang`, { method: 'PUT' }), | ||
| ]); | ||
|
|
||
| // connectOverCDP must not hang waiting for the stuck page to commit a navigation. | ||
| const cdpBrowser = await browserType.connectOverCDP(`http://127.0.0.1:${port}/`); | ||
| const context = cdpBrowser.contexts()[0]; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. expect there is just a single |
||
| // The stuck tab has not committed a navigation yet, so it is not reported. Releasing the | ||
| // response lets it finish navigating to /hang and show up in the context. | ||
| releaseHang(); | ||
| await expect.poll(() => context.pages().map(page => page.url())).toContain(server.PREFIX + '/hang'); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can just |
||
| await cdpBrowser.close(); | ||
| }); | ||
|
|
||
| test('should connect to existing service workers', async ({ browserType, mode, server }, testInfo) => { | ||
| const port = 9339 + testInfo.workerIndex; | ||
| const browserServer = await browserType.launch({ | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.