feat: add webContents.fromDevToolsTargetId() (#29399)
* feat: add webContents.fromDevToolsTargetId() * refactor: avoid using FromOrCreate
This commit is contained in:
parent
96131af5d3
commit
352ac21413
4 changed files with 53 additions and 0 deletions
|
@ -47,6 +47,24 @@ describe('webContents module', () => {
|
|||
});
|
||||
});
|
||||
|
||||
describe('fromDevToolsTargetId()', () => {
|
||||
it('returns WebContents for attached DevTools target', async () => {
|
||||
const w = new BrowserWindow({ show: false });
|
||||
await w.loadURL('about:blank');
|
||||
try {
|
||||
await w.webContents.debugger.attach('1.3');
|
||||
const { targetInfo } = await w.webContents.debugger.sendCommand('Target.getTargetInfo');
|
||||
expect(webContents.fromDevToolsTargetId(targetInfo.targetId)).to.equal(w.webContents);
|
||||
} finally {
|
||||
await w.webContents.debugger.detach();
|
||||
}
|
||||
});
|
||||
|
||||
it('returns undefined for an unknown id', () => {
|
||||
expect(webContents.fromDevToolsTargetId('nope')).to.be.undefined();
|
||||
});
|
||||
});
|
||||
|
||||
describe('will-prevent-unload event', function () {
|
||||
afterEach(closeAllWindows);
|
||||
it('does not emit if beforeunload returns undefined in a BrowserWindow', async () => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue