-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
fix(electron): return a ChromiumBrowserContext for electron #4913
fix(electron): return a ChromiumBrowserContext for electron #4913
Conversation
src/dispatchers/browserDispatcher.ts
Outdated
@@ -45,21 +45,21 @@ export class BrowserDispatcher extends Dispatcher<Browser, channels.BrowserIniti | |||
} | |||
|
|||
async crNewBrowserCDPSession(): Promise<channels.BrowserCrNewBrowserCDPSessionResult> { | |||
if (this._object._options.name !== 'chromium') | |||
if (this._object._options.name !== 'chromium' && this._object._options.name !== 'electron') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe add a helper function like isChromiumBasedBrowser() since its duplicated logic which is "hard" to maintain.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, something like isChromiumBased(). I wonder what happens with android? Can we do newCDPSession there? We probably should.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Browsers now register themselves with isChromium
. I changed the protocol so that isChromium
is sent rather than browserName
. And android now reports a ChromiumBrowserContext.
cc4993c
to
2113dea
Compare
2113dea
to
e61f97c
Compare
@@ -507,7 +507,7 @@ BrowserContext: | |||
type: interface | |||
|
|||
initializer: | |||
browserName: string | |||
isChromium: boolean |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why don't we send both? I find browserName pretty useful.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
browserName
in the client was only used to distinguish chromium and non-chromium based browsers. Removing it ensures that nobody does browserName === 'chromum'
when they mean isChromium
.
If will need it back, it will probably be for some feature that requires larger protocol changes. So let's not have it until we need it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure about what other language clients do? I am somewhat hesitant breaking them without a good reason.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought none of them distinguish browsers. I'll check to confirm. I imagine if they are using browserName, they will want to want to fix the same bug and consider electron to be chromium.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
python reads the browser name, but should switch to isChromium
after this patch. https://github.com/microsoft/playwright-python/blob/30c5b52cc460f3cce8ba1910682c9d74e0f6f5bf/playwright/_impl/_object_factory.py#L57
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Java, Go, and Crystal do not appear to distinguish between browsers by name.
Co-authored-by: Max Schmitt <[email protected]>
fixes #4905