Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(479)

Unified Diff: test/intl/general/case-mapping.js

Issue 2236593002: Throw when case mapping result > max string length (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: AssertThrows and destructuring Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/runtime/runtime-i18n.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/intl/general/case-mapping.js
diff --git a/test/intl/general/case-mapping.js b/test/intl/general/case-mapping.js
index a73622bf0deb9cfdf35ae0071737bb5c633cbeb8..a0fb8370f2bfbac2a52a1b5afcc6af8c5748eaad 100644
--- a/test/intl/general/case-mapping.js
+++ b/test/intl/general/case-mapping.js
@@ -136,3 +136,30 @@ assertEquals("\u{10CC0}", "\u{10C80}".toLocaleLowerCase());
assertEquals("\u{10C80}", "\u{10CC0}".toLocaleUpperCase(["tr"]));
assertEquals("\u{10C80}", "\u{10CC0}".toLocaleUpperCase(["tr"]));
assertEquals("\u{10CC0}", "\u{10C80}".toLocaleLowerCase());
+
+// If the result of case mapping is longer than the max string length
+// (1<<28 - 16), it should throw a range error instead of crashing.
+var invalidValues = [
+ { c: "\u0390", opType: 0 },
+ { c: "ß", opType: 0 },
+ { c: "\uFB01", opType: 0 }, // fi ligature
+ { c: "\uFB04", opType: 0 }, // ffl ligature
+ { c: "\u0390", opType: 1, locale: "und" },
+ { c: "\u00CC", opType: 2, locale: "lt" },
+ { c: "\u0130", opType: 2, locale: "en" },
+];
+
+for (var {c, opType, locale} of invalidValues) {
+ var s = c.repeat(1<<27);
+ switch (opType) {
+ case 0:
+ assertThrows(() => s.toUpperCase(), RangeError);
+ break;
+ case 1:
+ assertThrows(() => s.toLocaleUpperCase(locale), RangeError);
+ break;
+ case 2:
+ assertThrows(() => s.toLocaleLowerCase(locale), RangeError);
+ break;
+ }
+}
« no previous file with comments | « src/runtime/runtime-i18n.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698