зеркало из https://github.com/electron/electron.git
test: replace (webContents as any).destroy() with webContents.destroy() (#36653)
Co-authored-by: Milan Burda <miburda@microsoft.com> Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org>
This commit is contained in:
Родитель
fb461effae
Коммит
5fd7a43970
|
@ -32,7 +32,7 @@ describe('BrowserView module', () => {
|
|||
|
||||
if (view && view.webContents) {
|
||||
const p = emittedOnce(view.webContents, 'destroyed');
|
||||
(view.webContents as any).destroy();
|
||||
view.webContents.destroy();
|
||||
view = null as any;
|
||||
await p;
|
||||
}
|
||||
|
@ -193,11 +193,11 @@ describe('BrowserView module', () => {
|
|||
describe('BrowserWindow.addBrowserView()', () => {
|
||||
it('does not throw for valid args', () => {
|
||||
const view1 = new BrowserView();
|
||||
defer(() => (view1.webContents as any).destroy());
|
||||
defer(() => view1.webContents.destroy());
|
||||
w.addBrowserView(view1);
|
||||
defer(() => w.removeBrowserView(view1));
|
||||
const view2 = new BrowserView();
|
||||
defer(() => (view2.webContents as any).destroy());
|
||||
defer(() => view2.webContents.destroy());
|
||||
w.addBrowserView(view2);
|
||||
defer(() => w.removeBrowserView(view2));
|
||||
});
|
||||
|
@ -212,7 +212,7 @@ describe('BrowserView module', () => {
|
|||
it('does not crash if the BrowserView webContents are destroyed prior to window addition', () => {
|
||||
expect(() => {
|
||||
const view1 = new BrowserView();
|
||||
(view1.webContents as any).destroy();
|
||||
view1.webContents.destroy();
|
||||
w.addBrowserView(view1);
|
||||
}).to.not.throw();
|
||||
});
|
||||
|
@ -262,11 +262,11 @@ describe('BrowserView module', () => {
|
|||
describe('BrowserWindow.getBrowserViews()', () => {
|
||||
it('returns same views as was added', () => {
|
||||
const view1 = new BrowserView();
|
||||
defer(() => (view1.webContents as any).destroy());
|
||||
defer(() => view1.webContents.destroy());
|
||||
w.addBrowserView(view1);
|
||||
defer(() => w.removeBrowserView(view1));
|
||||
const view2 = new BrowserView();
|
||||
defer(() => (view2.webContents as any).destroy());
|
||||
defer(() => view2.webContents.destroy());
|
||||
w.addBrowserView(view2);
|
||||
defer(() => w.removeBrowserView(view2));
|
||||
|
||||
|
|
|
@ -2206,7 +2206,7 @@ describe('BrowserWindow module', () => {
|
|||
w.setBrowserView(bv);
|
||||
defer(() => {
|
||||
w.removeBrowserView(bv);
|
||||
(bv.webContents as any).destroy();
|
||||
bv.webContents.destroy();
|
||||
});
|
||||
await bv.webContents.loadURL('about:blank');
|
||||
expect(BrowserWindow.fromWebContents(bv.webContents)!.id).to.equal(w.id);
|
||||
|
@ -2254,7 +2254,7 @@ describe('BrowserWindow module', () => {
|
|||
w.setBrowserView(bv);
|
||||
defer(() => {
|
||||
w.removeBrowserView(bv);
|
||||
(bv.webContents as any).destroy();
|
||||
bv.webContents.destroy();
|
||||
});
|
||||
expect(BrowserWindow.fromBrowserView(bv)!.id).to.equal(w.id);
|
||||
});
|
||||
|
@ -2268,8 +2268,8 @@ describe('BrowserWindow module', () => {
|
|||
defer(() => {
|
||||
w.removeBrowserView(bv1);
|
||||
w.removeBrowserView(bv2);
|
||||
(bv1.webContents as any).destroy();
|
||||
(bv2.webContents as any).destroy();
|
||||
bv1.webContents.destroy();
|
||||
bv2.webContents.destroy();
|
||||
});
|
||||
expect(BrowserWindow.fromBrowserView(bv1)!.id).to.equal(w.id);
|
||||
expect(BrowserWindow.fromBrowserView(bv2)!.id).to.equal(w.id);
|
||||
|
@ -2278,7 +2278,7 @@ describe('BrowserWindow module', () => {
|
|||
it('returns undefined if not attached', () => {
|
||||
const bv = new BrowserView();
|
||||
defer(() => {
|
||||
(bv.webContents as any).destroy();
|
||||
bv.webContents.destroy();
|
||||
});
|
||||
expect(BrowserWindow.fromBrowserView(bv)).to.be.null('BrowserWindow associated with bv');
|
||||
});
|
||||
|
|
|
@ -144,7 +144,7 @@ describe('ipcRenderer module', () => {
|
|||
});
|
||||
|
||||
after(() => {
|
||||
(contents as any).destroy();
|
||||
contents.destroy();
|
||||
contents = null as unknown as WebContents;
|
||||
});
|
||||
|
||||
|
|
|
@ -74,7 +74,7 @@ describe('protocol module', () => {
|
|||
let contents: WebContents = null as unknown as WebContents;
|
||||
// NB. sandbox: true is used because it makes navigations much (~8x) faster.
|
||||
before(() => { contents = (webContents as any).create({ sandbox: true }); });
|
||||
after(() => (contents as any).destroy());
|
||||
after(() => contents.destroy());
|
||||
|
||||
async function ajax (url: string, options = {}) {
|
||||
// Note that we need to do navigation every time after a protocol is
|
||||
|
@ -964,7 +964,7 @@ describe('protocol module', () => {
|
|||
// This is called in a timeout to avoid a crash that happens when
|
||||
// calling destroy() in a microtask.
|
||||
setTimeout(() => {
|
||||
(newContents as any).destroy();
|
||||
newContents.destroy();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -1062,7 +1062,7 @@ describe('protocol module', () => {
|
|||
// This is called in a timeout to avoid a crash that happens when
|
||||
// calling destroy() in a microtask.
|
||||
setTimeout(() => {
|
||||
(newContents as any).destroy();
|
||||
newContents.destroy();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ describe('session.serviceWorkers', () => {
|
|||
});
|
||||
|
||||
afterEach(async () => {
|
||||
(w as any).destroy();
|
||||
w.destroy();
|
||||
server.close();
|
||||
await ses.clearStorageData();
|
||||
});
|
||||
|
|
|
@ -1552,7 +1552,7 @@ describe('webContents module', () => {
|
|||
const contents = (webContents as any).create() as WebContents;
|
||||
const originalEmit = contents.emit.bind(contents);
|
||||
contents.emit = (...args) => { return originalEmit(...args); };
|
||||
contents.once(e.name as any, () => (contents as any).destroy());
|
||||
contents.once(e.name as any, () => contents.destroy());
|
||||
const destroyed = emittedOnce(contents, 'destroyed');
|
||||
contents.loadURL(serverUrl + e.url);
|
||||
await destroyed;
|
||||
|
|
|
@ -55,7 +55,7 @@ describe('webRequest module', () => {
|
|||
contents = (webContents as any).create({ sandbox: true });
|
||||
await contents.loadFile(path.join(fixturesPath, 'pages', 'fetch.html'));
|
||||
});
|
||||
after(() => (contents as any).destroy());
|
||||
after(() => contents.destroy());
|
||||
|
||||
async function ajax (url: string, options = {}) {
|
||||
return contents.executeJavaScript(`ajax("${url}", ${JSON.stringify(options)})`);
|
||||
|
|
|
@ -1479,7 +1479,7 @@ describe('chromium features', () => {
|
|||
});
|
||||
|
||||
afterEach(() => {
|
||||
(contents as any).destroy();
|
||||
contents.destroy();
|
||||
contents = null as any;
|
||||
});
|
||||
|
||||
|
@ -1595,7 +1595,7 @@ describe('chromium features', () => {
|
|||
|
||||
afterEach(async () => {
|
||||
if (contents) {
|
||||
(contents as any).destroy();
|
||||
contents.destroy();
|
||||
contents = null as any;
|
||||
}
|
||||
await closeAllWindows();
|
||||
|
|
|
@ -790,7 +790,7 @@ describe('node feature', () => {
|
|||
}
|
||||
})`))
|
||||
.then(() => {
|
||||
(w as any).destroy();
|
||||
w.destroy();
|
||||
child.send('plz-quit');
|
||||
done();
|
||||
});
|
||||
|
|
Загрузка…
Ссылка в новой задаче