diff --git a/lib/renderer/web-view/web-view-impl.ts b/lib/renderer/web-view/web-view-impl.ts index c345d7a4de9a..494c779cbf2e 100644 --- a/lib/renderer/web-view/web-view-impl.ts +++ b/lib/renderer/web-view/web-view-impl.ts @@ -44,7 +44,9 @@ export class WebViewImpl { // Create internal iframe element. this.internalElement = this.createInternalElement(); const shadowRoot = this.webviewNode.attachShadow({ mode: 'open' }); - shadowRoot.innerHTML = ''; + const style = shadowRoot.ownerDocument.createElement('style'); + style.textContent = ':host { display: flex; }'; + shadowRoot.appendChild(style); this.setupWebViewAttributes(); this.viewInstanceId = getNextId(); shadowRoot.appendChild(this.internalElement); diff --git a/spec-main/webview-spec.ts b/spec-main/webview-spec.ts index 76f0fa517d0e..e9de935e245c 100644 --- a/spec-main/webview-spec.ts +++ b/spec-main/webview-spec.ts @@ -63,7 +63,6 @@ describe(' tag', function () { show: false, webPreferences: { webviewTag: true, - nodeIntegration: true, sandbox: true } }); @@ -76,7 +75,6 @@ describe(' tag', function () { show: false, webPreferences: { webviewTag: true, - nodeIntegration: true, contextIsolation: true } }); @@ -89,7 +87,6 @@ describe(' tag', function () { show: false, webPreferences: { webviewTag: true, - nodeIntegration: true, contextIsolation: true, sandbox: true } @@ -98,6 +95,17 @@ describe(' tag', function () { await emittedOnce(ipcMain, 'pong'); }); + it('works with Trusted Types', async () => { + const w = new BrowserWindow({ + show: false, + webPreferences: { + webviewTag: true + } + }); + w.loadFile(path.join(fixtures, 'pages', 'webview-trusted-types.html')); + await emittedOnce(ipcMain, 'pong'); + }); + it('is disabled by default', async () => { const w = new BrowserWindow({ show: false, diff --git a/spec/fixtures/pages/webview-trusted-types.html b/spec/fixtures/pages/webview-trusted-types.html new file mode 100644 index 000000000000..328a2a3f4d3a --- /dev/null +++ b/spec/fixtures/pages/webview-trusted-types.html @@ -0,0 +1,8 @@ + + + + + + + +