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

Unified Diff: net/data/proxy_resolver_v8_unittest/pac_library_unittest.js

Issue 812543002: Update from https://crrev.com/308331 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years 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/base/net_log_util.cc ('k') | net/disk_cache/backend_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/data/proxy_resolver_v8_unittest/pac_library_unittest.js
diff --git a/net/data/proxy_resolver_v8_unittest/pac_library_unittest.js b/net/data/proxy_resolver_v8_unittest/pac_library_unittest.js
index 0c0a4a981509ad5cbf98da2f1987e1b47db676d2..58de402314830f16f938f2f743cc86bba2aefd73 100644
--- a/net/data/proxy_resolver_v8_unittest/pac_library_unittest.js
+++ b/net/data/proxy_resolver_v8_unittest/pac_library_unittest.js
@@ -1,3 +1,7 @@
+// Copyright (c) 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
// This should output "PROXY success:80" if all the tests pass.
// Otherwise it will output "PROXY failure:<num-failures>".
//
@@ -61,6 +65,56 @@ Tests.testIsInNet = function(t) {
Tests.testIsPlainHostName = function(t) {
t.expectTrue(isPlainHostName("google"));
t.expectFalse(isPlainHostName("google.com"));
+ t.expectFalse(isPlainHostName("192.168.1.1"));
+ t.expectFalse(isPlainHostName("."));
+ t.expectFalse(isPlainHostName(".:"));
+
+ // Valid IPv6 address
+ t.expectFalse(isPlainHostName("::1"));
+
+ // Not a valid IPv6 address
+ t.expectTrue(isPlainHostName("foopy::1"));
+ t.expectTrue(isPlainHostName("foo:112"));
+ t.expectTrue(isPlainHostName(":"));
+ t.expectTrue(isPlainHostName("[:]"));
+
+ // Not considered a valid IPv6 address because of surrounding brackets.
+ t.expectTrue(isPlainHostName("[::1]"));
+
+ // Calling with more than 1 argument is allowed.
+ t.expectTrue(isPlainHostName("foo", "foo", "foo"));
+
+ // Calling with no arguments is an error.
+ try {
+ isPlainHostName();
+ t.expectTrue(false); // Not reached.
+ } catch (e) {
+ t.expectEquals('TypeError: Requires 1 string parameter', e.toString());
+ }
+
+ // Calling with the wrong argument type is an error.
+ try {
+ isPlainHostName(null);
+ t.expectTrue(false); // Not reached.
+ } catch (e) {
+ t.expectEquals('TypeError: Requires 1 string parameter', e.toString());
+ }
+
+ // Calling with the wrong argument type is an error.
+ try {
+ isPlainHostName(1);
+ t.expectTrue(false); // Not reached.
+ } catch (e) {
+ t.expectEquals('TypeError: Requires 1 string parameter', e.toString());
+ }
+
+ // Calling with the wrong argument type is an error.
+ try {
+ isPlainHostName(function() {});
+ t.expectTrue(false); // Not reached.
+ } catch (e) {
+ t.expectEquals('TypeError: Requires 1 string parameter', e.toString());
+ }
};
Tests.testLocalHostOrDomainIs = function(t) {
« no previous file with comments | « net/base/net_log_util.cc ('k') | net/disk_cache/backend_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698