Created
July 20, 2020 15:59
-
-
Save ckerr/315d7b9da1ac0202b72cbe2dff745953 to your computer and use it in GitHub Desktop.
drivon's repro of https://github.com/electron/electron/issues/24630
This file contains hidden or 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
const {app, BrowserWindow, ipcMain} = require('electron'); | |
app.on('ready', () => { | |
const window = new BrowserWindow({ webPreferences: { webviewTag: true } }); | |
window.loadURL('file://' + app.getAppPath() + '/renderer.html'); | |
}); | |
ipcMain.on('visibilityState', (event, evType, visibilityState) => { | |
console.log('visibilityState', evType, visibilityState); | |
}) |
This file contains hidden or 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
{ | |
"name": "webview-visibilitystate-unload", | |
"devDependencies": { | |
"electron": "10.0.0-beta.12" | |
}, | |
"scripts": { | |
"run": "electron main.js" | |
} | |
} |
This file contains hidden or 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
const { ipcRenderer } = require("electron"); | |
function sendVisibilityState(ev) { | |
ipcRenderer.send("visibilityState", ev.type, document.visibilityState); | |
} | |
document.addEventListener('visibilitychange', sendVisibilityState); | |
window.addEventListener('beforeunload', sendVisibilityState); | |
window.addEventListener('unload', sendVisibilityState); |
This file contains hidden or 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>webview-visibilitystate-unload</title> | |
</head> | |
<body> | |
<webview id="webview" src="./webview.html" preload="./preload.js" /> | |
</body> | |
</html> |
This file contains hidden or 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta http-equiv="refresh" content="5;URL=about:blank"> | |
<script> | |
function logVisibilityState(ev) { | |
console.log('visibilityState', ev.type, document.visibilityState) | |
} | |
document.addEventListener('visibilitychange', logVisibilityState); | |
window.addEventListener('beforeunload', logVisibilityState); | |
window.addEventListener('unload', logVisibilityState); | |
</script> | |
</head> | |
<body> | |
<p>This webview will be unloaded in 5s.</p> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment