Repository navigation
fix(browser): open the file chooser for a file input, and land a Leave on a busy machine - #993
Merged
Merged
Conversation
…e on a busy machine A headless Chrome has no file chooser, so a click on a file input in the session browser did nothing. The page now intercepts the chooser and opens the system one the attach button uses, for one file or several as the input asks, while a pane shows the page. A beforeunload accepted too soon has Chrome abort the navigation it held and reload the page, and how soon is too soon grows with load (about 450 ms idle, 2 to 3 s with Chromium held to 30% of a core), which made TestChromeADialogWaitsForTheAgentsAnswer fail 6 in 10 under the gate's load. A leave now watches for that reload and takes the held navigation up again once it lands.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
File inputs
A headless Chrome has no file chooser, so a click on a file input in the session browser did nothing (a profile picture upload, for one). Each tab now intercepts the chooser (
Page.setInterceptFileChooserDialog), andPage.fileChooserOpenedopens the system chooser the attach button uses, throughproject.ZenityPicker:PickFilefor a single input, the newPickFilesfor one withmultiple. The picked paths fill the input withDOM.setFileInputFiles; Cancel leaves it as it was.The chooser opens only while a pane shows the page (or in a headed window): an agent's click on a file input in a page nobody is looking at leaves it empty, and no tool fills one. The input's
acceptfilter is not passed on. Both are indocs/ceilings.md.Leave on a busy machine
TestChromeADialogWaitsForTheAgentsAnswer/beforeunloadfailed 6 in 10 under the gate's load. Root cause, measured on Chromium 155: abeforeunloadaccepted too soon after it opens has Chrome hold the navigation's request (it never reaches the server), cancel it withERR_ABORTEDand reload the page, sometimes asking again. How soon is too soon grows with load: about 450 ms idle, 2 to 3 s with Chromium held to 30% of a core. It is not lich's doing (a rawPage.navigatewith no cancellation and no reads after the accept does the same), and no CDP event marks the moment, so the fixedbeforeunloadSettlecannot cover it.A leave now recovers instead (
chrome_leave.go): the URL abeforeunloadholds is kept from the navigation that started just before it; after an accept, a reload on that tab counts as an abort, its ownbeforeunloadis accepted unseen (the person already chose Leave), and once it lands the held URL is loaded again, up to three times.Settlewaits for the leave to land, up to 15 s, so the agent's answer is the page it left for.Test plan
files_live_test.go: a single and amultiplefile input in real Chromium fill with the picked files; fails without the interceptionfiles_test.go: picker per mode, cancel, error, no panechrome_leave_test.go: a leave lands, an aborted one is taken up until its tries run out, dismiss and alerts do not leave (-race)TestChromeADialogWaitsForTheAgentsAnswerwith the test's CPU held byCPUQuota: 6/10 failed at 30% before, 0/20 at 30% and 0/20 at 20% aftergofmt,go vet ./...,go test ./...in the gate's memory jail;GOOS=darwin|windows go build