Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: prevent destroyed view references from causing crashes (#25509)
* fix: prevent destroyed view references from causing crashes * Remove extraneous comments * Relocate crash test to proper location * Add WebContentsObserver * Add nullptr check and inspectable observer * Remote initial test file * Add test cases to test file * Rename and move testing file * Fix linting errors * Make functions exit early on check * Fix setBackgroundColor function call in test file * Fix styling of test file * Fix mac name mismatch and make variable name more clear Co-authored-by: Michaela Laurencin <mlaurencin@microsoft.com>
- Loading branch information
1 parent
4e080c4
commit 0f4f5ac
Showing
5 changed files
with
90 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
spec-main/fixtures/crash-cases/api-browser-destroy/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
const { app, BrowserWindow, BrowserView } = require('electron'); | ||
const { expect } = require('chai'); | ||
|
||
function createWindow () { | ||
// Create the browser window. | ||
const mainWindow = new BrowserWindow({ | ||
width: 800, | ||
height: 600, | ||
webPreferences: { | ||
nodeIntegration: true | ||
} | ||
}); | ||
const view = new BrowserView(); | ||
mainWindow.addBrowserView(view); | ||
view.webContents.destroy(); | ||
view.setBounds({ x: 0, y: 0, width: 0, height: 0 }); | ||
const bounds = view.getBounds(); | ||
expect(bounds).to.deep.equal({ x: 0, y: 0, width: 0, height: 0 }); | ||
view.setBackgroundColor('#56cc5b10'); | ||
} | ||
|
||
app.on('ready', () => { | ||
createWindow(); | ||
setTimeout(() => app.quit()); | ||
}); |