fix: EventSource undefined in Renderer/Worker (#44475)
This commit is contained in:
parent
8be4ae4bab
commit
15151c6853
6 changed files with 52 additions and 6 deletions
|
@ -1028,6 +1028,43 @@ describe('chromium features', () => {
|
|||
expect(code).to.equal(0);
|
||||
});
|
||||
|
||||
itremote('Worker with nodeIntegrationInWorker has access to EventSource', () => {
|
||||
const es = new EventSource('https://example.com');
|
||||
expect(es).to.have.property('url').that.is.a('string');
|
||||
expect(es).to.have.property('readyState').that.is.a('number');
|
||||
expect(es).to.have.property('withCredentials').that.is.a('boolean');
|
||||
});
|
||||
|
||||
itremote('Worker with nodeIntegrationInWorker has access to fetch-dependent interfaces', async (fixtures: string) => {
|
||||
const file = require('node:path').join(fixtures, 'hello.txt');
|
||||
expect(() => {
|
||||
fetch('file://' + file);
|
||||
}).to.not.throw();
|
||||
|
||||
expect(() => {
|
||||
const formData = new FormData();
|
||||
formData.append('username', 'Groucho');
|
||||
}).not.to.throw();
|
||||
|
||||
expect(() => {
|
||||
const request = new Request('https://example.com', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ foo: 'bar' })
|
||||
});
|
||||
expect(request.method).to.equal('POST');
|
||||
}).not.to.throw();
|
||||
|
||||
expect(() => {
|
||||
const response = new Response('Hello, world!');
|
||||
expect(response.status).to.equal(200);
|
||||
}).not.to.throw();
|
||||
|
||||
expect(() => {
|
||||
const headers = new Headers();
|
||||
headers.append('Content-Type', 'text/xml');
|
||||
}).not.to.throw();
|
||||
}, [path.join(__dirname, 'fixtures')]);
|
||||
|
||||
it('Worker can work', async () => {
|
||||
const w = new BrowserWindow({ show: false });
|
||||
await w.loadURL(`file://${fixturesPath}/pages/blank.html`);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue