electron/spec/fixtures/pages/webview-in-page-navigate.html
Shelley Vohr 3ca87d205f
feat: make zoomLevel/zoomFactor sync (#16410)
* feat: make zoomLevel/zoomFactor sync

* update ts defs dep
2019-01-20 23:40:27 -08:00

30 lines
876 B
HTML

<html>
<body>
<webview nodeintegration src="zoom://host1" id="view" partition="webview-temp"/>
</body>
<script>
const {ipcRenderer, webFrame} = require('electron')
const view = document.getElementById('view')
let finalNavigation = false
function SendZoomLevel() {
return new Promise((resolve, reject) => {
const zoomLevel = view.getZoomLevel()
const zoomFactor = view.getZoomFactor()
ipcRenderer.send('webview-zoom-in-page', zoomLevel, zoomFactor, finalNavigation)
resolve()
})
}
view.addEventListener('dom-ready', () => {
view.setZoomLevel(2.0)
SendZoomLevel().then(() => {
if (!finalNavigation) {
finalNavigation = true
view.executeJavaScript('window.location.hash=123', () => {})
}
})
})
view.addEventListener('did-navigate-in-page', () => {
SendZoomLevel()
})
</script>
</html>