From 21f20c8940b8b9f06b04ff142716201a2530f0a3 Mon Sep 17 00:00:00 2001 From: "eroman@chromium.org" Date: Mon, 26 Oct 2009 23:51:28 +0000 Subject: Add three of the six extensions to PAC that Internet Explorer supports. The following descriptions were taken from ---------------------------- * myIpAddressEx(): Returns a semi-colon delimited string containing all IP addresses for localhost (IPv6 and/or IPv4), or an empty string if unable to resolve localhost to an IP address. * dnsResolveEx(host): Returns semi-colon delimited string containing IPv6 and IPv4 addresses or an empty string if host is not resolvable. * isResolvableEx(): Returns TRUE if the host is resolvable to a IPv4 or IPv6 address, FALSE otherwise. ---------------------------- These differ from the vanilla PAC functions in the following ways: * myIpAddressEx() returns all the addrsses for localhost (including IPv6 ones), whereas myIpAddress() only returns the first IPv4 one. * On failure, myIpAddress() returns "127.0.0.1" whereas on failure myIpAddressEx() returns empty string. * dnsResolveEx() returns a list of addresses (including IPV6 ones), whereas dnsResolve() only returns the first IPv4 address. * On failure, dnsResolve() returns |null|, whereas on failure dnsResolveEx() returns empty string. BUG=25407 TEST=ProxyResolverV8Test.DNSResolutionFailure, ProxyResolverJSBindingsTest.RestrictAddressFamily, ProxyResolverJSBindingsTest.ExFunctionsReturnList Review URL: http://codereview.chromium.org/333006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@30127 0039d316-1c4b-4281-b951-d872f2087c98 --- net/data/proxy_resolver_v8_unittest/bindings.js | 9 ++++++++- net/data/proxy_resolver_v8_unittest/dns_fail.js | 27 +++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 net/data/proxy_resolver_v8_unittest/dns_fail.js (limited to 'net/data/proxy_resolver_v8_unittest') diff --git a/net/data/proxy_resolver_v8_unittest/bindings.js b/net/data/proxy_resolver_v8_unittest/bindings.js index 0e748c1..3026569 100644 --- a/net/data/proxy_resolver_v8_unittest/bindings.js +++ b/net/data/proxy_resolver_v8_unittest/bindings.js @@ -35,10 +35,17 @@ function FindProxyForURL(url, host) { alert(e); } - // Call myIpAddress() with wonky arguments + // Call myIpAddress() with wonky arguments myIpAddress(null); myIpAddress(null, null); + // Call myIpAddressEx() correctly (no arguments). + myIpAddressEx(); + + // Call dnsResolveEx() (note that isResolvableEx() implicity calls it.) + isResolvableEx("is_resolvable"); + dnsResolveEx("foobar"); + return "DIRECT"; } diff --git a/net/data/proxy_resolver_v8_unittest/dns_fail.js b/net/data/proxy_resolver_v8_unittest/dns_fail.js new file mode 100644 index 0000000..c71bcc3 --- /dev/null +++ b/net/data/proxy_resolver_v8_unittest/dns_fail.js @@ -0,0 +1,27 @@ +// This script should be run in an environment where all DNS resolution are +// failing. It tests that functions return the expected values. +// +// Returns "PROXY success:80" on success. +function FindProxyForURL(url, host) { + try { + expectEq("127.0.0.1", myIpAddress()); + expectEq("", myIpAddressEx()); + + expectEq(null, dnsResolve("not-found")); + expectEq("", dnsResolveEx("not-found")); + + expectEq(false, isResolvable("not-found")); + expectEq(false, isResolvableEx("not-found")); + + return "PROXY success:80"; + } catch(e) { + alert(e); + return "PROXY failed:80"; + } +} + +function expectEq(expected, actual) { + if (expected != actual) + throw "Expected " + expected + " but was " + actual; +} + -- cgit v1.1