mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 19:35:51 +00:00
Bug 1823208 - Use lossy conversion in getBacktrace testing function. r=jandem
Differential Revision: https://phabricator.services.mozilla.com/D173262
This commit is contained in:
parent
19819b17d0
commit
01d4f3c0ba
@ -5683,8 +5683,15 @@ static bool GetBacktrace(JSContext* cx, unsigned argc, Value* vp) {
|
||||
return false;
|
||||
}
|
||||
|
||||
JS::ConstUTF8CharsZ utf8chars(buf.get(), strlen(buf.get()));
|
||||
JSString* str = NewStringCopyUTF8Z(cx, utf8chars);
|
||||
size_t len;
|
||||
UniqueTwoByteChars ucbuf(JS::LossyUTF8CharsToNewTwoByteCharsZ(
|
||||
cx, JS::UTF8Chars(buf.get(), strlen(buf.get())),
|
||||
&len, js::MallocArena)
|
||||
.get());
|
||||
if (!ucbuf) {
|
||||
return false;
|
||||
}
|
||||
JSString* str = JS_NewUCStringCopyN(cx, ucbuf.get(), len);
|
||||
if (!str) {
|
||||
return false;
|
||||
}
|
||||
|
10
js/src/jit-test/tests/basic/getBacktrace-invalid.js
Normal file
10
js/src/jit-test/tests/basic/getBacktrace-invalid.js
Normal file
@ -0,0 +1,10 @@
|
||||
// Some filename handling code still uses latin1, and some characters are
|
||||
// replaced with REPLACEMENT CHARACTER (U+FFFD).
|
||||
//
|
||||
// FIXME: bug 1492090
|
||||
|
||||
const backtrace = evaluate(`
|
||||
this.getBacktrace(this);
|
||||
`, { fileName: "\u86D9" });
|
||||
|
||||
assertEq(backtrace.includes(`["\uFFFD":2:5]`), true);
|
Loading…
Reference in New Issue
Block a user