diff options
author | android-build-team Robot <android-build-team-robot@google.com> | 2020-05-05 07:00:21 +0000 |
---|---|---|
committer | android-build-team Robot <android-build-team-robot@google.com> | 2020-05-05 07:00:21 +0000 |
commit | 5372c33e99c1eb94e34c88b540e1b8dc15a94dae (patch) | |
tree | fe51293053ab8126dc79b35f5f1c9406c5eb7158 | |
parent | e0e56273f3d535f4cc9a99f49592496836b2ed05 (diff) | |
parent | c45369097577b68f6616c6660405043c7b1e6bdd (diff) | |
download | chromium-libpac-android11-mainline-sparse-2020-dec-release.tar.gz |
Snap for 6462261 from c45369097577b68f6616c6660405043c7b1e6bdd to mainline-releaser_aml_301500702android-mainline-12.0.0_r55android-mainline-11.0.0_r9android-mainline-11.0.0_r8android-mainline-11.0.0_r7android-mainline-11.0.0_r6android-mainline-11.0.0_r5android-mainline-11.0.0_r45android-mainline-11.0.0_r4android-mainline-11.0.0_r33android-mainline-11.0.0_r3android-mainline-11.0.0_r29android-mainline-11.0.0_r2android-mainline-11.0.0_r19android-mainline-11.0.0_r10android-mainline-11.0.0_r1android11-mainline-sparse-2021-jan-releaseandroid11-mainline-sparse-2020-dec-releaseandroid11-mainline-release
Change-Id: I8f93263097d5b8623480bc235bd0a275658eee7b
-rw-r--r-- | test/js-unittest/b_147664838.js | 21 | ||||
-rw-r--r-- | test/proxy_resolver_v8_unittest.cc | 13 | ||||
-rw-r--r-- | test/proxy_test_script.h | 24 |
3 files changed, 58 insertions, 0 deletions
diff --git a/test/js-unittest/b_147664838.js b/test/js-unittest/b_147664838.js new file mode 100644 index 0000000..d1d8b72 --- /dev/null +++ b/test/js-unittest/b_147664838.js @@ -0,0 +1,21 @@ +function FindProxyForURL(url, host){ + let re = /x/y; + let cnt = 0; + let str = re[Symbol.replace]("x", { + toString: () => { + cnt++; + if (cnt == 2) { + re.lastIndex = {valueOf: () => { + re.x = 42; + return 0; + }}; + } + return 'y$'; + } + }); + if (str != "y$") { + throw "regex mutated"; + return "FAIL"; + } + return "DIRECT"; +}
\ No newline at end of file diff --git a/test/proxy_resolver_v8_unittest.cc b/test/proxy_resolver_v8_unittest.cc index 3f6d20f..8469cab 100644 --- a/test/proxy_resolver_v8_unittest.cc +++ b/test/proxy_resolver_v8_unittest.cc @@ -657,6 +657,19 @@ TEST(ProxyResolverV8Test, B_139806216) { EXPECT_EQ("DIRECT", proxies[0]); } +TEST(ProxyResolverV8Test, B_147664838) { + ProxyResolverV8WithMockBindings resolver(new MockJSBindings()); + int result = resolver.SetPacScript(SCRIPT(B_147664838_JS)); + EXPECT_EQ(OK, result); + + // Execute FindProxyForURL(). + result = resolver.GetProxyForURL(kQueryUrl, kQueryHost, &kResults); + + EXPECT_EQ(OK, result); + std::vector<std::string> proxies = string16ToProxyList(kResults); + EXPECT_EQ(1U, proxies.size()); + EXPECT_EQ("DIRECT", proxies[0]); +} } // namespace } // namespace net diff --git a/test/proxy_test_script.h b/test/proxy_test_script.h index 500a57a..2a86491 100644 --- a/test/proxy_test_script.h +++ b/test/proxy_test_script.h @@ -35,6 +35,30 @@ " return \"DIRECT\";\n" \ "}\n" \ +#define B_147664838_JS \ + u""\ + "function FindProxyForURL(url, host){\n" \ + " let re = /x/y;\n" \ + " let cnt = 0;\n" \ + " let str = re[Symbol.replace](\"x\", {\n" \ + " toString: () => {\n" \ + " cnt++;\n" \ + " if (cnt == 2) {\n" \ + " re.lastIndex = {valueOf: () => {\n" \ + " re.x = 42;\n" \ + " return 0;\n" \ + " }};\n" \ + " }\n" \ + " return 'y$';\n" \ + " }\n" \ + " });\n" \ + " if (str != \"y$\") {\n" \ + " throw \"regex mutated\";\n" \ + " return \"FAIL\";\n" \ + " }\n" \ + " return \"DIRECT\";\n" \ + "}\n" \ + #define BINDING_FROM_GLOBAL_JS \ u""\ "// Calls a bindings outside of FindProxyForURL(). This causes the code to\n" \ |