test: use webContents.setWindowOpenHandler() in specs (#34310)
This commit is contained in:
parent
887b5a7dc7
commit
09a80ea48c
1 changed files with 8 additions and 6 deletions
|
@ -1563,9 +1563,10 @@ describe('webContents module', () => {
|
||||||
server.listen(0, '127.0.0.1', () => {
|
server.listen(0, '127.0.0.1', () => {
|
||||||
const url = 'http://127.0.0.1:' + (server.address() as AddressInfo).port + '/';
|
const url = 'http://127.0.0.1:' + (server.address() as AddressInfo).port + '/';
|
||||||
w.webContents.once('did-finish-load', () => {
|
w.webContents.once('did-finish-load', () => {
|
||||||
w.webContents.once('new-window', (event, newUrl, frameName, disposition, options, features, referrer) => {
|
w.webContents.setWindowOpenHandler(details => {
|
||||||
expect(referrer.url).to.equal(url);
|
expect(details.referrer.url).to.equal(url);
|
||||||
expect(referrer.policy).to.equal('strict-origin-when-cross-origin');
|
expect(details.referrer.policy).to.equal('strict-origin-when-cross-origin');
|
||||||
|
return { action: 'allow' };
|
||||||
});
|
});
|
||||||
w.webContents.executeJavaScript('a.click()');
|
w.webContents.executeJavaScript('a.click()');
|
||||||
});
|
});
|
||||||
|
@ -1591,9 +1592,10 @@ describe('webContents module', () => {
|
||||||
server.listen(0, '127.0.0.1', () => {
|
server.listen(0, '127.0.0.1', () => {
|
||||||
const url = 'http://127.0.0.1:' + (server.address() as AddressInfo).port + '/';
|
const url = 'http://127.0.0.1:' + (server.address() as AddressInfo).port + '/';
|
||||||
w.webContents.once('did-finish-load', () => {
|
w.webContents.once('did-finish-load', () => {
|
||||||
w.webContents.once('new-window', (event, newUrl, frameName, disposition, options, features, referrer) => {
|
w.webContents.setWindowOpenHandler(details => {
|
||||||
expect(referrer.url).to.equal(url);
|
expect(details.referrer.url).to.equal(url);
|
||||||
expect(referrer.policy).to.equal('no-referrer-when-downgrade');
|
expect(details.referrer.policy).to.equal('no-referrer-when-downgrade');
|
||||||
|
return { action: 'allow' };
|
||||||
});
|
});
|
||||||
w.webContents.executeJavaScript('window.open(location.href + "should_have_referrer")');
|
w.webContents.executeJavaScript('window.open(location.href + "should_have_referrer")');
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue