"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "spec-main/api-protocol-spec.ts" between
electron-11.4.1.tar.gz and electron-11.4.2.tar.gz

About: Electron is a framework for creating native cross platform applications with web technologies like JavaScript, HTML, and CSS.

api-protocol-spec.ts  (electron-11.4.1):api-protocol-spec.ts  (electron-11.4.2)
import { expect } from 'chai'; import { expect } from 'chai';
import { v4 } from 'uuid';
import { protocol, webContents, WebContents, session, BrowserWindow, ipcMain } f rom 'electron/main'; import { protocol, webContents, WebContents, session, BrowserWindow, ipcMain } f rom 'electron/main';
import { AddressInfo } from 'net'; import { AddressInfo } from 'net';
import * as ChildProcess from 'child_process'; import * as ChildProcess from 'child_process';
import * as path from 'path'; import * as path from 'path';
import * as http from 'http'; import * as http from 'http';
import * as fs from 'fs'; import * as fs from 'fs';
import * as qs from 'querystring'; import * as qs from 'querystring';
import * as stream from 'stream'; import * as stream from 'stream';
import { EventEmitter } from 'events'; import { EventEmitter } from 'events';
import { closeWindow } from './window-helpers'; import { closeWindow } from './window-helpers';
skipping to change at line 706 skipping to change at line 707
console.log('Exit code : ', code); console.log('Exit code : ', code);
console.log('stdout : ', stdout); console.log('stdout : ', stdout);
console.log('stderr : ', stderr); console.log('stderr : ', stderr);
} }
expect(code).to.equal(0); expect(code).to.equal(0);
expect(stdout).to.not.contain('VALIDATION_ERROR_DESERIALIZATION_FAILED'); expect(stdout).to.not.contain('VALIDATION_ERROR_DESERIALIZATION_FAILED');
expect(stderr).to.not.contain('VALIDATION_ERROR_DESERIALIZATION_FAILED'); expect(stderr).to.not.contain('VALIDATION_ERROR_DESERIALIZATION_FAILED');
}); });
}); });
describe('protocol.registerSchemesAsPrivileged allowServiceWorkers', () => {
const { serviceWorkerScheme } = global as any;
protocol.registerStringProtocol(serviceWorkerScheme, (request, cb) => {
if (request.url.endsWith('.js')) {
cb({
mimeType: 'text/javascript',
charset: 'utf-8',
data: 'console.log("Loaded")'
});
} else {
cb({
mimeType: 'text/html',
charset: 'utf-8',
data: '<!DOCTYPE html>'
});
}
});
after(() => protocol.unregisterProtocol(serviceWorkerScheme));
it('should fail when registering invalid service worker', async () => {
await contents.loadURL(`${serviceWorkerScheme}://${v4()}.com`);
const wait = emittedOnce(contents, 'console-message');
await contents.executeJavaScript(`navigator.serviceWorker.register('${v4()
}.notjs', {scope: './'}).then(() => console.log('ok')).catch(() => console.log('
error'))`);
const [,, msg] = await wait;
expect(msg).to.equal('error');
});
it('should be able to register service worker for custom scheme', async () =
> {
await contents.loadURL(`${serviceWorkerScheme}://${v4()}.com`);
const wait = emittedOnce(contents, 'console-message');
await contents.executeJavaScript(`navigator.serviceWorker.register('${v4()
}.js', {scope: './'}).then(() => console.log('ok')).catch(() => console.log('err
or'))`);
const [,, msg] = await wait;
expect(msg).to.equal('ok');
});
});
describe.skip('protocol.registerSchemesAsPrivileged standard', () => { describe.skip('protocol.registerSchemesAsPrivileged standard', () => {
const standardScheme = (global as any).standardScheme; const standardScheme = (global as any).standardScheme;
const origin = `${standardScheme}://fake-host`; const origin = `${standardScheme}://fake-host`;
const imageURL = `${origin}/test.png`; const imageURL = `${origin}/test.png`;
const filePath = path.join(fixturesPath, 'pages', 'b.html'); const filePath = path.join(fixturesPath, 'pages', 'b.html');
const fileContent = '<img src="/test.png" />'; const fileContent = '<img src="/test.png" />';
let w: BrowserWindow = null as unknown as BrowserWindow; let w: BrowserWindow = null as unknown as BrowserWindow;
beforeEach(() => { beforeEach(() => {
w = new BrowserWindow({ w = new BrowserWindow({
 End of changes. 2 change blocks. 
0 lines changed or deleted 42 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)