fix: also pass securityOrigin to media permissions request handler (#31357)
This commit is contained in:
parent
a751845afc
commit
b2a2b077da
3 changed files with 29 additions and 0 deletions
|
@ -618,6 +618,7 @@ win.webContents.session.setCertificateVerifyProc((request, callback) => {
|
|||
* `permissionGranted` Boolean - Allow or deny the permission.
|
||||
* `details` Object - Some properties are only available on certain permission types.
|
||||
* `externalURL` String (optional) - The url of the `openExternal` request.
|
||||
* `securityOrigin` String (optional) - The security origin of the `media` request.
|
||||
* `mediaTypes` String[] (optional) - The types of media access being requested, elements can be `video`
|
||||
or `audio`
|
||||
* `requestingUrl` String - The last URL the requesting frame loaded
|
||||
|
|
|
@ -140,6 +140,7 @@ void WebContentsPermissionHelper::RequestMediaAccessPermission(
|
|||
media_types->Append("video");
|
||||
}
|
||||
details.SetList("mediaTypes", std::move(media_types));
|
||||
details.SetString("securityOrigin", request.security_origin.spec());
|
||||
|
||||
// The permission type doesn't matter here, AUDIO_CAPTURE/VIDEO_CAPTURE
|
||||
// are presented as same type in content_converter.h.
|
||||
|
|
|
@ -947,6 +947,7 @@ describe('chromium features', () => {
|
|||
afterEach(closeAllWindows);
|
||||
afterEach(() => {
|
||||
session.defaultSession.setPermissionCheckHandler(null);
|
||||
session.defaultSession.setPermissionRequestHandler(null);
|
||||
});
|
||||
|
||||
it('can return labels of enumerated devices', async () => {
|
||||
|
@ -996,6 +997,32 @@ describe('chromium features', () => {
|
|||
const [, secondDeviceIds] = await emittedOnce(ipcMain, 'deviceIds', () => w.webContents.reload());
|
||||
expect(firstDeviceIds).to.not.deep.equal(secondDeviceIds);
|
||||
});
|
||||
|
||||
it('provides a securityOrigin to the request handler', async () => {
|
||||
session.defaultSession.setPermissionRequestHandler(
|
||||
(wc, permission, callback, details) => {
|
||||
if (details.securityOrigin !== undefined) {
|
||||
callback(true);
|
||||
} else {
|
||||
callback(false);
|
||||
}
|
||||
}
|
||||
);
|
||||
const w = new BrowserWindow({ show: false });
|
||||
w.loadFile(path.join(fixturesPath, 'pages', 'blank.html'));
|
||||
const labels = await w.webContents.executeJavaScript(`navigator.mediaDevices.getUserMedia({
|
||||
video: {
|
||||
mandatory: {
|
||||
chromeMediaSource: "desktop",
|
||||
minWidth: 1280,
|
||||
maxWidth: 1280,
|
||||
minHeight: 720,
|
||||
maxHeight: 720
|
||||
}
|
||||
}
|
||||
}).then((stream) => stream.getVideoTracks())`);
|
||||
expect(labels.some((l: any) => l)).to.be.true();
|
||||
});
|
||||
});
|
||||
|
||||
describe('window.opener access', () => {
|
||||
|
|
Loading…
Add table
Reference in a new issue