fix: allow persistent media salts (#22386)
* fix: allow persistent media salts * chore: add regression test for persistent media device ids across reloads
This commit is contained in:
parent
fc54db11f3
commit
ee04c7f7ee
3 changed files with 29 additions and 2 deletions
|
@ -872,6 +872,14 @@ bool ElectronBrowserClient::ShouldUseProcessPerSite(
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ElectronBrowserClient::ArePersistentMediaDeviceIDsAllowed(
|
||||||
|
content::BrowserContext* browser_context,
|
||||||
|
const GURL& scope,
|
||||||
|
const GURL& site_for_cookies,
|
||||||
|
const base::Optional<url::Origin>& top_frame_origin) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void ElectronBrowserClient::SiteInstanceDeleting(
|
void ElectronBrowserClient::SiteInstanceDeleting(
|
||||||
content::SiteInstance* site_instance) {
|
content::SiteInstance* site_instance) {
|
||||||
// We are storing weak_ptr, is it fundamental to maintain the map up-to-date
|
// We are storing weak_ptr, is it fundamental to maintain the map up-to-date
|
||||||
|
|
|
@ -246,6 +246,11 @@ class ElectronBrowserClient : public content::ContentBrowserClient,
|
||||||
const GURL& site_url) override;
|
const GURL& site_url) override;
|
||||||
bool ShouldUseProcessPerSite(content::BrowserContext* browser_context,
|
bool ShouldUseProcessPerSite(content::BrowserContext* browser_context,
|
||||||
const GURL& effective_url) override;
|
const GURL& effective_url) override;
|
||||||
|
bool ArePersistentMediaDeviceIDsAllowed(
|
||||||
|
content::BrowserContext* browser_context,
|
||||||
|
const GURL& scope,
|
||||||
|
const GURL& site_for_cookies,
|
||||||
|
const base::Optional<url::Origin>& top_frame_origin) override;
|
||||||
|
|
||||||
// content::RenderProcessHostObserver:
|
// content::RenderProcessHostObserver:
|
||||||
void RenderProcessHostDestroyed(content::RenderProcessHost* host) override;
|
void RenderProcessHostDestroyed(content::RenderProcessHost* host) override;
|
||||||
|
|
|
@ -694,6 +694,21 @@ describe('chromium features', () => {
|
||||||
expect(labels.some((l: any) => l)).to.be.false()
|
expect(labels.some((l: any) => l)).to.be.false()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('returns the same device ids across reloads', async () => {
|
||||||
|
const ses = session.fromPartition('persist:media-device-id')
|
||||||
|
const w = new BrowserWindow({
|
||||||
|
show: false,
|
||||||
|
webPreferences: {
|
||||||
|
nodeIntegration: true,
|
||||||
|
session: ses
|
||||||
|
}
|
||||||
|
})
|
||||||
|
w.loadFile(path.join(fixturesPath, 'pages', 'media-id-reset.html'))
|
||||||
|
const [, firstDeviceIds] = await emittedOnce(ipcMain, 'deviceIds')
|
||||||
|
const [, secondDeviceIds] = await emittedOnce(ipcMain, 'deviceIds', () => w.webContents.reload())
|
||||||
|
expect(firstDeviceIds).to.deep.equal(secondDeviceIds)
|
||||||
|
})
|
||||||
|
|
||||||
it('can return new device id when cookie storage is cleared', async () => {
|
it('can return new device id when cookie storage is cleared', async () => {
|
||||||
const ses = session.fromPartition('persist:media-device-id')
|
const ses = session.fromPartition('persist:media-device-id')
|
||||||
const w = new BrowserWindow({
|
const w = new BrowserWindow({
|
||||||
|
@ -706,8 +721,7 @@ describe('chromium features', () => {
|
||||||
w.loadFile(path.join(fixturesPath, 'pages', 'media-id-reset.html'))
|
w.loadFile(path.join(fixturesPath, 'pages', 'media-id-reset.html'))
|
||||||
const [, firstDeviceIds] = await emittedOnce(ipcMain, 'deviceIds')
|
const [, firstDeviceIds] = await emittedOnce(ipcMain, 'deviceIds')
|
||||||
await ses.clearStorageData({ storages: ['cookies'] })
|
await ses.clearStorageData({ storages: ['cookies'] })
|
||||||
w.webContents.reload()
|
const [, secondDeviceIds] = await emittedOnce(ipcMain, 'deviceIds', () => w.webContents.reload())
|
||||||
const [, secondDeviceIds] = await emittedOnce(ipcMain, 'deviceIds')
|
|
||||||
expect(firstDeviceIds).to.not.deep.equal(secondDeviceIds)
|
expect(firstDeviceIds).to.not.deep.equal(secondDeviceIds)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue