|
@@ -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)
|
|
|
})
|