|
@@ -9,6 +9,7 @@ const url = require('url')
|
|
|
const ChildProcess = require('child_process')
|
|
|
const { ipcRenderer, remote } = require('electron')
|
|
|
const { emittedOnce } = require('./events-helpers')
|
|
|
+const { promisify } = require('util')
|
|
|
const { closeWindow, waitForWebContentsToLoad } = require('./window-helpers')
|
|
|
const { resolveGetters } = require('./assert-helpers')
|
|
|
const { app, BrowserWindow, ipcMain, protocol, session, webContents } = remote
|
|
@@ -1574,3 +1575,81 @@ describe('font fallback', () => {
|
|
|
}[process.platform])
|
|
|
})
|
|
|
})
|
|
|
+
|
|
|
+describe('iframe using HTML fullscreen API while window is OS-fullscreened', () => {
|
|
|
+ const fixtures = path.resolve(__dirname, 'fixtures')
|
|
|
+ const fullscreenChildHtml = promisify(fs.readFile)(
|
|
|
+ path.join(fixtures, 'pages', 'fullscreen-oopif.html')
|
|
|
+ )
|
|
|
+ let w, server
|
|
|
+
|
|
|
+ before(() => {
|
|
|
+ server = http.createServer(async (_req, res) => {
|
|
|
+ res.writeHead(200, { 'Content-Type': 'text/html' })
|
|
|
+ res.write(await fullscreenChildHtml)
|
|
|
+ res.end()
|
|
|
+ })
|
|
|
+
|
|
|
+ server.listen(8989, '127.0.0.1')
|
|
|
+ })
|
|
|
+
|
|
|
+ beforeEach(() => {
|
|
|
+ w = new BrowserWindow({
|
|
|
+ show: true,
|
|
|
+ fullscreen: true,
|
|
|
+ webPreferences: {
|
|
|
+ nodeIntegration: true,
|
|
|
+ nodeIntegrationInSubFrames: true
|
|
|
+ }
|
|
|
+ })
|
|
|
+ })
|
|
|
+
|
|
|
+ afterEach(() => {
|
|
|
+ closeWindow(w).then(() => { w = null })
|
|
|
+ server.close()
|
|
|
+ })
|
|
|
+
|
|
|
+ it('can fullscreen from out-of-process iframes (OOPIFs)', done => {
|
|
|
+ ipcMain.once('fullscreenChange', async () => {
|
|
|
+ const fullscreenWidth = await w.webContents.executeJavaScript(
|
|
|
+ "document.querySelector('iframe').offsetWidth"
|
|
|
+ )
|
|
|
+ expect(fullscreenWidth > 0).to.be.true()
|
|
|
+
|
|
|
+ await w.webContents.executeJavaScript(
|
|
|
+ "document.querySelector('iframe').contentWindow.postMessage('exitFullscreen', '*')"
|
|
|
+ )
|
|
|
+
|
|
|
+ await new Promise(resolve => setTimeout(resolve, 500))
|
|
|
+
|
|
|
+ const width = await w.webContents.executeJavaScript(
|
|
|
+ "document.querySelector('iframe').offsetWidth"
|
|
|
+ )
|
|
|
+ expect(width).to.equal(0)
|
|
|
+
|
|
|
+ done()
|
|
|
+ })
|
|
|
+
|
|
|
+ const html =
|
|
|
+ '<iframe style="width: 0" frameborder=0 src="http://localhost:8989" allowfullscreen></iframe>'
|
|
|
+ w.loadURL(`data:text/html,${html}`)
|
|
|
+ })
|
|
|
+
|
|
|
+ it('can fullscreen from in-process iframes', done => {
|
|
|
+ ipcMain.once('fullscreenChange', async () => {
|
|
|
+ const fullscreenWidth = await w.webContents.executeJavaScript(
|
|
|
+ "document.querySelector('iframe').offsetWidth"
|
|
|
+ )
|
|
|
+ expect(fullscreenWidth > 0).to.true()
|
|
|
+
|
|
|
+ await w.webContents.executeJavaScript('document.exitFullscreen()')
|
|
|
+ const width = await w.webContents.executeJavaScript(
|
|
|
+ "document.querySelector('iframe').offsetWidth"
|
|
|
+ )
|
|
|
+ expect(width).to.equal(0)
|
|
|
+ done()
|
|
|
+ })
|
|
|
+
|
|
|
+ w.loadFile(path.join(fixtures, 'pages', 'fullscreen-ipif.html'))
|
|
|
+ })
|
|
|
+})
|