Skip to content

Commit a77960a

Browse files
Fredrik Söderquistchromium-wpt-export-bot
authored andcommitted
Fix conversion from String to Blob in ClipboardItem.getType()
String::Span8() does not return UTF-8 encoded data, but rather Latin-1 if the string has an 8-bit backing. If the string has a 16-bit backing it returns jibberish. Fixed: 457303645 Change-Id: Ibce8f4817b6e8571baf041867065da7eb13a9b23 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7110225 Auto-Submit: Fredrik Söderquist <[email protected]> Reviewed-by: Daniel Cheng <[email protected]> Commit-Queue: Daniel Cheng <[email protected]> Cr-Commit-Position: refs/heads/main@{#1539397}
1 parent afaf0ac commit a77960a

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

clipboard-apis/async-navigator-clipboard-write-domstring.https.html

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,21 @@
9595
assert_true(blob instanceof Blob, "item.getType('text/html') should return a Blob");
9696
}, 'validate GetType(type) on a constructed ClipboardItem returns Blob');
9797

98+
promise_test(async () => {
99+
await getPermissions();
100+
// Test string with various non-Latin characters: Chinese, Arabic, Cyrillic, emoji
101+
const nonLatinText = "你好 مرحبا Привет 👋🌍";
102+
const item = new ClipboardItem({
103+
'text/plain': nonLatinText
104+
});
105+
const textBlob = await item.getType('text/plain');
106+
107+
// Read back the text and verify it matches
108+
const readText = await textBlob.text();
109+
assert_equals(readText, nonLatinText,
110+
"Text read from ClipboardItem should match the non-Latin text that was written");
111+
}, 'write non-Latin characters with DOMString and verify getType returns a Blob with the same string');
112+
98113
promise_test(async () => {
99114
await getPermissions();
100115
// Test string with various non-Latin characters: Chinese, Arabic, Cyrillic, emoji

0 commit comments

Comments
 (0)