restore browserView webcontents type

This commit is contained in:
Jeremy Rose
2022-11-10 16:25:38 -08:00
parent b3814f4139
commit 88d0b7fb89
5 changed files with 15 additions and 1 deletions

View File

@@ -15,6 +15,7 @@ export default class BrowserView {
if (webContents) {
v8Util.setHiddenValue(webPreferences, 'webContents', webContents);
}
webPreferences.type = 'browserView';
this.#webContentsView = new WebContentsView(webPreferences);
}

View File

@@ -322,6 +322,9 @@ struct Converter<electron::api::WebContents::Type> {
case Type::kBrowserWindow:
type = "window";
break;
case Type::kBrowserView:
type = "browserView";
break;
case Type::kRemote:
type = "remote";
break;
@@ -346,6 +349,8 @@ struct Converter<electron::api::WebContents::Type> {
return false;
if (type == "backgroundPage") {
*out = Type::kBackgroundPage;
} else if (type == "browserView") {
*out = Type::kBrowserView;
} else if (type == "webview") {
*out = Type::kWebView;
#if BUILDFLAG(ENABLE_OSR)

View File

@@ -115,6 +115,9 @@ class WebContents : public ExclusiveAccessContext,
enum class Type {
kBackgroundPage, // An extension background page.
kBrowserWindow, // Used by BrowserWindow.
kBrowserView, // Used by the JS implementation of BrowserView for
// backwards compatibility. Otherwise identical to
// kBrowserWindow.
kRemote, // Thin wrap around an existing WebContents.
kWebView, // Used by <webview>.
kOffScreen, // Used for offscreen rendering

View File

@@ -50,6 +50,11 @@ describe('BrowserView module', () => {
expect(view.webContents.getURL()).to.equal('about:blank');
});
it('has type browserView', () => {
view = new BrowserView();
expect(view.webContents.getType()).to.equal('browserView');
});
describe('BrowserView.setBackgroundColor()', () => {
it('does not throw for valid args', () => {
view = new BrowserView();

View File

@@ -105,7 +105,7 @@ declare namespace Electron {
interface WebPreferences {
disablePopups?: boolean;
embedder?: Electron.WebContents;
type?: 'backgroundPage' | 'window' | 'remote' | 'webview' | 'offscreen';
type?: 'backgroundPage' | 'window' | 'browserView' | 'remote' | 'webview' | 'offscreen';
}
interface Menu {