Commit 5d895391 authored by Johannes Henkel's avatar Johannes Henkel Committed by Commit Bot

[DevTools] Assert that the console text ends with exactly the low surrogate.

In |step5|, |text| ends with a UTF16 low surrogate, so text is invalid
Unicode, and this is as designed, since the Javascript console must
be able to deal with invalid Unicode as Javascript allows
unbalanced surrogate characters.

Unfortunately, the test only asserted the number of UTF16 characters,
not the actual characters preserved. Now we assert that |text|
ends with a particular character, '\uD835' which is a low surrogate,
the exact same one that was second to last in the original input
|str| in TestRunner.evaluateInPagePromise(...) above.

The test will thus fail if somehow this invalid UTF16 payload
runs through a UTF8 transcoder and back, as such transcoders
have no way to preserve unbalanced surrogate pairs - they will
typically replace them with a mark for "invalid character",
so then what comes back in |text| is valid UTF16, which
won't have a hanging low surrogate.

Change-Id: I0efedc84f6eb4f6570714e67e49ee44ffa309a7f
Reviewed-on: https://chromium-review.googlesource.com/c/1481952
Auto-Submit: Johannes Henkel <johannes@chromium.org>
Reviewed-by: default avatarAndrey Kosyakov <caseq@chromium.org>
Commit-Queue: Andrey Kosyakov <caseq@chromium.org>
Cr-Commit-Position: refs/heads/master@{#634433}
parent 9405f035
...@@ -40,6 +40,11 @@ ...@@ -40,6 +40,11 @@
function step5(result) { function step5(result) {
var text = result; var text = result;
TestRunner.assertEquals(15, text.length, 'text length'); TestRunner.assertEquals(15, text.length, 'text length');
// It's important that this last character in |text| is an unbalanced UTF16
// low surrogate (|text| is invalid UTF16, allowed by Javascript), as
// opposed to some replacement character that came from transcoding to UTF8
// and back to valid UTF16.
TestRunner.assertEquals('\uD835', text[text.length - 1]);
TestRunner.assertEquals(8, countTextNodes(text), 'nodes count'); TestRunner.assertEquals(8, countTextNodes(text), 'nodes count');
TestRunner.assertEquals(1, countTextNodes('"' + text + '"'), 'nodes with quoted text count'); TestRunner.assertEquals(1, countTextNodes('"' + text + '"'), 'nodes with quoted text count');
TestRunner.addResult('PASS: Found all nodes with the broken text'); TestRunner.addResult('PASS: Found all nodes with the broken text');
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment