940c4c0787
* chore: deprecate webFrame.registerURLSchemeAsPrivileged * Add register schemes protocol api * update branch to enable browser process API * Revert deprecation changes * Fetch API support * Updated api to take an array, still working on tests * Update tests * Remove web frame API * Minor changes * update scheme registrations on browser and renderer process * fix: enable ses.getBlobData spec * Update breaking changes doc
59 lines
1.8 KiB
JavaScript
59 lines
1.8 KiB
JavaScript
const assert = require('assert')
|
|
const chai = require('chai')
|
|
const dirtyChai = require('dirty-chai')
|
|
const path = require('path')
|
|
const { closeWindow } = require('./window-helpers')
|
|
const { remote, webFrame } = require('electron')
|
|
const { BrowserWindow, ipcMain } = remote
|
|
|
|
const { expect } = chai
|
|
chai.use(dirtyChai)
|
|
|
|
/* Most of the APIs here don't use standard callbacks */
|
|
/* eslint-disable standard/no-callback-literal */
|
|
|
|
describe('webFrame module', function () {
|
|
const fixtures = path.resolve(__dirname, 'fixtures')
|
|
let w = null
|
|
|
|
afterEach(function () {
|
|
return closeWindow(w).then(function () { w = null })
|
|
})
|
|
|
|
it('supports setting the visual and layout zoom level limits', function () {
|
|
assert.doesNotThrow(function () {
|
|
webFrame.setVisualZoomLevelLimits(1, 50)
|
|
webFrame.setLayoutZoomLevelLimits(0, 25)
|
|
})
|
|
})
|
|
|
|
it('calls a spellcheck provider', async () => {
|
|
w = new BrowserWindow({
|
|
show: false,
|
|
webPreferences: {
|
|
nodeIntegration: true
|
|
}
|
|
})
|
|
await w.loadFile(path.join(fixtures, 'pages', 'webframe-spell-check.html'))
|
|
w.focus()
|
|
await w.webContents.executeJavaScript('document.querySelector("input").focus()', true)
|
|
|
|
const spellCheckerFeedback =
|
|
new Promise(resolve => {
|
|
ipcMain.on('spec-spell-check', (e, words, callback) => {
|
|
if (words.length === 2) {
|
|
// The promise is resolved only after this event is received twice
|
|
// Array contains only 1 word first time and 2 the next time
|
|
resolve([words, callback])
|
|
}
|
|
})
|
|
})
|
|
const inputText = 'spleling test '
|
|
for (const keyCode of inputText) {
|
|
w.webContents.sendInputEvent({ type: 'char', keyCode })
|
|
}
|
|
const [words, callback] = await spellCheckerFeedback
|
|
expect(words).to.deep.equal(['spleling', 'test'])
|
|
expect(callback).to.be.true()
|
|
})
|
|
})
|