зеркало из https://github.com/electron/electron.git
spec: check if pdf has loaded
This commit is contained in:
Родитель
6e02d18a40
Коммит
80ce60f644
|
@ -813,7 +813,10 @@ describe('chromium feature', function () {
|
|||
|
||||
beforeEach(function () {
|
||||
w = new BrowserWindow({
|
||||
show: false
|
||||
show: false,
|
||||
webPreferences: {
|
||||
preload: path.join(fixtures, 'module', 'preload-inject-ipc.js')
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
|
@ -822,15 +825,23 @@ describe('chromium feature', function () {
|
|||
})
|
||||
|
||||
it('opens when loading a pdf resource as top level navigation', function (done) {
|
||||
w.webContents.on('did-finish-load', function () {
|
||||
ipcMain.once('pdf-loaded', function (event, success) {
|
||||
if (success) done()
|
||||
})
|
||||
w.webContents.on('page-title-updated', function () {
|
||||
const source = `
|
||||
if (window.viewer) {
|
||||
window.viewer.setLoadCallback(function(success) {
|
||||
window.ipcRenderer.send('pdf-loaded', success);
|
||||
});
|
||||
}
|
||||
`
|
||||
const parsedURL = url.parse(w.webContents.getURL(), true)
|
||||
assert.equal(parsedURL.protocol, 'chrome:')
|
||||
assert.equal(parsedURL.hostname, 'pdf-viewer')
|
||||
assert.equal(parsedURL.query.src, pdfSource)
|
||||
})
|
||||
w.webContents.on('page-title-updated', function () {
|
||||
assert.equal(w.webContents.getTitle(), 'cat.pdf')
|
||||
done()
|
||||
w.webContents.executeJavaScript(source)
|
||||
})
|
||||
w.webContents.loadURL(pdfSource)
|
||||
})
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
const {ipcRenderer} = require('electron')
|
||||
window.ipcRenderer = ipcRenderer
|
|
@ -1 +1 @@
|
|||
Subproject commit 3bf66a67738aa338b0622f36caacbb23235e0844
|
||||
Subproject commit a050a339cfeabcfb5f07c313161d2ee27b6c3a39
|
Загрузка…
Ссылка в новой задаче