test: use new uuid for each ServiceWorker test (#27444)
This commit is contained in:
parent
70190ec2b1
commit
9baca911a1
1 changed files with 10 additions and 16 deletions
|
@ -1,26 +1,27 @@
|
||||||
import * as fs from 'fs';
|
import * as fs from 'fs';
|
||||||
import * as http from 'http';
|
import * as http from 'http';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import { session, BrowserWindow } from 'electron/main';
|
import { session, webContents, WebContents } from 'electron/main';
|
||||||
import { expect } from 'chai';
|
import { expect } from 'chai';
|
||||||
import { v4 } from 'uuid';
|
import { v4 } from 'uuid';
|
||||||
import { AddressInfo } from 'net';
|
import { AddressInfo } from 'net';
|
||||||
import { closeWindow } from './window-helpers';
|
|
||||||
import { emittedOnce, emittedNTimes } from './events-helpers';
|
import { emittedOnce, emittedNTimes } from './events-helpers';
|
||||||
import { ifdescribe } from './spec-helpers';
|
|
||||||
|
|
||||||
const partition = 'service-workers-spec';
|
const partition = 'service-workers-spec';
|
||||||
const uuid = v4();
|
|
||||||
|
|
||||||
describe('session.serviceWorkers', () => {
|
describe('session.serviceWorkers', () => {
|
||||||
let ses: Electron.Session;
|
let ses: Electron.Session;
|
||||||
let server: http.Server;
|
let server: http.Server;
|
||||||
let baseUrl: string;
|
let baseUrl: string;
|
||||||
let w: BrowserWindow;
|
let w: WebContents = null as unknown as WebContents;
|
||||||
|
|
||||||
before(async () => {
|
before(async () => {
|
||||||
ses = session.fromPartition(partition);
|
ses = session.fromPartition(partition);
|
||||||
await ses.clearStorageData();
|
await ses.clearStorageData();
|
||||||
|
});
|
||||||
|
|
||||||
|
beforeEach(async () => {
|
||||||
|
const uuid = v4();
|
||||||
|
|
||||||
server = http.createServer((req, res) => {
|
server = http.createServer((req, res) => {
|
||||||
// /{uuid}/{file}
|
// /{uuid}/{file}
|
||||||
|
@ -37,20 +38,14 @@ describe('session.serviceWorkers', () => {
|
||||||
resolve();
|
resolve();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
|
||||||
beforeEach(() => {
|
w = (webContents as any).create({ session: ses });
|
||||||
w = new BrowserWindow({ show: false, webPreferences: { session: ses } });
|
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(async () => {
|
afterEach(async () => {
|
||||||
await ses.clearStorageData();
|
(w as any).destroy();
|
||||||
await closeWindow(w);
|
|
||||||
w = null as any;
|
|
||||||
});
|
|
||||||
|
|
||||||
after(async () => {
|
|
||||||
server.close();
|
server.close();
|
||||||
|
await ses.clearStorageData();
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('getAllRunning()', () => {
|
describe('getAllRunning()', () => {
|
||||||
|
@ -66,8 +61,7 @@ describe('session.serviceWorkers', () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// TODO (jkleinsc) - reenable this test once https://github.com/electron/electron/issues/26043 is resolved
|
describe('getFromVersionID()', () => {
|
||||||
ifdescribe(!process.arch.includes('arm'))('getFromVersionID()', () => {
|
|
||||||
it('should report the correct script url and scope', async () => {
|
it('should report the correct script url and scope', async () => {
|
||||||
const eventInfo = await emittedOnce(ses.serviceWorkers, 'console-message', () => w.loadURL(`${baseUrl}/index.html`));
|
const eventInfo = await emittedOnce(ses.serviceWorkers, 'console-message', () => w.loadURL(`${baseUrl}/index.html`));
|
||||||
const details: Electron.MessageDetails = eventInfo[1];
|
const details: Electron.MessageDetails = eventInfo[1];
|
||||||
|
|
Loading…
Reference in a new issue