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

Unified Diff: test/unittests/value-serializer-unittest.cc

Issue 2870743004: [value-serializer] Ensure deserialized JSRegExp flags are valid (Closed)
Patch Set: Add a unit test Created 3 years, 7 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/value-serializer.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/unittests/value-serializer-unittest.cc
diff --git a/test/unittests/value-serializer-unittest.cc b/test/unittests/value-serializer-unittest.cc
index 8f921ab11bb912ba99012d4616b4f3e86ffb8d2e..7ca7433eebc1de8f0f4fa503b94f89692c33b239 100644
--- a/test/unittests/value-serializer-unittest.cc
+++ b/test/unittests/value-serializer-unittest.cc
@@ -1603,6 +1603,44 @@ TEST_F(ValueSerializerTest, DecodeRegExp) {
});
}
+// Tests that invalid flags are not accepted by the deserializer. In particular,
+// the dotAll flag ('s') is only valid when the corresponding flag is enabled.
+TEST_F(ValueSerializerTest, DecodeRegExpDotAll) {
+ i::FLAG_harmony_regexp_dotall = false;
+ DecodeTest({0xff, 0x09, 0x3f, 0x00, 0x52, 0x03, 0x66, 0x6f, 0x6f, 0x1f},
+ [this](Local<Value> value) {
+ ASSERT_TRUE(value->IsRegExp());
+ EXPECT_TRUE(EvaluateScriptForResultBool(
+ "Object.getPrototypeOf(result) === RegExp.prototype"));
+ EXPECT_TRUE(EvaluateScriptForResultBool(
+ "result.toString() === '/foo/gimuy'"));
+ });
+ InvalidDecodeTest(
+ {0xff, 0x09, 0x3f, 0x00, 0x52, 0x03, 0x66, 0x6f, 0x6f, 0x3f});
+ InvalidDecodeTest(
+ {0xff, 0x09, 0x3f, 0x00, 0x52, 0x03, 0x66, 0x6f, 0x6f, 0x7f});
+
+ i::FLAG_harmony_regexp_dotall = true;
+ DecodeTest({0xff, 0x09, 0x3f, 0x00, 0x52, 0x03, 0x66, 0x6f, 0x6f, 0x1f},
+ [this](Local<Value> value) {
+ ASSERT_TRUE(value->IsRegExp());
+ EXPECT_TRUE(EvaluateScriptForResultBool(
+ "Object.getPrototypeOf(result) === RegExp.prototype"));
+ EXPECT_TRUE(EvaluateScriptForResultBool(
+ "result.toString() === '/foo/gimuy'"));
+ });
+ DecodeTest({0xff, 0x09, 0x3f, 0x00, 0x52, 0x03, 0x66, 0x6f, 0x6f, 0x3f},
+ [this](Local<Value> value) {
+ ASSERT_TRUE(value->IsRegExp());
+ EXPECT_TRUE(EvaluateScriptForResultBool(
+ "Object.getPrototypeOf(result) === RegExp.prototype"));
+ EXPECT_TRUE(EvaluateScriptForResultBool(
+ "result.toString() === '/foo/gimsuy'"));
+ });
+ InvalidDecodeTest(
+ {0xff, 0x09, 0x3f, 0x00, 0x52, 0x03, 0x66, 0x6f, 0x6f, 0x7f});
+}
+
TEST_F(ValueSerializerTest, RoundTripMap) {
RoundTripTest(
"(() => { var m = new Map(); m.set(42, 'foo'); return m; })()",
« no previous file with comments | « src/value-serializer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698