Skip to content

Commit 7d21e11

Browse files
shwetabinchromium-wpt-export-bot
authored andcommitted
[Clipboard] Prevent crash with disengaged unsanitized argument
Adding a has_value check on the unsanitized vector to verify whether it is set to a disengaged state. Bug: 443201222 Change-Id: Ibb5fcc1888ff948327f61cd7d48fe7a9f93e33c7 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6928781 Commit-Queue: Shweta Bindal <[email protected]> Reviewed-by: Dan Clark <[email protected]> Reviewed-by: Rohan Raja <[email protected]> Cr-Commit-Position: refs/heads/main@{#1517125}
1 parent 0c83f50 commit 7d21e11

1 file changed

Lines changed: 28 additions & 0 deletions

File tree

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<!doctype html>
2+
<meta charset="utf-8">
3+
<title>Async Clipboard read with unsanitized:null should not crash</title>
4+
<body>Body needed for test_driver.click()</body>
5+
<script src="/resources/testharness.js"></script>
6+
<script src="/resources/testharnessreport.js"></script>
7+
<script src="/resources/testdriver.js"></script>
8+
<script src="/resources/testdriver-vendor.js"></script>
9+
<script src="resources/user-activation.js"></script>
10+
<script>
11+
'use strict';
12+
13+
promise_test(async t => {
14+
await tryGrantReadPermission();
15+
await tryGrantWritePermission();
16+
17+
const textInput = "<p>hello</p>";
18+
const format1 = 'text/html';
19+
const blobInput1 = new Blob([textInput], {type: format1});
20+
const clipboardItemInput = new ClipboardItem({[format1]: blobInput1});
21+
22+
await waitForUserActivation();
23+
await navigator.clipboard.write([clipboardItemInput]);
24+
await waitForUserActivation();
25+
const items = navigator.clipboard.read({unsanitized: null});
26+
await promise_rejects_js(t, TypeError, items);
27+
}, 'unsanitized: null should reject with TypeError');
28+
</script>

0 commit comments

Comments
 (0)