Repository: electron/electron (language: cpp)

Issue:
[Bug]: There is no `clipboard-sanitized-write` permission listed in docs
### Preflight Checklist

- [X] I have read the [Contributing Guidelines](https://github.com/electron/electron/blob/main/CONTRIBUTING.md) for this project.
- [X] I agree to follow the [Code of Conduct](https://github.com/electron/electron/blob/main/CODE_OF_CONDUCT.md) that this project adheres to.
- [X] I have searched the [issue tracker](https://www.github.com/electron/electron/issues) for a bug report that matches the one I want to file, without success.

### Electron Version

17.0.0

### What operating system are you using?

macOS

### Operating System Version

Does not matter

### What arch are you using?

x64

### Last Known Working Electron version

16.0.0

### Expected Behavior

This is not a bug.
I noticed my webContents requests permission named `clipboard-sanitized-write` when attempting to write data to clipboard.
I did a search in docs https://www.electronjs.org/docs/latest/api/session#sessetpermissionrequesthandlerhandler and found only `clipboard-read` permission.

It would be great to update the documentation :)
Expected: there is `clipboard-sanitized-write` in docsthe 

### Actual Behavior

There is no `clipboard-sanitized-write` permission in docs.


### Testcase Gist URL

_No response_

### Additional Information

_No response_


Discussion / hints:

Fix patch:
diff --git a/docs/api/session.md b/docs/api/session.md
index 199202dd8a96e..ad0cb87ac3fca 100644
--- a/docs/api/session.md
+++ b/docs/api/session.md
@@ -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.
   * `permission` string - The type of requested permission.
     * `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.
     * `display-capture` - Request access to capture the screen.
     * `mediaKeySystem` - Request access to DRM protected content.
diff --git a/spec/chromium-spec.ts b/spec/chromium-spec.ts
index 6ce63aa285545..ecf8d966a2aa3 100644
--- a/spec/chromium-spec.ts
+++ b/spec/chromium-spec.ts
@@ -2545,14 +2545,10 @@ describe('window.getScreenDetails', () => {
   });
 });
 
-describe('navigator.clipboard', () => {
+describe('navigator.clipboard.read', () => {
   let w: BrowserWindow;
   before(async () => {
-    w = new BrowserWindow({
-      webPreferences: {
-        enableBlinkFeatures: 'Serial'
-      }
-    });
+    w = new BrowserWindow();
     await w.loadFile(path.join(fixturesPath, 'pages', 'blank.html'));
   });
 
@@ -2597,6 +2593,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', () => {
   let w: BrowserWindow;
 


Test patch: