add a new spec for https://github.com/electron/electron/pull/10008
This commit is contained in:
parent
4fb1fffe44
commit
01d021e6a3
1 changed files with 27 additions and 0 deletions
|
@ -982,6 +982,15 @@ describe('chromium feature', function () {
|
||||||
protocol: 'file',
|
protocol: 'file',
|
||||||
slashes: true
|
slashes: true
|
||||||
})
|
})
|
||||||
|
const pdfSourceWithParams = url.format({
|
||||||
|
pathname: path.join(fixtures, 'assets', 'cat.pdf').replace(/\\/g, '/'),
|
||||||
|
query: {
|
||||||
|
a: 1,
|
||||||
|
b: 2
|
||||||
|
},
|
||||||
|
protocol: 'file',
|
||||||
|
slashes: true
|
||||||
|
})
|
||||||
|
|
||||||
function createBrowserWindow ({plugins}) {
|
function createBrowserWindow ({plugins}) {
|
||||||
w = new BrowserWindow({
|
w = new BrowserWindow({
|
||||||
|
@ -1009,6 +1018,24 @@ describe('chromium feature', function () {
|
||||||
w.webContents.loadURL(pdfSource)
|
w.webContents.loadURL(pdfSource)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('opens a pdf link given params, the query string should be escaped', function (done) {
|
||||||
|
createBrowserWindow({plugins: true})
|
||||||
|
ipcMain.once('pdf-loaded', function (event, state) {
|
||||||
|
assert.equal(state, 'success')
|
||||||
|
done()
|
||||||
|
})
|
||||||
|
w.webContents.on('page-title-updated', function () {
|
||||||
|
const parsedURL = url.parse(w.webContents.getURL(), true)
|
||||||
|
assert.equal(parsedURL.protocol, 'chrome:')
|
||||||
|
assert.equal(parsedURL.hostname, 'pdf-viewer')
|
||||||
|
assert.equal(parsedURL.query.src, pdfSourceWithParams)
|
||||||
|
assert.equal(parsedURL.query.b, undefined)
|
||||||
|
assert.equal(parsedURL.search, `?src=${pdfSource}%3Fa%3D1%26b%3D2`)
|
||||||
|
assert.equal(w.webContents.getTitle(), 'cat.pdf')
|
||||||
|
})
|
||||||
|
w.webContents.loadURL(pdfSourceWithParams)
|
||||||
|
})
|
||||||
|
|
||||||
it('should download a pdf when plugins are disabled', function (done) {
|
it('should download a pdf when plugins are disabled', function (done) {
|
||||||
createBrowserWindow({plugins: false})
|
createBrowserWindow({plugins: false})
|
||||||
ipcRenderer.sendSync('set-download-option', false, false)
|
ipcRenderer.sendSync('set-download-option', false, false)
|
||||||
|
|
Loading…
Reference in a new issue