fix: clipboard.readBuffer returning empty value (#24454)
This commit is contained in:
parent
e59370f541
commit
7dd365784d
2 changed files with 4 additions and 25 deletions
|
@ -71,9 +71,8 @@ void Clipboard::WriteBuffer(const std::string& format,
|
||||||
base::span<const uint8_t> payload_span(
|
base::span<const uint8_t> payload_span(
|
||||||
reinterpret_cast<const uint8_t*>(node::Buffer::Data(buffer)),
|
reinterpret_cast<const uint8_t*>(node::Buffer::Data(buffer)),
|
||||||
node::Buffer::Length(buffer));
|
node::Buffer::Length(buffer));
|
||||||
writer.WriteData(
|
writer.WriteData(base::UTF8ToUTF16(format),
|
||||||
base::UTF8ToUTF16(ui::ClipboardFormatType::GetType(format).Serialize()),
|
mojo_base::BigBuffer(payload_span));
|
||||||
mojo_base::BigBuffer(payload_span));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Clipboard::Write(const gin_helper::Dictionary& data,
|
void Clipboard::Write(const gin_helper::Dictionary& data,
|
||||||
|
|
|
@ -112,17 +112,11 @@ describe('clipboard module', () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('clipboard.writeBuffer(format, buffer)', () => {
|
describe('clipboard.readBuffer(format)', () => {
|
||||||
it('writes a Buffer for the specified format', function () {
|
it('writes a Buffer for the specified format', function () {
|
||||||
if (process.platform !== 'darwin') {
|
|
||||||
// FIXME(alexeykuzmin): Skip the test.
|
|
||||||
// this.skip()
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const buffer = Buffer.from('writeBuffer', 'utf8');
|
const buffer = Buffer.from('writeBuffer', 'utf8');
|
||||||
clipboard.writeBuffer('public.utf8-plain-text', buffer);
|
clipboard.writeBuffer('public.utf8-plain-text', buffer);
|
||||||
expect(clipboard.readText()).to.equal('writeBuffer');
|
expect(buffer.equals(clipboard.readBuffer('public.utf8-plain-text'))).to.equal(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('throws an error when a non-Buffer is specified', () => {
|
it('throws an error when a non-Buffer is specified', () => {
|
||||||
|
@ -131,18 +125,4 @@ describe('clipboard module', () => {
|
||||||
}).to.throw(/buffer must be a node Buffer/);
|
}).to.throw(/buffer must be a node Buffer/);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('clipboard.readBuffer(format)', () => {
|
|
||||||
before(function () {
|
|
||||||
if (process.platform !== 'darwin') {
|
|
||||||
this.skip();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
it('returns a Buffer of the content for the specified format', () => {
|
|
||||||
const buffer = Buffer.from('this is binary', 'utf8');
|
|
||||||
clipboard.writeText(buffer.toString());
|
|
||||||
expect(buffer.equals(clipboard.readBuffer('public.utf8-plain-text'))).to.equal(true);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue