fix: crash loading about:blank in subframes (#45694)

fix: crash loading about:blank in subframes
This commit is contained in:
Shelley Vohr 2025-02-20 18:07:15 +01:00 committed by GitHub
parent d6f4982522
commit d8baceb08c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 38 additions and 4 deletions

View file

@ -217,6 +217,40 @@ describe('renderer nodeIntegrationInSubFrames', () => {
});
});
describe('subframe with non-standard schemes', () => {
it('should not crash when changing subframe src to about:blank and back', async () => {
const w = new BrowserWindow({ show: false, width: 400, height: 400 });
const fwfPath = path.resolve(__dirname, 'fixtures/sub-frames/frame-with-frame.html');
await w.loadFile(fwfPath);
const originalSrc = await w.webContents.executeJavaScript(`
const iframe = document.querySelector('iframe');
iframe.src;
`);
const updatedSrc = await w.webContents.executeJavaScript(`
new Promise((resolve, reject) => {
const iframe = document.querySelector('iframe');
iframe.src = 'about:blank';
resolve(iframe.src);
})
`);
expect(updatedSrc).to.equal('about:blank');
const restoredSrc = await w.webContents.executeJavaScript(`
new Promise((resolve, reject) => {
const iframe = document.querySelector('iframe');
iframe.src = '${originalSrc}';
resolve(iframe.src);
})
`);
expect(restoredSrc).to.equal(originalSrc);
});
});
// app.getAppMetrics() does not return sandbox information on Linux.
ifdescribe(process.platform !== 'linux')('cross-site frame sandboxing', () => {
let server: http.Server;