fix: navigator.connection
not working as intended (#38491)
* fix: navigator.connection not working as intended * chore: make network quality methods private
This commit is contained in:
parent
67f273a6d6
commit
57147d1b8d
4 changed files with 57 additions and 0 deletions
|
@ -1970,6 +1970,30 @@ describe('chromium features', () => {
|
|||
});
|
||||
});
|
||||
|
||||
// https://developer.mozilla.org/en-US/docs/Web/API/NetworkInformation
|
||||
describe('navigator.connection', () => {
|
||||
it('returns the correct value', async () => {
|
||||
const w = new BrowserWindow({ show: false });
|
||||
|
||||
w.webContents.session.enableNetworkEmulation({
|
||||
latency: 500,
|
||||
downloadThroughput: 6400,
|
||||
uploadThroughput: 6400
|
||||
});
|
||||
|
||||
await w.loadURL(`file://${fixturesPath}/pages/blank.html`);
|
||||
const rtt = await w.webContents.executeJavaScript('navigator.connection.rtt');
|
||||
expect(rtt).to.be.a('number');
|
||||
|
||||
const downlink = await w.webContents.executeJavaScript('navigator.connection.downlink');
|
||||
expect(downlink).to.be.a('number');
|
||||
|
||||
const effectiveTypes = ['slow-2g', '2g', '3g', '4g'];
|
||||
const effectiveType = await w.webContents.executeJavaScript('navigator.connection.effectiveType');
|
||||
expect(effectiveTypes).to.include(effectiveType);
|
||||
});
|
||||
});
|
||||
|
||||
describe('navigator.userAgentData', () => {
|
||||
// These tests are done on an http server because navigator.userAgentData
|
||||
// requires a secure context.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue