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

Unified Diff: net/proxy/proxy_resolver_v8_unittest.cc

Issue 950433002: Fix a crash when processing an invalid PAC script. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add copyright to test data (placate presubmit) Created 5 years, 10 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 | « net/proxy/proxy_resolver_v8.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/proxy/proxy_resolver_v8_unittest.cc
diff --git a/net/proxy/proxy_resolver_v8_unittest.cc b/net/proxy/proxy_resolver_v8_unittest.cc
index 76ad232c80518141f24cb95848d89164ff9d081a..0f16d862f2a7a25ed7109624b82244bda9d4ec89 100644
--- a/net/proxy/proxy_resolver_v8_unittest.cc
+++ b/net/proxy/proxy_resolver_v8_unittest.cc
@@ -253,6 +253,12 @@ TEST(ProxyResolverV8Test, NoEntryPoint) {
kQueryUrl, &proxy_info, CompletionCallback(), NULL, BoundNetLog());
EXPECT_EQ(ERR_FAILED, result);
+
+ MockJSBindings* bindings = resolver.mock_js_bindings();
+ ASSERT_EQ(1U, bindings->errors.size());
+ EXPECT_EQ("FindProxyForURL is undefined or not a function.",
+ bindings->errors[0]);
+ EXPECT_EQ(-1, bindings->errors_line_number[0]);
}
// Try loading a malformed PAC script.
@@ -328,6 +334,46 @@ TEST(ProxyResolverV8Test, UnhandledException) {
EXPECT_EQ(3, bindings->errors_line_number[0]);
}
+// Execute a PAC script which throws an exception when first accessing
+// FindProxyForURL
+TEST(ProxyResolverV8Test, ExceptionAccessingFindProxyForURLDuringInit) {
+ ProxyResolverV8WithMockBindings resolver;
+ int result =
+ resolver.SetPacScriptFromDisk("exception_findproxyforurl_during_init.js");
+ EXPECT_EQ(ERR_PAC_SCRIPT_FAILED, result);
+
+ MockJSBindings* bindings = resolver.mock_js_bindings();
+ ASSERT_EQ(2U, bindings->errors.size());
+ EXPECT_EQ("Uncaught crash!", bindings->errors[0]);
+ EXPECT_EQ(9, bindings->errors_line_number[0]);
+ EXPECT_EQ("Accessing FindProxyForURL threw an exception.",
+ bindings->errors[1]);
+ EXPECT_EQ(-1, bindings->errors_line_number[1]);
+}
+
+// Execute a PAC script which throws an exception during the second access to
+// FindProxyForURL
+TEST(ProxyResolverV8Test, ExceptionAccessingFindProxyForURLDuringResolve) {
+ ProxyResolverV8WithMockBindings resolver;
+ int result = resolver.SetPacScriptFromDisk(
+ "exception_findproxyforurl_during_resolve.js");
+ EXPECT_EQ(OK, result);
+
+ ProxyInfo proxy_info;
+ result = resolver.GetProxyForURL(kQueryUrl, &proxy_info, CompletionCallback(),
+ NULL, BoundNetLog());
+
+ EXPECT_EQ(ERR_PAC_SCRIPT_FAILED, result);
+
+ MockJSBindings* bindings = resolver.mock_js_bindings();
+ ASSERT_EQ(2U, bindings->errors.size());
+ EXPECT_EQ("Uncaught crash!", bindings->errors[0]);
+ EXPECT_EQ(17, bindings->errors_line_number[0]);
+ EXPECT_EQ("Accessing FindProxyForURL threw an exception.",
+ bindings->errors[1]);
+ EXPECT_EQ(-1, bindings->errors_line_number[1]);
+}
+
TEST(ProxyResolverV8Test, ReturnUnicode) {
ProxyResolverV8WithMockBindings resolver;
int result = resolver.SetPacScriptFromDisk("return_unicode.js");
« no previous file with comments | « net/proxy/proxy_resolver_v8.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698