test: worker should be able to load asar files (#28858)

This commit is contained in:
Cheng Zhao 2021-04-28 01:07:05 +09:00 committed by GitHub
parent 72092c2312
commit b97b973306
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 58 additions and 0 deletions

View file

@ -1,5 +1,6 @@
import { expect } from 'chai';
import * as path from 'path';
import * as url from 'url';
import { BrowserWindow, ipcMain } from 'electron/main';
import { closeAllWindows } from './window-helpers';
import { emittedOnce } from './events-helpers';
@ -79,4 +80,32 @@ describe('asar package', () => {
}
});
});
describe('worker', () => {
it('Worker can load asar file', async () => {
const w = new BrowserWindow({ show: false });
await w.loadFile(path.join(fixtures, 'workers', 'load_worker.html'));
const workerUrl = url.format({
pathname: path.resolve(fixtures, 'workers', 'workers.asar', 'worker.js').replace(/\\/g, '/'),
protocol: 'file',
slashes: true
});
const result = await w.webContents.executeJavaScript(`loadWorker('${workerUrl}')`);
expect(result).to.equal('success');
});
it('SharedWorker can load asar file', async () => {
const w = new BrowserWindow({ show: false });
await w.loadFile(path.join(fixtures, 'workers', 'load_shared_worker.html'));
const workerUrl = url.format({
pathname: path.resolve(fixtures, 'workers', 'workers.asar', 'shared_worker.js').replace(/\\/g, '/'),
protocol: 'file',
slashes: true
});
const result = await w.webContents.executeJavaScript(`loadSharedWorker('${workerUrl}')`);
expect(result).to.equal('success');
});
});
});