Index: chrome/browser/extensions/api/declarative_webrequest/webrequest_action_unittest.cc |
diff --git a/chrome/browser/extensions/api/declarative_webrequest/webrequest_action_unittest.cc b/chrome/browser/extensions/api/declarative_webrequest/webrequest_action_unittest.cc |
index 1f36d717779e5b33c305a626cac266f45e35fec2..6473bb9b9be082b227f80185abb207b254ef27e6 100644 |
--- a/chrome/browser/extensions/api/declarative_webrequest/webrequest_action_unittest.cc |
+++ b/chrome/browser/extensions/api/declarative_webrequest/webrequest_action_unittest.cc |
@@ -100,4 +100,20 @@ TEST(WebRequestActionTest, CreateActionSet) { |
EXPECT_FALSE(result.get()); |
} |
+// Test capture group syntax conversions of WebRequestRedirectByRegExAction |
+TEST(WebRequestActionTest, PerlToRe2Style) { |
+#define CallPerlToRe2Style WebRequestRedirectByRegExAction::PerlToRe2Style |
+ // foo$1bar -> foo\1bar |
+ EXPECT_EQ("foo\\1bar", CallPerlToRe2Style("foo$1bar")); |
+ // foo\$1bar -> foo$1bar |
+ EXPECT_EQ("foo$1bar", CallPerlToRe2Style("foo\\$1bar")); |
+ // foo\\$1bar -> foo\\\1bar |
+ EXPECT_EQ("foo\\\\\\1bar", CallPerlToRe2Style("foo\\\\$1bar")); |
+ // foo\bar -> foobar |
+ EXPECT_EQ("foobar", CallPerlToRe2Style("foo\\bar")); |
+ // foo$bar -> foo$bar |
+ EXPECT_EQ("foo$bar", CallPerlToRe2Style("foo$bar")); |
+#undef CallPerlToRe2Style |
+} |
+ |
} // namespace extensions |