-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace unpaired surrogates in result of javascript URLs
Given a URL like javascript:String.fromCodePoint(0xDE0D), Chrome currently displays three U+FFFD replacement characters rather than just one, due to the incorrect UTF-8 conversion mode. We fix that by using kStrictUTF8ConversionReplacingUnpairedSurrogatesWithFFFD. This CL fully implements whatwg/html#6781. Tests are partially taken from #29419. Co-authored-by: Domenic Denicola <domenic@chromium.org> Bug: 1221018 Change-Id: Ic1282d0a88eabb40b4d5d8d8c68e040e9a0a938d
- Loading branch information
1 parent
ec5c1fc
commit ae1f6e6
Showing
2 changed files
with
58 additions
and
51 deletions.
There are no files selected for viewing
51 changes: 0 additions & 51 deletions
51
...ing-the-web/navigating-across-documents/javascript-url-return-value-handling-dynamic.html
This file was deleted.
Oops, something went wrong.
58 changes: 58 additions & 0 deletions
58
...b/navigating-across-documents/javascript-url-return-value-handling-dynamic.tentative.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<!doctype html> | ||
<meta charset=windows-1252> <!-- intentionally not UTF-8 to test that the javascript: frames are forced to UTF-8 --> | ||
<title>Test javascript URL string return values in direct and indirect (target) frame contexts.</title> | ||
<!-- Waiting on https://github.com/whatwg/html/pull/6781 to be non-tentative. --> | ||
<script src=/resources/testharness.js></script> | ||
<script src=/resources/testharnessreport.js></script> | ||
<div id=log></div> | ||
<script> | ||
const testCases = [ | ||
[[0x41]], | ||
[[0x80,0xFF]], | ||
[[0x80,0xFF,0x100]], | ||
[[0xD83D,0xDE0D]], | ||
[[0xDE0D,0x41], [0xFFFD,0x41]] | ||
]; | ||
|
||
function formatCharCodes(charCodes) { | ||
return charCodes.map(code => code.toString(16).toUpperCase().padStart(4, '0')).join(" "); | ||
} | ||
|
||
for (const [input, expected = input] of testCases) { | ||
const javascriptURL = `javascript:String.fromCharCode(${input})`; | ||
const output = String.fromCharCode(...expected); | ||
|
||
async_test(t => { | ||
const frame = document.createElement("iframe"); | ||
t.add_cleanup(() => frame.remove()); | ||
frame.src = javascriptURL; | ||
|
||
t.step_timeout(() => { | ||
assert_equals(frame.contentDocument.body.textContent, output); | ||
assert_equals(frame.contentDocument.charset, "UTF-8"); | ||
t.done(); | ||
}, 200); | ||
|
||
document.body.appendChild(frame); | ||
}, `${formatCharCodes(input)} set in src=""`); | ||
|
||
async_test(t => { | ||
const frame = document.createElement("iframe"); | ||
const href = document.createElement("a"); | ||
t.add_cleanup(() => { frame.remove(); href.remove(); }); | ||
frame.name = "hi" + input; | ||
href.target = "hi" + input; | ||
href.href = javascriptURL; | ||
|
||
t.step_timeout(() => { | ||
assert_equals(frame.contentDocument.body.textContent, output); | ||
assert_equals(frame.contentDocument.charset, "UTF-8"); | ||
t.done(); | ||
}, 200) | ||
|
||
document.body.appendChild(frame); | ||
document.body.appendChild(href); | ||
href.click(); | ||
}, `${formatCharCodes(input)} set in href="" targeting a frame and clicked`); | ||
} | ||
</script> |