Loading js/src/tests/non262/String/utf8-encode.js +15 −7 Original line number Diff line number Diff line Loading @@ -167,6 +167,7 @@ concat.forEach(function(t) { checkUtf8Equal(rope, t.expected); }); { var ab = newRope("a", "b"); var abc = newRope(ab, "c"); var ef = newRope("e", "f"); Loading @@ -174,6 +175,13 @@ var def = newRope("d", ef); var abcdef = newRope(abc, def); var abcdefab = newRope(abcdef, ab); checkUtf8Equal(abcdefab, "abcdefab"); } { var right = newRope("\ude0a", "."); var rope = newRope("\ud83d", right); checkUtf8Equal(rope, "\ud83d\ude0a."); } if (typeof reportCompare === "function") reportCompare(true, true); js/src/vm/StringType.cpp +18 −19 Original line number Diff line number Diff line Loading @@ -214,9 +214,7 @@ mozilla::Maybe<mozilla::Tuple<size_t, size_t> > JSString::encodeUTF8Partial( } pendingLeadSurrogate = 0; } if (src.IsEmpty()) { return mozilla::Some(mozilla::MakeTuple(totalRead, totalWritten)); } if (!src.IsEmpty()) { char16_t last = src[src.Length() - 1]; if (unicode::IsLeadSurrogate(last)) { src = src.To(src.Length() - 1); Loading @@ -235,6 +233,7 @@ mozilla::Maybe<mozilla::Tuple<size_t, size_t> > JSString::encodeUTF8Partial( return mozilla::Some(mozilla::MakeTuple(totalRead, totalWritten)); } } } if (stack.empty()) { break; } Loading Loading
js/src/tests/non262/String/utf8-encode.js +15 −7 Original line number Diff line number Diff line Loading @@ -167,6 +167,7 @@ concat.forEach(function(t) { checkUtf8Equal(rope, t.expected); }); { var ab = newRope("a", "b"); var abc = newRope(ab, "c"); var ef = newRope("e", "f"); Loading @@ -174,6 +175,13 @@ var def = newRope("d", ef); var abcdef = newRope(abc, def); var abcdefab = newRope(abcdef, ab); checkUtf8Equal(abcdefab, "abcdefab"); } { var right = newRope("\ude0a", "."); var rope = newRope("\ud83d", right); checkUtf8Equal(rope, "\ud83d\ude0a."); } if (typeof reportCompare === "function") reportCompare(true, true);
js/src/vm/StringType.cpp +18 −19 Original line number Diff line number Diff line Loading @@ -214,9 +214,7 @@ mozilla::Maybe<mozilla::Tuple<size_t, size_t> > JSString::encodeUTF8Partial( } pendingLeadSurrogate = 0; } if (src.IsEmpty()) { return mozilla::Some(mozilla::MakeTuple(totalRead, totalWritten)); } if (!src.IsEmpty()) { char16_t last = src[src.Length() - 1]; if (unicode::IsLeadSurrogate(last)) { src = src.To(src.Length() - 1); Loading @@ -235,6 +233,7 @@ mozilla::Maybe<mozilla::Tuple<size_t, size_t> > JSString::encodeUTF8Partial( return mozilla::Some(mozilla::MakeTuple(totalRead, totalWritten)); } } } if (stack.empty()) { break; } Loading