|
@@ -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');
|
|
|
+ });
|
|
|
+ });
|
|
|
});
|