fix: clipboard.writeBuffer raw format access (#31116)

* fix: clipboard.writeBuffer raw format access

* test: clipboard.writeBuffer raw format access

* test: clipboard win32 test skip

* fixup spec

* cleanup patch

Co-authored-by: John Kleinschmidt <jkleinsc@electronjs.org>
This commit is contained in:
henrit 2021-11-04 13:19:30 -05:00 committed by GitHub
parent f8df634197
commit 3c33d70294
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 76 additions and 3 deletions

View file

@ -129,5 +129,16 @@ ifdescribe(process.platform !== 'win32' || process.arch !== 'arm64')('clipboard
clipboard.writeBuffer('public/utf8-plain-text', 'hello');
}).to.throw(/buffer must be a node Buffer/);
});
ifit(process.platform !== 'win32')('writes a Buffer using a raw format that is used by native apps', function () {
const message = 'Hello from Electron!';
const buffer = Buffer.from(message);
let rawFormat = 'text/plain';
if (process.platform === 'darwin') {
rawFormat = 'public.utf8-plain-text';
}
clipboard.writeBuffer(rawFormat, buffer);
expect(clipboard.readText()).to.equal(message);
});
});
});