feat: add navigationHistory.getEntryAtIndex(int index) method (#41577)

This commit is contained in:
Alice Zhao 2024-03-21 14:59:23 -07:00 committed by GitHub
parent 1036d824fe
commit 00e3445f8a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 164 additions and 9 deletions

View file

@ -2068,13 +2068,13 @@ describe('chromium features', () => {
const w = new BrowserWindow({ show: false });
await w.loadFile(path.join(fixturesPath, 'pages', 'blank.html'));
// History should have current page by now.
expect(w.webContents.length()).to.equal(1);
expect(w.webContents.navigationHistory.length()).to.equal(1);
const waitCommit = once(w.webContents, 'navigation-entry-committed');
w.webContents.executeJavaScript('window.history.pushState({}, "")');
await waitCommit;
// Initial page + pushed state.
expect(w.webContents.length()).to.equal(2);
expect(w.webContents.navigationHistory.length()).to.equal(2);
});
});
@ -2102,7 +2102,7 @@ describe('chromium features', () => {
});
await w.webContents.mainFrame.frames[0].executeJavaScript('window.history.back()');
expect(await w.webContents.executeJavaScript('window.history.state')).to.equal(1);
expect(w.webContents.getActiveIndex()).to.equal(1);
expect(w.webContents.navigationHistory.getActiveIndex()).to.equal(1);
});
});
});