electron/spec/fixtures/module/preload-pdf-loaded-in-nested-subframe.js

16 lines
495 B
JavaScript
Raw Normal View History

2020-03-20 20:28:31 +00:00
const { ipcRenderer } = require('electron');
2017-10-19 14:15:02 +00:00
2017-11-13 20:13:19 +00:00
document.addEventListener('DOMContentLoaded', (event) => {
2020-03-20 20:28:31 +00:00
const outerFrame = document.querySelector('#outer-frame');
2017-10-19 14:15:02 +00:00
if (outerFrame) {
2017-10-20 06:46:41 +00:00
outerFrame.onload = function () {
2020-03-20 20:28:31 +00:00
const pdframe = outerFrame.contentWindow.document.getElementById('pdf-frame');
2017-10-20 06:46:41 +00:00
if (pdframe) {
2017-11-13 20:13:19 +00:00
pdframe.contentWindow.addEventListener('pdf-loaded', (event) => {
2020-03-20 20:28:31 +00:00
ipcRenderer.send('pdf-loaded', event.detail);
});
2017-10-20 06:46:41 +00:00
}
2020-03-20 20:28:31 +00:00
};
2017-10-19 14:15:02 +00:00
}
2020-03-20 20:28:31 +00:00
});