зеркало из https://github.com/electron/electron.git
docs: add missing clipboard-sanitized-write permission value to setPermissionRequestHandler() (#37173)
Co-authored-by: Milan Burda <miburda@microsoft.com>
This commit is contained in:
Родитель
478ce96914
Коммит
e5e9186d61
|
@ -784,6 +784,7 @@ win.webContents.session.setCertificateVerifyProc((request, callback) => {
|
||||||
* `webContents` [WebContents](web-contents.md) - WebContents requesting the permission. Please note that if the request comes from a subframe you should use `requestingUrl` to check the request origin.
|
* `webContents` [WebContents](web-contents.md) - WebContents requesting the permission. Please note that if the request comes from a subframe you should use `requestingUrl` to check the request origin.
|
||||||
* `permission` string - The type of requested permission.
|
* `permission` string - The type of requested permission.
|
||||||
* `clipboard-read` - Request access to read from the clipboard.
|
* `clipboard-read` - Request access to read from the clipboard.
|
||||||
|
* `clipboard-sanitized-write` - Request access to write to the clipboard.
|
||||||
* `media` - Request access to media devices such as camera, microphone and speakers.
|
* `media` - Request access to media devices such as camera, microphone and speakers.
|
||||||
* `display-capture` - Request access to capture the screen.
|
* `display-capture` - Request access to capture the screen.
|
||||||
* `mediaKeySystem` - Request access to DRM protected content.
|
* `mediaKeySystem` - Request access to DRM protected content.
|
||||||
|
|
|
@ -2547,14 +2547,10 @@ describe('window.getScreenDetails', () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('navigator.clipboard', () => {
|
describe('navigator.clipboard.read', () => {
|
||||||
let w: BrowserWindow;
|
let w: BrowserWindow;
|
||||||
before(async () => {
|
before(async () => {
|
||||||
w = new BrowserWindow({
|
w = new BrowserWindow();
|
||||||
webPreferences: {
|
|
||||||
enableBlinkFeatures: 'Serial'
|
|
||||||
}
|
|
||||||
});
|
|
||||||
await w.loadFile(path.join(fixturesPath, 'pages', 'blank.html'));
|
await w.loadFile(path.join(fixturesPath, 'pages', 'blank.html'));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -2599,6 +2595,54 @@ describe('navigator.clipboard', () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('navigator.clipboard.write', () => {
|
||||||
|
let w: BrowserWindow;
|
||||||
|
before(async () => {
|
||||||
|
w = new BrowserWindow();
|
||||||
|
await w.loadFile(path.join(fixturesPath, 'pages', 'blank.html'));
|
||||||
|
});
|
||||||
|
|
||||||
|
const writeClipboard: any = () => {
|
||||||
|
return w.webContents.executeJavaScript(`
|
||||||
|
navigator.clipboard.writeText('Hello World!').catch(err => err.message);
|
||||||
|
`, true);
|
||||||
|
};
|
||||||
|
|
||||||
|
after(closeAllWindows);
|
||||||
|
afterEach(() => {
|
||||||
|
session.defaultSession.setPermissionRequestHandler(null);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('returns clipboard contents when a PermissionRequestHandler is not defined', async () => {
|
||||||
|
const clipboard = await writeClipboard();
|
||||||
|
expect(clipboard).to.not.equal('Write permission denied.');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('returns an error when permission denied', async () => {
|
||||||
|
session.defaultSession.setPermissionRequestHandler((wc, permission, callback) => {
|
||||||
|
if (permission === 'clipboard-sanitized-write') {
|
||||||
|
callback(false);
|
||||||
|
} else {
|
||||||
|
callback(true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
const clipboard = await writeClipboard();
|
||||||
|
expect(clipboard).to.equal('Write permission denied.');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('returns clipboard contents when permission is granted', async () => {
|
||||||
|
session.defaultSession.setPermissionRequestHandler((wc, permission, callback) => {
|
||||||
|
if (permission === 'clipboard-sanitized-write') {
|
||||||
|
callback(true);
|
||||||
|
} else {
|
||||||
|
callback(false);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
const clipboard = await writeClipboard();
|
||||||
|
expect(clipboard).to.not.equal('Write permission denied.');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
ifdescribe((process.platform !== 'linux' || app.isUnityRunning()))('navigator.setAppBadge/clearAppBadge', () => {
|
ifdescribe((process.platform !== 'linux' || app.isUnityRunning()))('navigator.setAppBadge/clearAppBadge', () => {
|
||||||
let w: BrowserWindow;
|
let w: BrowserWindow;
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче