Skip to content

Commit

Permalink
[Clipboard APIs] Handle null values for blobs OnRead()
Browse files Browse the repository at this point in the history
Don't create |V8UnionBlobOrString| if the blob is null so that the null
value is handled in |ClipboardPromise::ResolveRead()| and it doesn't
perform an invalid conversion |ToResolvedPromise|.

Updated |ClipboardItemWithDOMStringSupport| flag status to experimental

Bug: 377251898
Change-Id: I47400f8a7671e4bb7b98b44d864b24b510e64835
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5993934
Reviewed-by: Christine Hollingsworth <[email protected]>
Reviewed-by: Nate Chapin <[email protected]>
Reviewed-by: Ayu Ishii <[email protected]>
Commit-Queue: Sambamurthy Bandaru <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1379178}
  • Loading branch information
sambandaru authored and chromium-wpt-export-bot committed Nov 6, 2024
1 parent 7360067 commit 3a14200
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions clipboard-apis/async-write-blobs-read-blobs.https.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,18 @@
assert_equals(blobTextOutput.type, 'text/plain');
assert_equals(blobImageOutput.type, 'image/png');
}, 'Verify write and read clipboard (multiple types)');

promise_test(async () => {
await tryGrantReadPermission();
await tryGrantWritePermission();
const text_blob = new Blob(['hello'], {type: 'text/plain'});
const html_blob = new Blob(undefined, {type: 'text/html'});
const item = new ClipboardItem({'text/plain': text_blob, 'text/html': html_blob});

await waitForUserActivation();
await navigator.clipboard.write([item]);
await waitForUserActivation();
const [clipboardItem] = await navigator.clipboard.read();
}, 'navigator.clipboard.read() does not crash if clipboard data has null values');

</script>

0 comments on commit 3a14200

Please sign in to comment.