electron/spec/fixtures/no-proprietary-codecs.js
Samuel Attard 186301e126
feat: enable context isolation by default (#26890)
* feat: enable context isolation by default

* chore: set default in ctx iso getter

* spec: make all specs work with the new contextIsolation default

* spec: fix affinity specs

* spec: update tests for new ctx iso default

* spec: update tests for new ctx iso default

* spec: update tests for new ctx iso default

* spec: update tests for new ctx iso default

* chore: move stray prod deps to dev deps

* spec: update tests for new ctx iso default

* turn off contextIsolation for visibility tests

* turn off contextIsolation for <webview> tag nodeintegration attribute loads native modules when navigation happens

Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org>
2021-03-01 16:52:29 -05:00

51 lines
1.3 KiB
JavaScript

// Verifies that Electron cannot play a video that uses proprietary codecs
//
// This application should be run with the ffmpeg that does not include
// proprietary codecs to ensure Electron uses it instead of the version
// that does include proprietary codecs.
const { app, BrowserWindow, ipcMain } = require('electron');
const path = require('path');
const MEDIA_ERR_SRC_NOT_SUPPORTED = 4;
const FIVE_MINUTES = 5 * 60 * 1000;
let window;
app.whenReady().then(() => {
window = new BrowserWindow({
show: false,
webPreferences: {
nodeIntegration: true,
contextIsolation: false
}
});
window.webContents.on('crashed', (event, killed) => {
console.log(`WebContents crashed (killed=${killed})`);
app.exit(1);
});
window.loadFile(path.resolve(__dirname, 'test.asar', 'video.asar', 'index.html'));
ipcMain.on('asar-video', (event, message, error) => {
if (message === 'ended') {
console.log('Video played, proprietary codecs are included');
app.exit(1);
return;
}
if (message === 'error' && error === MEDIA_ERR_SRC_NOT_SUPPORTED) {
app.exit(0);
return;
}
console.log(`Unexpected response from page: ${message} ${error}`);
app.exit(1);
});
setTimeout(() => {
console.log('No IPC message after 5 minutes');
app.exit(1);
}, FIVE_MINUTES);
});