electron/spec/chromium-spec.js

525 lines
19 KiB
JavaScript
Raw Normal View History

2020-03-20 20:28:31 +00:00
const { expect } = require('chai');
const fs = require('fs');
const http = require('http');
const path = require('path');
const ws = require('ws');
const url = require('url');
const ChildProcess = require('child_process');
const { ipcRenderer } = require('electron');
const { emittedOnce, waitForEvent } = require('./events-helpers');
2020-03-20 20:28:31 +00:00
const { resolveGetters } = require('./expect-helpers');
const { ifit, ifdescribe, delay } = require('./spec-helpers');
const features = process._linkedBinding('electron_common_features');
2017-11-23 22:22:43 +00:00
/* Most of the APIs here don't use standard callbacks */
/* eslint-disable standard/no-callback-literal */
2017-11-13 20:13:19 +00:00
describe('chromium feature', () => {
2020-03-20 20:28:31 +00:00
const fixtures = path.resolve(__dirname, 'fixtures');
2016-03-25 20:03:49 +00:00
describe('Badging API', () => {
it('does not crash', () => {
expect(() => {
navigator.setAppBadge(42);
}).to.not.throw();
expect(() => {
// setAppBadge with no argument should show dot
navigator.setAppBadge();
}).to.not.throw();
expect(() => {
navigator.clearAppBadge();
}).to.not.throw();
});
});
2017-11-13 20:13:19 +00:00
describe('heap snapshot', () => {
it('does not crash', function () {
process._linkedBinding('electron_common_v8_util').takeHeapSnapshot();
2020-03-20 20:28:31 +00:00
});
});
2016-03-25 20:03:49 +00:00
2017-11-13 20:13:19 +00:00
describe('navigator.webkitGetUserMedia', () => {
it('calls its callbacks', (done) => {
2016-02-17 01:39:11 +00:00
navigator.webkitGetUserMedia({
2016-01-12 02:40:23 +00:00
audio: true,
video: false
2017-11-13 20:13:19 +00:00
}, () => done(),
2020-03-20 20:28:31 +00:00
() => done());
});
});
2016-03-25 20:03:49 +00:00
2017-11-13 20:13:19 +00:00
describe('navigator.language', () => {
it('should not be empty', () => {
2020-03-20 20:28:31 +00:00
expect(navigator.language).to.not.equal('');
});
});
2016-03-25 20:03:49 +00:00
ifdescribe(features.isFakeLocationProviderEnabled())('navigator.geolocation', () => {
it('returns position when permission is granted', async () => {
const position = await new Promise((resolve, reject) => navigator.geolocation.getCurrentPosition(resolve, reject));
expect(position).to.have.a.property('coords');
expect(position).to.have.a.property('timestamp');
2020-03-20 20:28:31 +00:00
});
});
2017-11-13 20:13:19 +00:00
describe('window.open', () => {
it('accepts "nodeIntegration" as feature', async () => {
const message = waitForEvent(window, 'message');
const b = window.open(`file://${fixtures}/pages/window-opener-node.html`, '', 'nodeIntegration=no,show=no');
const event = await message;
b.close();
expect(event.data.isProcessGlobalUndefined).to.be.true();
2020-03-20 20:28:31 +00:00
});
2016-03-25 20:03:49 +00:00
it('inherit options of parent window', async () => {
const message = waitForEvent(window, 'message');
const b = window.open(`file://${fixtures}/pages/window-open-size.html`, '', 'show=no');
const event = await message;
b.close();
const width = outerWidth;
const height = outerHeight;
expect(event.data).to.equal(`size: ${width} ${height}`);
2020-03-20 20:28:31 +00:00
});
2016-03-25 20:03:49 +00:00
// FIXME(zcbenz): This test is making the spec runner hang on exit on Windows.
ifit(process.platform !== 'win32')('disables node integration when it is disabled on the parent window', async () => {
2017-11-13 20:13:19 +00:00
const windowUrl = require('url').format({
2016-03-24 00:40:25 +00:00
pathname: `${fixtures}/pages/window-opener-no-node-integration.html`,
protocol: 'file',
query: {
2016-03-24 00:40:25 +00:00
p: `${fixtures}/pages/window-opener-node.html`
},
slashes: true
2020-03-20 20:28:31 +00:00
});
const message = waitForEvent(window, 'message');
const b = window.open(windowUrl, '', 'nodeIntegration=no,contextIsolation=no,show=no');
const event = await message;
b.close();
expect(event.data.isProcessGlobalUndefined).to.be.true();
2020-03-20 20:28:31 +00:00
});
it('disables the <webview> tag when it is disabled on the parent window', async () => {
2017-11-13 20:13:19 +00:00
const windowUrl = require('url').format({
pathname: `${fixtures}/pages/window-opener-no-webview-tag.html`,
protocol: 'file',
query: {
p: `${fixtures}/pages/window-opener-webview.html`
},
slashes: true
2020-03-20 20:28:31 +00:00
});
const message = waitForEvent(window, 'message');
const b = window.open(windowUrl, '', 'webviewTag=no,contextIsolation=no,nodeIntegration=yes,show=no');
const event = await message;
b.close();
expect(event.data.isWebViewGlobalUndefined).to.be.true();
2020-03-20 20:28:31 +00:00
});
it('does not override child options', async () => {
2017-11-13 20:13:19 +00:00
const size = {
2016-01-12 02:40:23 +00:00
width: 350,
height: 450
2020-03-20 20:28:31 +00:00
};
const message = waitForEvent(window, 'message');
const b = window.open(`file://${fixtures}/pages/window-open-size.html`, '', 'show=no,width=' + size.width + ',height=' + size.height);
const event = await message;
b.close();
expect(event.data).to.equal(`size: ${size.width} ${size.height}`);
2020-03-20 20:28:31 +00:00
});
2016-03-25 20:03:49 +00:00
2017-11-13 20:13:19 +00:00
it('throws an exception when the arguments cannot be converted to strings', () => {
expect(() => {
2020-03-20 20:28:31 +00:00
window.open('', { toString: null });
}).to.throw('Cannot convert object to primitive value');
expect(() => {
2020-03-20 20:28:31 +00:00
window.open('', '', { toString: 3 });
}).to.throw('Cannot convert object to primitive value');
});
2017-11-13 20:13:19 +00:00
it('does not throw an exception when the features include webPreferences', () => {
2020-03-20 20:28:31 +00:00
let b = null;
expect(() => {
2020-03-20 20:28:31 +00:00
b = window.open('', '', 'webPreferences=');
}).to.not.throw();
b.close();
});
});
2017-11-13 20:13:19 +00:00
describe('window.opener', () => {
it('is not null for window opened by window.open', async () => {
const message = waitForEvent(window, 'message');
const b = window.open(`file://${fixtures}/pages/window-opener.html`, '', 'show=no');
const event = await message;
b.close();
expect(event.data).to.equal('object');
2020-03-20 20:28:31 +00:00
});
});
2016-03-25 20:03:49 +00:00
2017-11-13 20:13:19 +00:00
describe('window.opener.postMessage', () => {
it('sets source and origin correctly', async () => {
const message = waitForEvent(window, 'message');
const b = window.open(`file://${fixtures}/pages/window-opener-postMessage.html`, '', 'show=no');
const event = await message;
try {
expect(event.source).to.deep.equal(b);
2020-03-20 20:28:31 +00:00
expect(event.origin).to.equal('file://');
} finally {
b.close();
}
2020-03-20 20:28:31 +00:00
});
it('supports windows opened from a <webview>', async () => {
2020-03-20 20:28:31 +00:00
const webview = new WebView();
const consoleMessage = waitForEvent(webview, 'console-message');
2020-03-20 20:28:31 +00:00
webview.allowpopups = true;
webview.setAttribute('webpreferences', 'contextIsolation=no');
webview.src = url.format({
pathname: `${fixtures}/pages/webview-opener-postMessage.html`,
protocol: 'file',
query: {
p: `${fixtures}/pages/window-opener-postMessage.html`
},
slashes: true
2020-03-20 20:28:31 +00:00
});
document.body.appendChild(webview);
const event = await consoleMessage;
webview.remove();
expect(event.message).to.equal('message');
2020-03-20 20:28:31 +00:00
});
2017-11-13 20:13:19 +00:00
describe('targetOrigin argument', () => {
2020-03-20 20:28:31 +00:00
let serverURL;
let server;
2017-11-13 20:13:19 +00:00
beforeEach((done) => {
server = http.createServer((req, res) => {
2020-03-20 20:28:31 +00:00
res.writeHead(200);
const filePath = path.join(fixtures, 'pages', 'window-opener-targetOrigin.html');
res.end(fs.readFileSync(filePath, 'utf8'));
});
2017-11-13 20:13:19 +00:00
server.listen(0, '127.0.0.1', () => {
2020-03-20 20:28:31 +00:00
serverURL = `http://127.0.0.1:${server.address().port}`;
done();
});
});
2017-11-13 20:13:19 +00:00
afterEach(() => {
2020-03-20 20:28:31 +00:00
server.close();
});
it('delivers messages that match the origin', async () => {
const message = waitForEvent(window, 'message');
const b = window.open(serverURL, '', 'show=no,contextIsolation=no,nodeIntegration=yes');
const event = await message;
b.close();
expect(event.data).to.equal('deliver');
2020-03-20 20:28:31 +00:00
});
});
});
2016-03-25 20:03:49 +00:00
2017-11-13 20:13:19 +00:00
describe('webgl', () => {
before(function () {
if (process.platform === 'win32') {
2020-03-20 20:28:31 +00:00
this.skip();
}
2020-03-20 20:28:31 +00:00
});
2016-04-30 09:21:18 +00:00
2017-11-13 20:13:19 +00:00
it('can be get as context in canvas', () => {
if (process.platform === 'linux') {
// FIXME(alexeykuzmin): Skip the test.
// this.skip()
2020-03-20 20:28:31 +00:00
return;
}
2016-03-28 23:11:00 +00:00
2020-03-20 20:28:31 +00:00
const webgl = document.createElement('canvas').getContext('webgl');
expect(webgl).to.not.be.null();
});
});
2016-03-25 20:03:49 +00:00
2017-11-13 20:13:19 +00:00
describe('web workers', () => {
it('Worker can work', async () => {
2020-03-20 20:28:31 +00:00
const worker = new Worker('../fixtures/workers/worker.js');
const message = 'ping';
const eventPromise = new Promise((resolve) => { worker.onmessage = resolve; });
2020-03-20 20:28:31 +00:00
worker.postMessage(message);
const event = await eventPromise;
worker.terminate();
expect(event.data).to.equal(message);
2020-03-20 20:28:31 +00:00
});
2016-03-25 20:03:49 +00:00
it('Worker has no node integration by default', async () => {
2020-03-20 20:28:31 +00:00
const worker = new Worker('../fixtures/workers/worker_node.js');
const event = await new Promise((resolve) => { worker.onmessage = resolve; });
worker.terminate();
expect(event.data).to.equal('undefined undefined undefined undefined');
2020-03-20 20:28:31 +00:00
});
2017-03-15 11:07:28 +00:00
it('Worker has node integration with nodeIntegrationInWorker', async () => {
2020-03-20 20:28:31 +00:00
const webview = new WebView();
const eventPromise = waitForEvent(webview, 'ipc-message');
2020-03-20 20:28:31 +00:00
webview.src = `file://${fixtures}/pages/worker.html`;
webview.setAttribute('webpreferences', 'nodeIntegration, nodeIntegrationInWorker, contextIsolation=no');
2020-03-20 20:28:31 +00:00
document.body.appendChild(webview);
const event = await eventPromise;
webview.remove();
expect(event.channel).to.equal('object function object function');
2020-03-20 20:28:31 +00:00
});
2017-03-15 11:07:28 +00:00
describe('SharedWorker', () => {
it('can work', async () => {
2020-03-20 20:28:31 +00:00
const worker = new SharedWorker('../fixtures/workers/shared_worker.js');
const message = 'ping';
const eventPromise = new Promise((resolve) => { worker.port.onmessage = resolve; });
2020-03-20 20:28:31 +00:00
worker.port.postMessage(message);
const event = await eventPromise;
expect(event.data).to.equal(message);
2020-03-20 20:28:31 +00:00
});
2017-03-15 11:07:28 +00:00
it('has no node integration by default', async () => {
2020-03-20 20:28:31 +00:00
const worker = new SharedWorker('../fixtures/workers/shared_worker_node.js');
const event = await new Promise((resolve) => { worker.port.onmessage = resolve; });
expect(event.data).to.equal('undefined undefined undefined undefined');
2020-03-20 20:28:31 +00:00
});
chore: bump chromium to f1d9522c04ca8fa0a906f88ababe9 (master) (#18648) * chore: bump chromium in DEPS to 675d7dc9f3334b15c3ec28c27db3dc19b26bd12e * chore: update patches * chore: bump chromium in DEPS to dce3562696f165a324273fcb6893f0e1fef42ab1 * chore: const interfaces are being removed from //content Refs: https://chromium-review.googlesource.com/c/chromium/src/+/1631749 Bug: https://bugs.chromium.org/p/chromium/issues/detail?id=908139 * chore: update patches * chore: blink::MediaStreamType is now consistent and deduplicated * chore: update patches and printing code for ref -> uniq * chore: bridge_impl() --> GetInProcessNSWindowBridge Refs: https://chromium-review.googlesource.com/c/chromium/src/+/1642988 * fixme: TotalMarkedObjectSize has been removed * chore: fix linting * chore: bump chromium in DEPS to 9503e1a2fcbf17db08094d8caae3e1407e918af3 * chore: fix slightly broken printing patch * chore: update patches for SiteInstanceImpl changes Refs: https://chromium-review.googlesource.com/c/chromium/src/+/1612025 * chore: update patches for SiteInstanceImpl changes * chore: bump chromium in DEPS to 6801e6c1ddd1b7b73e594e97157ddd539ca335d7 * chore: update patches * chore: bump chromium in DEPS to 27e198912d7c1767052ec785c22e2e88b2cb4d8b * chore: remove system_request_context Refs: https://chromium-review.googlesource.com/c/chromium/src/+/1647172 * chore: creation of FtpProtocolHandler needs an auth cache Refs: https://chromium-review.googlesource.com/c/chromium/src/+/1639683 * fixme: disable marked spec * chore: bump chromium in DEPS to 3dcd7fe453ad13a22b114b95f05590eba74c5471 * chore: bump chromium in DEPS to bdc24128b75008743d819e298557a53205706e7c * chore: bump chromium in DEPS to 7da330b58fbe0ba94b9b94abbb8085bead220228 * update patches * remove TotalMarkedObjectSize https://chromium-review.googlesource.com/c/chromium/src/+/1631708 * add libvulkan.so to dist zip manifest on linux * chore: bump chromium in DEPS to 1e85d0f45b52649efd0010cc9dab6d2804f24443 * update patches * add angle features to gpuinfo https://chromium-review.googlesource.com/c/chromium/src/+/1638658 * mark 'marked' property as deprecated * disable webview resize test * FIXME: disable vulkan on 32-bit arm * chore: bump chromium in DEPS to cd0297c6a83fdd2b1f6bc312e7d5acca736a3c56 * Revert "FIXME: disable vulkan on 32-bit arm" This reverts commit 5c1e0ef302a6db1e72231d4e823f91bb08e281af. * backport from upstream: fix swiftshader build on arm https://swiftshader-review.googlesource.com/c/SwiftShader/+/32768/ * update patches * viz: update OutputDeviceWin to new shared memory api https://chromium-review.googlesource.com/c/chromium/src/+/1649574 * base::Contains{Key,Value} => base::Contains https://chromium-review.googlesource.com/c/chromium/src/+/1649478 * fixup! viz: update OutputDeviceWin to new shared memory api * stub out StatusIconLinuxDbus-related delegate methods https://chromium-review.googlesource.com/c/chromium/src/+/1638180 * chore: bump chromium in DEPS to 964ea3fd4bdc006d62533f5755043076220181f1 * Remove the BrowserContext methods to create URLRequestContexts for main/media partitions when a partition_domain is specified https://chromium-review.googlesource.com/c/chromium/src/+/1655087 * fixup! stub out StatusIconLinuxDbus-related delegate methods * add remote_cocoa to chromium_src deps https://chromium-review.googlesource.com/c/chromium/src/+/1657068 * fixup! stub out StatusIconLinuxDbus-related delegate methods * attempt at fix linux-debug build * add swiftshader/libvulkan.so to arm manifest * chore: bump chromium in DEPS to 28688f76afef27c36631aa274691e333ddecdc22 * update patches * chore: bump chromium in DEPS to fe7450e1578a9584189f87d59d0d1a8548bf6b90 * chore: bump chromium in DEPS to f304dfd682dc86a755a6c49a16ee6876e0db45fb * chore: bump chromium in DEPS to f0fd4d6c365aad9edd83bdfff9954c47d271b75c * Update patches * Remove no longer needed WOA patch * Put back IOThread in BrowserProcess We need this until we enable the network service. * move atom.ico to inputs * Update to latest LKGR to fix no template named 'bitset' in namespace 'std' * fixup! Put back IOThread in BrowserProcess * chore: bump chromium in DEPS to dcf9662dc9a896a175d791001350324167b1cad3 * Update patches content_allow_embedder_to_prevent_locking_scheme_registry.patch is no longer necessary as it was upstreamed via https://chromium-review.googlesource.com/c/chromium/src/+/1637040 * Fix renamed enum * Use newer docker container Contains updated dependencies * Try to track down arm test failures * Fix arm tests * chore: bump chromium in DEPS to 8cbceef57b37ee14b9c4c3405a3f7663922c5b5d * Update patches * Add needed dependencies for testing 32-bit linux * Remove arm debugging. * Remove additional debugging * Fix compiler errors * Handle new macOS helper * Fix compile error on Linux * chore: bump chromium in DEPS to 66a93991ddaff6a9f1b13d110959947cb03a1860 * Add new helper files to manifests * fix BUILD.gn for macOS * Fix compile errors * Add patch to put back colors needed for autofill/datalist * chore: bump chromium in DEPS to e89617079f11e33f33cdb3924f719a579c73704b * Updated patches * Remove no longer needed patch * Remove no longer needed patch * Fix compile error with patch * Really fix the patch * chore: bump chromium in DEPS to c70f12476a45840408f1d5ff5968e7f7ceaad9d4 * chore: bump chromium in DEPS to 06d2dd7a8933b41545a7c26349c802f570563fd5 * chore: bump chromium in DEPS to b0b9ff8f727deb519ccbec7cf1c8d9ed543d88ab * Update patches * Fix compiler errors * Fix removed ChromeNetLog * Revert "Fix removed ChromeNetLog" This reverts commit 426dfd90b5ab0a9c1df415d71c88e8aed2bd5bbe. * Remove ChromeNetLog. https://chromium-review.googlesource.com/c/chromium/src/+/1663846 * chore: bump chromium in DEPS to fefcc4926d58dccd59ac95be65eab3a4ebfe2f29 * Update patches * Update v8 patches * Fix lint error * Fix compile errors * chore: bump chromium in DEPS to 4de815ef92ef2eef515506fe09bdc466526a8fd9 * Use custom protocol to test baseURLForDataURL * Use newer SDK (10.0.18362) for Windows * Update patches * Update arm manifest since swiftshader reenabled. * Don't delete dir that isn't ever there. * Fix compile errors. * Need src dir created * Update for removed InspectorFrontendAPI.addExtensions * Revert "Use newer SDK (10.0.18362) for Windows" This reverts commit 68763a0c88cdc44b971462e49662aecc167d3d99. * Revert "Need src dir created" This reverts commit 7daedc29d0844316d4097648dde7f40f1a3848fb. * Revert "Don't delete dir that isn't ever there." This reverts commit bf424bc30ffcb23b1d9a634d4df410342536640e. * chore: bump chromium in DEPS to 97dab6b0124ea53244caf123921b5d14893bcca7 * chore: bump chromium in DEPS to c87d16d49a85dc7122781f6c979d354c20f7f78b * chore: bump chromium in DEPS to 004bcee2ea336687cedfda8f8a151806ac757d15 * chore: bump chromium in DEPS to 24428b26a9d15a013b2a253e1084ec3cb54b660b * chore: bump chromium in DEPS to fd25914e875237df88035a6abf89a70bf1360b57 * Update patches * Update node to fix build error * Fix compile errors * chore: bump chromium in DEPS to 3062b7cf090f1d9522c04ca8fa0a906f88ababe9 * chore: update node ref for pushed tags * chore: update patches for new chromium * chore: fix printing patches * Use new (10.0.18362) Windows SDK * roll node to fix v8 build issues in debug build * Add support for plugin helper * fix: add patch to fix gpu info enumeration Can be removed once CL lands upstream. Refs: https://chromium-review.googlesource.com/c/chromium/src/+/1685993 * spec: navigator.requestMIDIAccess now requires a secure origin This test requires a secure origin so we fake one. Refs: https://chromium-review.googlesource.com/c/chromium/src/+/1657952 * FIXME: temporarily disable SharedWorker tests * use released version of node-abstractsocket * fix abstract-socket
2019-07-03 01:22:09 +00:00
// FIXME: disabled during chromium update due to crash in content::WorkerScriptFetchInitiator::CreateScriptLoaderOnIO
xit('has node integration with nodeIntegrationInWorker', async () => {
2020-03-20 20:28:31 +00:00
const webview = new WebView();
chore: bump chromium to f1d9522c04ca8fa0a906f88ababe9 (master) (#18648) * chore: bump chromium in DEPS to 675d7dc9f3334b15c3ec28c27db3dc19b26bd12e * chore: update patches * chore: bump chromium in DEPS to dce3562696f165a324273fcb6893f0e1fef42ab1 * chore: const interfaces are being removed from //content Refs: https://chromium-review.googlesource.com/c/chromium/src/+/1631749 Bug: https://bugs.chromium.org/p/chromium/issues/detail?id=908139 * chore: update patches * chore: blink::MediaStreamType is now consistent and deduplicated * chore: update patches and printing code for ref -> uniq * chore: bridge_impl() --> GetInProcessNSWindowBridge Refs: https://chromium-review.googlesource.com/c/chromium/src/+/1642988 * fixme: TotalMarkedObjectSize has been removed * chore: fix linting * chore: bump chromium in DEPS to 9503e1a2fcbf17db08094d8caae3e1407e918af3 * chore: fix slightly broken printing patch * chore: update patches for SiteInstanceImpl changes Refs: https://chromium-review.googlesource.com/c/chromium/src/+/1612025 * chore: update patches for SiteInstanceImpl changes * chore: bump chromium in DEPS to 6801e6c1ddd1b7b73e594e97157ddd539ca335d7 * chore: update patches * chore: bump chromium in DEPS to 27e198912d7c1767052ec785c22e2e88b2cb4d8b * chore: remove system_request_context Refs: https://chromium-review.googlesource.com/c/chromium/src/+/1647172 * chore: creation of FtpProtocolHandler needs an auth cache Refs: https://chromium-review.googlesource.com/c/chromium/src/+/1639683 * fixme: disable marked spec * chore: bump chromium in DEPS to 3dcd7fe453ad13a22b114b95f05590eba74c5471 * chore: bump chromium in DEPS to bdc24128b75008743d819e298557a53205706e7c * chore: bump chromium in DEPS to 7da330b58fbe0ba94b9b94abbb8085bead220228 * update patches * remove TotalMarkedObjectSize https://chromium-review.googlesource.com/c/chromium/src/+/1631708 * add libvulkan.so to dist zip manifest on linux * chore: bump chromium in DEPS to 1e85d0f45b52649efd0010cc9dab6d2804f24443 * update patches * add angle features to gpuinfo https://chromium-review.googlesource.com/c/chromium/src/+/1638658 * mark 'marked' property as deprecated * disable webview resize test * FIXME: disable vulkan on 32-bit arm * chore: bump chromium in DEPS to cd0297c6a83fdd2b1f6bc312e7d5acca736a3c56 * Revert "FIXME: disable vulkan on 32-bit arm" This reverts commit 5c1e0ef302a6db1e72231d4e823f91bb08e281af. * backport from upstream: fix swiftshader build on arm https://swiftshader-review.googlesource.com/c/SwiftShader/+/32768/ * update patches * viz: update OutputDeviceWin to new shared memory api https://chromium-review.googlesource.com/c/chromium/src/+/1649574 * base::Contains{Key,Value} => base::Contains https://chromium-review.googlesource.com/c/chromium/src/+/1649478 * fixup! viz: update OutputDeviceWin to new shared memory api * stub out StatusIconLinuxDbus-related delegate methods https://chromium-review.googlesource.com/c/chromium/src/+/1638180 * chore: bump chromium in DEPS to 964ea3fd4bdc006d62533f5755043076220181f1 * Remove the BrowserContext methods to create URLRequestContexts for main/media partitions when a partition_domain is specified https://chromium-review.googlesource.com/c/chromium/src/+/1655087 * fixup! stub out StatusIconLinuxDbus-related delegate methods * add remote_cocoa to chromium_src deps https://chromium-review.googlesource.com/c/chromium/src/+/1657068 * fixup! stub out StatusIconLinuxDbus-related delegate methods * attempt at fix linux-debug build * add swiftshader/libvulkan.so to arm manifest * chore: bump chromium in DEPS to 28688f76afef27c36631aa274691e333ddecdc22 * update patches * chore: bump chromium in DEPS to fe7450e1578a9584189f87d59d0d1a8548bf6b90 * chore: bump chromium in DEPS to f304dfd682dc86a755a6c49a16ee6876e0db45fb * chore: bump chromium in DEPS to f0fd4d6c365aad9edd83bdfff9954c47d271b75c * Update patches * Remove no longer needed WOA patch * Put back IOThread in BrowserProcess We need this until we enable the network service. * move atom.ico to inputs * Update to latest LKGR to fix no template named 'bitset' in namespace 'std' * fixup! Put back IOThread in BrowserProcess * chore: bump chromium in DEPS to dcf9662dc9a896a175d791001350324167b1cad3 * Update patches content_allow_embedder_to_prevent_locking_scheme_registry.patch is no longer necessary as it was upstreamed via https://chromium-review.googlesource.com/c/chromium/src/+/1637040 * Fix renamed enum * Use newer docker container Contains updated dependencies * Try to track down arm test failures * Fix arm tests * chore: bump chromium in DEPS to 8cbceef57b37ee14b9c4c3405a3f7663922c5b5d * Update patches * Add needed dependencies for testing 32-bit linux * Remove arm debugging. * Remove additional debugging * Fix compiler errors * Handle new macOS helper * Fix compile error on Linux * chore: bump chromium in DEPS to 66a93991ddaff6a9f1b13d110959947cb03a1860 * Add new helper files to manifests * fix BUILD.gn for macOS * Fix compile errors * Add patch to put back colors needed for autofill/datalist * chore: bump chromium in DEPS to e89617079f11e33f33cdb3924f719a579c73704b * Updated patches * Remove no longer needed patch * Remove no longer needed patch * Fix compile error with patch * Really fix the patch * chore: bump chromium in DEPS to c70f12476a45840408f1d5ff5968e7f7ceaad9d4 * chore: bump chromium in DEPS to 06d2dd7a8933b41545a7c26349c802f570563fd5 * chore: bump chromium in DEPS to b0b9ff8f727deb519ccbec7cf1c8d9ed543d88ab * Update patches * Fix compiler errors * Fix removed ChromeNetLog * Revert "Fix removed ChromeNetLog" This reverts commit 426dfd90b5ab0a9c1df415d71c88e8aed2bd5bbe. * Remove ChromeNetLog. https://chromium-review.googlesource.com/c/chromium/src/+/1663846 * chore: bump chromium in DEPS to fefcc4926d58dccd59ac95be65eab3a4ebfe2f29 * Update patches * Update v8 patches * Fix lint error * Fix compile errors * chore: bump chromium in DEPS to 4de815ef92ef2eef515506fe09bdc466526a8fd9 * Use custom protocol to test baseURLForDataURL * Use newer SDK (10.0.18362) for Windows * Update patches * Update arm manifest since swiftshader reenabled. * Don't delete dir that isn't ever there. * Fix compile errors. * Need src dir created * Update for removed InspectorFrontendAPI.addExtensions * Revert "Use newer SDK (10.0.18362) for Windows" This reverts commit 68763a0c88cdc44b971462e49662aecc167d3d99. * Revert "Need src dir created" This reverts commit 7daedc29d0844316d4097648dde7f40f1a3848fb. * Revert "Don't delete dir that isn't ever there." This reverts commit bf424bc30ffcb23b1d9a634d4df410342536640e. * chore: bump chromium in DEPS to 97dab6b0124ea53244caf123921b5d14893bcca7 * chore: bump chromium in DEPS to c87d16d49a85dc7122781f6c979d354c20f7f78b * chore: bump chromium in DEPS to 004bcee2ea336687cedfda8f8a151806ac757d15 * chore: bump chromium in DEPS to 24428b26a9d15a013b2a253e1084ec3cb54b660b * chore: bump chromium in DEPS to fd25914e875237df88035a6abf89a70bf1360b57 * Update patches * Update node to fix build error * Fix compile errors * chore: bump chromium in DEPS to 3062b7cf090f1d9522c04ca8fa0a906f88ababe9 * chore: update node ref for pushed tags * chore: update patches for new chromium * chore: fix printing patches * Use new (10.0.18362) Windows SDK * roll node to fix v8 build issues in debug build * Add support for plugin helper * fix: add patch to fix gpu info enumeration Can be removed once CL lands upstream. Refs: https://chromium-review.googlesource.com/c/chromium/src/+/1685993 * spec: navigator.requestMIDIAccess now requires a secure origin This test requires a secure origin so we fake one. Refs: https://chromium-review.googlesource.com/c/chromium/src/+/1657952 * FIXME: temporarily disable SharedWorker tests * use released version of node-abstractsocket * fix abstract-socket
2019-07-03 01:22:09 +00:00
webview.addEventListener('console-message', (e) => {
2020-03-20 20:28:31 +00:00
console.log(e);
});
const eventPromise = waitForEvent(webview, 'ipc-message');
2020-03-20 20:28:31 +00:00
webview.src = `file://${fixtures}/pages/shared_worker.html`;
webview.setAttribute('webpreferences', 'nodeIntegration, nodeIntegrationInWorker');
document.body.appendChild(webview);
const event = await eventPromise;
webview.remove();
expect(event.channel).to.equal('object function object function');
2020-03-20 20:28:31 +00:00
});
});
});
2016-03-25 20:03:49 +00:00
2017-11-13 20:13:19 +00:00
describe('iframe', () => {
2020-03-20 20:28:31 +00:00
let iframe = null;
2016-03-25 20:03:49 +00:00
2017-11-13 20:13:19 +00:00
beforeEach(() => {
2020-03-20 20:28:31 +00:00
iframe = document.createElement('iframe');
});
2016-03-25 20:03:49 +00:00
2017-11-13 20:13:19 +00:00
afterEach(() => {
2020-03-20 20:28:31 +00:00
document.body.removeChild(iframe);
});
2016-03-25 20:03:49 +00:00
it('does not have node integration', async () => {
2020-03-20 20:28:31 +00:00
iframe.src = `file://${fixtures}/pages/set-global.html`;
document.body.appendChild(iframe);
await waitForEvent(iframe, 'load');
expect(iframe.contentWindow.test).to.equal('undefined undefined undefined');
2020-03-20 20:28:31 +00:00
});
});
2016-03-25 20:03:49 +00:00
2017-11-13 20:13:19 +00:00
describe('storage', () => {
describe('DOM storage quota increase', () => {
2018-11-12 17:19:01 +00:00
['localStorage', 'sessionStorage'].forEach((storageName) => {
2020-03-20 20:28:31 +00:00
const storage = window[storageName];
it(`allows saving at least 40MiB in ${storageName}`, async () => {
// Although JavaScript strings use UTF-16, the underlying
// storage provider may encode strings differently, muddling the
// translation between character and byte counts. However,
// a string of 40 * 2^20 characters will require at least 40MiB
// and presumably no more than 80MiB, a size guaranteed to
// to exceed the original 10MiB quota yet stay within the
// new 100MiB quota.
// Note that both the key name and value affect the total size.
2020-03-20 20:28:31 +00:00
const testKeyName = '_electronDOMStorageQuotaIncreasedTest';
const length = 40 * Math.pow(2, 20) - testKeyName.length;
storage.setItem(testKeyName, 'X'.repeat(length));
// Wait at least one turn of the event loop to help avoid false positives
// Although not entirely necessary, the previous version of this test case
// failed to detect a real problem (perhaps related to DOM storage data caching)
// wherein calling `getItem` immediately after `setItem` would appear to work
// but then later (e.g. next tick) it would not.
await delay(1);
try {
2020-03-20 20:28:31 +00:00
expect(storage.getItem(testKeyName)).to.have.lengthOf(length);
} finally {
2020-03-20 20:28:31 +00:00
storage.removeItem(testKeyName);
}
2020-03-20 20:28:31 +00:00
});
it(`throws when attempting to use more than 128MiB in ${storageName}`, () => {
expect(() => {
2020-03-20 20:28:31 +00:00
const testKeyName = '_electronDOMStorageQuotaStillEnforcedTest';
const length = 128 * Math.pow(2, 20) - testKeyName.length;
try {
2020-03-20 20:28:31 +00:00
storage.setItem(testKeyName, 'X'.repeat(length));
} finally {
2020-03-20 20:28:31 +00:00
storage.removeItem(testKeyName);
}
2020-03-20 20:28:31 +00:00
}).to.throw();
});
});
});
2018-11-12 17:19:01 +00:00
it('requesting persitent quota works', async () => {
const grantedBytes = await new Promise(resolve => {
navigator.webkitPersistentStorage.requestQuota(1024 * 1024, resolve);
2020-03-20 20:28:31 +00:00
});
expect(grantedBytes).to.equal(1048576);
2020-03-20 20:28:31 +00:00
});
});
2016-03-25 20:03:49 +00:00
2017-11-13 20:13:19 +00:00
describe('websockets', () => {
2020-03-20 20:28:31 +00:00
let wss = null;
let server = null;
const WebSocketServer = ws.Server;
2016-03-25 20:03:49 +00:00
2017-11-13 20:13:19 +00:00
afterEach(() => {
2020-03-20 20:28:31 +00:00
wss.close();
server.close();
});
2016-03-25 20:03:49 +00:00
2017-11-13 20:13:19 +00:00
it('has user agent', (done) => {
2020-03-20 20:28:31 +00:00
server = http.createServer();
2017-11-13 20:13:19 +00:00
server.listen(0, '127.0.0.1', () => {
2020-03-20 20:28:31 +00:00
const port = server.address().port;
wss = new WebSocketServer({ server: server });
wss.on('error', done);
wss.on('connection', (ws, upgradeReq) => {
if (upgradeReq.headers['user-agent']) {
2020-03-20 20:28:31 +00:00
done();
2016-01-12 02:40:23 +00:00
} else {
2020-03-20 20:28:31 +00:00
done('user agent is empty');
2016-01-12 02:40:23 +00:00
}
2020-03-20 20:28:31 +00:00
});
const socket = new WebSocket(`ws://127.0.0.1:${port}`);
});
});
});
2016-03-25 20:03:49 +00:00
2017-11-13 20:13:19 +00:00
describe('Promise', () => {
it('resolves correctly in Node.js calls', (done) => {
class XElement extends HTMLElement {}
2020-03-20 20:28:31 +00:00
customElements.define('x-element', XElement);
2017-11-13 20:13:19 +00:00
setImmediate(() => {
2020-03-20 20:28:31 +00:00
let called = false;
2017-11-13 20:13:19 +00:00
Promise.resolve().then(() => {
2020-03-20 20:28:31 +00:00
done(called ? undefined : new Error('wrong sequence'));
});
document.createElement('x-element');
called = true;
});
});
2016-03-25 20:03:49 +00:00
2017-11-13 20:13:19 +00:00
it('resolves correctly in Electron calls', (done) => {
class YElement extends HTMLElement {}
2020-03-20 20:28:31 +00:00
customElements.define('y-element', YElement);
ipcRenderer.invoke('ping').then(() => {
2020-03-20 20:28:31 +00:00
let called = false;
2017-11-13 20:13:19 +00:00
Promise.resolve().then(() => {
2020-03-20 20:28:31 +00:00
done(called ? undefined : new Error('wrong sequence'));
});
document.createElement('y-element');
called = true;
});
});
});
2016-08-22 10:26:07 +00:00
2017-11-13 20:13:19 +00:00
describe('fetch', () => {
it('does not crash', (done) => {
const server = http.createServer((req, res) => {
2020-03-20 20:28:31 +00:00
res.end('test');
server.close();
});
2017-11-13 20:13:19 +00:00
server.listen(0, '127.0.0.1', () => {
2020-03-20 20:28:31 +00:00
const port = server.address().port;
2017-11-13 20:13:19 +00:00
fetch(`http://127.0.0.1:${port}`).then((res) => res.body.getReader())
.then((reader) => {
reader.read().then((r) => {
2020-03-20 20:28:31 +00:00
reader.cancel();
done();
});
}).catch((e) => done(e));
});
});
});
2017-02-04 14:48:16 +00:00
2017-11-13 20:13:19 +00:00
describe('window.alert(message, title)', () => {
it('throws an exception when the arguments cannot be converted to strings', () => {
expect(() => {
2020-03-20 20:28:31 +00:00
window.alert({ toString: null });
}).to.throw('Cannot convert object to primitive value');
});
});
2017-11-13 20:13:19 +00:00
describe('window.confirm(message, title)', () => {
it('throws an exception when the arguments cannot be converted to strings', () => {
expect(() => {
2020-03-20 20:28:31 +00:00
window.confirm({ toString: null }, 'title');
}).to.throw('Cannot convert object to primitive value');
});
});
2017-11-13 20:13:19 +00:00
describe('window.history', () => {
describe('window.history.go(offset)', () => {
it('throws an exception when the argumnet cannot be converted to a string', () => {
expect(() => {
2020-03-20 20:28:31 +00:00
window.history.go({ toString: null });
}).to.throw('Cannot convert object to primitive value');
});
});
});
// TODO(nornagon): this is broken on CI, it triggers:
// [FATAL:speech_synthesis.mojom-shared.h(237)] The outgoing message will
// trigger VALIDATION_ERROR_UNEXPECTED_NULL_POINTER at the receiving side
// (null text in SpeechSynthesisUtterance struct).
describe.skip('SpeechSynthesis', () => {
before(function () {
if (!features.isTtsEnabled()) {
2020-03-20 20:28:31 +00:00
this.skip();
}
2020-03-20 20:28:31 +00:00
});
it('should emit lifecycle events', async () => {
const sentence = `long sentence which will take at least a few seconds to
2020-03-20 20:28:31 +00:00
utter so that it's possible to pause and resume before the end`;
const utter = new SpeechSynthesisUtterance(sentence);
// Create a dummy utterence so that speech synthesis state
// is initialized for later calls.
2020-03-20 20:28:31 +00:00
speechSynthesis.speak(new SpeechSynthesisUtterance());
speechSynthesis.cancel();
speechSynthesis.speak(utter);
// paused state after speak()
2020-03-20 20:28:31 +00:00
expect(speechSynthesis.paused).to.be.false();
await new Promise((resolve) => { utter.onstart = resolve; });
// paused state after start event
2020-03-20 20:28:31 +00:00
expect(speechSynthesis.paused).to.be.false();
2020-03-20 20:28:31 +00:00
speechSynthesis.pause();
// paused state changes async, right before the pause event
2020-03-20 20:28:31 +00:00
expect(speechSynthesis.paused).to.be.false();
await new Promise((resolve) => { utter.onpause = resolve; });
expect(speechSynthesis.paused).to.be.true();
2020-03-20 20:28:31 +00:00
speechSynthesis.resume();
await new Promise((resolve) => { utter.onresume = resolve; });
// paused state after resume event
2020-03-20 20:28:31 +00:00
expect(speechSynthesis.paused).to.be.false();
2020-03-20 20:28:31 +00:00
await new Promise((resolve) => { utter.onend = resolve; });
});
});
});
describe('console functions', () => {
it('should exist', () => {
2020-03-20 20:28:31 +00:00
expect(console.log, 'log').to.be.a('function');
expect(console.error, 'error').to.be.a('function');
expect(console.warn, 'warn').to.be.a('function');
expect(console.info, 'info').to.be.a('function');
expect(console.debug, 'debug').to.be.a('function');
expect(console.trace, 'trace').to.be.a('function');
expect(console.time, 'time').to.be.a('function');
expect(console.timeEnd, 'timeEnd').to.be.a('function');
});
});