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

@ -533,6 +533,17 @@ WebContents.prototype._init = function () {
enumerable: true
});
// Add navigationHistory property which handles session history,
// maintaining a list of navigation entries for backward and forward navigation.
Object.defineProperty(this, 'navigationHistory', {
value: {
getActiveIndex: this._getActiveIndex.bind(this),
length: this._historyLength.bind(this),
getEntryAtIndex: this._getNavigationEntryAtIndex.bind(this)
},
writable: false
});
// Dispatch IPC messages to the ipc module.
this.on('-ipc-message' as any, function (this: Electron.WebContents, event: Electron.IpcMainEvent, internal: boolean, channel: string, args: any[]) {
addSenderToEvent(event, this);