mirror of
https://github.com/electron/electron.git
synced 2026-04-10 03:01:51 -04:00
docs: add missing window-placement permission value to setPermissionRequestHandler() (#36904)
docs: add missing window-placement permission value to setPermissionRequestHandler() (#36777) Co-authored-by: Milan Burda <miburda@microsoft.com> Co-authored-by: Milan Burda <milan.burda@gmail.com> Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Milan Burda <milan.burda@gmail.com>
This commit is contained in:
@@ -638,6 +638,7 @@ win.webContents.session.setCertificateVerifyProc((request, callback) => {
|
||||
* `pointerLock` - Request to directly interpret mouse movements as an input method. Click [here](https://developer.mozilla.org/en-US/docs/Web/API/Pointer_Lock_API) to know more. These requests always appear to originate from the main frame.
|
||||
* `fullscreen` - Request for the app to enter fullscreen mode.
|
||||
* `openExternal` - Request to open links in external applications.
|
||||
* `window-placement` - Request access to enumerate screens using the [`getScreenDetails`](https://developer.chrome.com/en/articles/multi-screen-window-placement/) API.
|
||||
* `unknown` - An unrecognized permission request
|
||||
* `callback` Function
|
||||
* `permissionGranted` boolean - Allow or deny the permission.
|
||||
|
||||
@@ -1864,6 +1864,54 @@ describe('navigator.serial', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('window.getScreenDetails', () => {
|
||||
let w: BrowserWindow;
|
||||
before(async () => {
|
||||
w = new BrowserWindow({
|
||||
show: false
|
||||
});
|
||||
await w.loadFile(path.join(fixturesPath, 'pages', 'blank.html'));
|
||||
});
|
||||
|
||||
after(closeAllWindows);
|
||||
afterEach(() => {
|
||||
session.defaultSession.setPermissionRequestHandler(null);
|
||||
});
|
||||
|
||||
const getScreenDetails: any = () => {
|
||||
return w.webContents.executeJavaScript('window.getScreenDetails().then(data => data.screens).catch(err => err.message)', true);
|
||||
};
|
||||
|
||||
it('returns screens when a PermissionRequestHandler is not defined', async () => {
|
||||
const screens = await getScreenDetails();
|
||||
expect(screens).to.not.equal('Read permission denied.');
|
||||
});
|
||||
|
||||
it('returns an error when permission denied', async () => {
|
||||
session.defaultSession.setPermissionRequestHandler((wc, permission, callback) => {
|
||||
if (permission === 'window-placement') {
|
||||
callback(false);
|
||||
} else {
|
||||
callback(true);
|
||||
}
|
||||
});
|
||||
const screens = await getScreenDetails();
|
||||
expect(screens).to.equal('Permission denied.');
|
||||
});
|
||||
|
||||
it('returns screens when permission is granted', async () => {
|
||||
session.defaultSession.setPermissionRequestHandler((wc, permission, callback) => {
|
||||
if (permission === 'window-placement') {
|
||||
callback(true);
|
||||
} else {
|
||||
callback(false);
|
||||
}
|
||||
});
|
||||
const screens = await getScreenDetails();
|
||||
expect(screens).to.not.equal('Permission denied.');
|
||||
});
|
||||
});
|
||||
|
||||
describe('navigator.clipboard', () => {
|
||||
let w: BrowserWindow;
|
||||
before(async () => {
|
||||
|
||||
Reference in New Issue
Block a user