Skip to content
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

Merged

Conversation

JoelEinbinder
Copy link
Contributor

fixes #4905

@@ -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')
Copy link
Member

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.

Copy link
Contributor

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.

Copy link
Contributor Author

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.

@JoelEinbinder JoelEinbinder force-pushed the electron_chromium_browsercontext branch from cc4993c to 2113dea Compare January 12, 2021 17:47
@JoelEinbinder JoelEinbinder force-pushed the electron_chromium_browsercontext branch from 2113dea to e61f97c Compare January 12, 2021 18:05
@@ -507,7 +507,7 @@ BrowserContext:
type: interface

initializer:
browserName: string
isChromium: boolean
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same in C#: https://github.com/microsoft/playwright-sharp/blob/afb06a5a3c69f48f524260ad382aab59efd13e77/src/PlaywrightSharp/Page.cs#L793

Java, Go, and Crystal do not appear to distinguish between browsers by name.

@JoelEinbinder JoelEinbinder merged commit decf373 into microsoft:master Jan 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] Electron: neither ElectronApplication.context() nor ElectronPage.context() are ChromiumBrowserContexts
3 participants