From 05ae671d83d5226d10765e51e48f671683456522 Mon Sep 17 00:00:00 2001 From: "trop[bot]" <37223003+trop[bot]@users.noreply.github.com> Date: Tue, 14 May 2024 17:46:59 -0700 Subject: [PATCH] fix: `webContents.navigationHistory` should be enumerable (#42181) fix: webContents.navigationHistory should be enumerable Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Shelley Vohr --- lib/browser/api/web-contents.ts | 3 ++- spec/api-web-contents-spec.ts | 11 +++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/browser/api/web-contents.ts b/lib/browser/api/web-contents.ts index 4166dc5caddd..f551650afc02 100644 --- a/lib/browser/api/web-contents.ts +++ b/lib/browser/api/web-contents.ts @@ -539,7 +539,8 @@ WebContents.prototype._init = function () { length: this._historyLength.bind(this), getEntryAtIndex: this._getNavigationEntryAtIndex.bind(this) }, - writable: false + writable: false, + enumerable: true }); // Dispatch IPC messages to the ipc module. diff --git a/spec/api-web-contents-spec.ts b/spec/api-web-contents-spec.ts index f5fd80061ef3..a54990fcb8ab 100644 --- a/spec/api-web-contents-spec.ts +++ b/spec/api-web-contents-spec.ts @@ -41,6 +41,17 @@ describe('webContents module', () => { }); }); + describe('webContents properties', () => { + afterEach(closeAllWindows); + + it('has expected additional enumerable properties', () => { + const w = new BrowserWindow({ show: false }); + const properties = Object.getOwnPropertyNames(w.webContents); + expect(properties).to.include('ipc'); + expect(properties).to.include('navigationHistory'); + }); + }); + describe('fromId()', () => { it('returns undefined for an unknown id', () => { expect(webContents.fromId(12345)).to.be.undefined();