diff --git a/spec-main/chromium-spec.ts b/spec-main/chromium-spec.ts index 06fa2e5154158..26d0afbca2bb9 100644 --- a/spec-main/chromium-spec.ts +++ b/spec-main/chromium-spec.ts @@ -495,6 +495,37 @@ describe('chromium features', () => { }); }); + describe('first party sets', () => { + const fps = [ + 'https://fps-member1.glitch.me', + 'https://fps-member2.glitch.me', + 'https://fps-member3.glitch.me' + ]; + + it('loads first party sets', async () => { + const appPath = path.join(fixturesPath, 'api', 'first-party-sets', 'base'); + const fpsProcess = ChildProcess.spawn(process.execPath, [appPath]); + + let output = ''; + fpsProcess.stdout.on('data', data => { output += data; }); + await emittedOnce(fpsProcess, 'exit'); + + expect(output).to.include(fps.join(',')); + }); + + it('loads sets from the command line', async () => { + const appPath = path.join(fixturesPath, 'api', 'first-party-sets', 'command-line'); + const args = [appPath, `--use-first-party-set=${fps}`]; + const fpsProcess = ChildProcess.spawn(process.execPath, args); + + let output = ''; + fpsProcess.stdout.on('data', data => { output += data; }); + await emittedOnce(fpsProcess, 'exit'); + + expect(output).to.include(fps.join(',')); + }); + }); + describe('loading jquery', () => { it('does not crash', (done) => { const w = new BrowserWindow({ show: false }); diff --git a/spec/fixtures/api/first-party-sets/base/main.js b/spec/fixtures/api/first-party-sets/base/main.js new file mode 100644 index 0000000000000..68865b517607a --- /dev/null +++ b/spec/fixtures/api/first-party-sets/base/main.js @@ -0,0 +1,20 @@ +const { app } = require('electron'); + +const sets = [ + 'https://fps-member1.glitch.me', + 'https://fps-member2.glitch.me', + 'https://fps-member3.glitch.me' +]; + +app.commandLine.appendSwitch('use-first-party-set', sets.join(',')); + +app.whenReady().then(function () { + const hasSwitch = app.commandLine.hasSwitch('use-first-party-set'); + const value = app.commandLine.getSwitchValue('use-first-party-set'); + if (hasSwitch) { + process.stdout.write(JSON.stringify(value)); + process.stdout.end(); + } + + app.quit(); +}); diff --git a/spec/fixtures/api/first-party-sets/base/package.json b/spec/fixtures/api/first-party-sets/base/package.json new file mode 100644 index 0000000000000..1766d06684600 --- /dev/null +++ b/spec/fixtures/api/first-party-sets/base/package.json @@ -0,0 +1,4 @@ +{ + "name": "electron-test-first-party-sets-base", + "main": "main.js" +} diff --git a/spec/fixtures/api/first-party-sets/command-line/main.js b/spec/fixtures/api/first-party-sets/command-line/main.js new file mode 100644 index 0000000000000..8e2782f31dc0e --- /dev/null +++ b/spec/fixtures/api/first-party-sets/command-line/main.js @@ -0,0 +1,12 @@ +const { app } = require('electron'); + +app.whenReady().then(function () { + const hasSwitch = app.commandLine.hasSwitch('use-first-party-set'); + const value = app.commandLine.getSwitchValue('use-first-party-set'); + if (hasSwitch) { + process.stdout.write(JSON.stringify(value)); + process.stdout.end(); + } + + app.quit(); +}); diff --git a/spec/fixtures/api/first-party-sets/command-line/package.json b/spec/fixtures/api/first-party-sets/command-line/package.json new file mode 100644 index 0000000000000..c4b5839bdcc60 --- /dev/null +++ b/spec/fixtures/api/first-party-sets/command-line/package.json @@ -0,0 +1,4 @@ +{ + "name": "electron-test-first-party-sets-command-line", + "main": "main.js" +}