fix: set userAgent on navigationHistory.restore() (#46260)

fix: set userAgent on navigationHistory restore
This commit is contained in:
Shelley Vohr 2025-03-26 16:59:19 +01:00 committed by GitHub
parent a5076a663b
commit 3212f60d69
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 32 additions and 0 deletions

View file

@ -887,6 +887,31 @@ describe('webContents module', () => {
});
});
});
it('should restore an overridden user agent', async () => {
const partition = 'persist:wcvtest';
const testUA = 'MyCustomUA';
const ses = session.fromPartition(partition);
ses.setUserAgent(testUA);
const wcv = new WebContentsView({
webPreferences: { partition }
});
wcv.webContents.navigationHistory.restore({
entries: [{
url: urlPage1,
title: 'url1'
}],
index: 0
});
const ua = wcv.webContents.getUserAgent();
const wcvua = await wcv.webContents.executeJavaScript('navigator.userAgent');
expect(ua).to.equal(wcvua);
});
});
describe('getFocusedWebContents() API', () => {