Cast: Stop logging kVideoFrameSentToEncoder and rename a couple events.
[chromium-blink-merge.git] / net / data / proxy_resolver_v8_unittest / passthrough.js
blob832ac6624b439b2fe7c5358d4d4d99b16d0209f9
1 // Return a single-proxy result, which encodes ALL the arguments that were
2 // passed to FindProxyForURL().
4 function FindProxyForURL(url, host) {
5 if (arguments.length != 2) {
6 throw "Wrong number of arguments passed to FindProxyForURL!";
7 return "FAIL";
10 return "PROXY " + makePseudoHost(url + "." + host);
13 // Form a string that kind-of resembles a host. We will replace any
14 // non-alphanumeric character with a dot, then fix up the oddly placed dots.
15 function makePseudoHost(str) {
16 var result = "";
18 for (var i = 0; i < str.length; ++i) {
19 var c = str.charAt(i);
20 if (!isValidPseudoHostChar(c)) {
21 c = '.'; // Replace unsupported characters with a dot.
24 // Take care not to place multiple adjacent dots,
25 // a dot at the beginning, or a dot at the end.
26 if (c == '.' &&
27 (result.length == 0 ||
28 i == str.length - 1 ||
29 result.charAt(result.length - 1) == '.')) {
30 continue;
32 result += c;
34 return result;
37 function isValidPseudoHostChar(c) {
38 if (c >= '0' && c <= '9')
39 return true;
40 if (c >= 'a' && c <= 'z')
41 return true;
42 if (c >= 'A' && c <= 'Z')
43 return true;
44 return false;