summaryrefslogtreecommitdiffstats
path: root/net/data/proxy_resolver_v8_unittest/bindings.js
blob: 0e748c1335f0cefb5d9f974b7ea6a433bad72410 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// Try calling the browser-side bound functions with varying (invalid)
// inputs. There is no notion of "success" for this test, other than
// verifying the correct C++ bindings were reached with expected values.

function MyObject() {
  this.x = "3";
}

MyObject.prototype.toString = function() {
  throw "exception from calling toString()";
}

function FindProxyForURL(url, host) {
  // Call dnsResolve with some wonky arguments.
  dnsResolve();
  dnsResolve(null);
  dnsResolve(undefined);
  dnsResolve("");
  dnsResolve({foo: 'bar'});
  dnsResolve(fn);
  dnsResolve(['3']);
  dnsResolve("arg1", "arg2", "arg3", "arg4");

  // Call alert with some wonky arguments.
  alert();
  alert(null);
  alert(undefined);
  alert({foo:'bar'});

  // This should throw an exception when we toString() the argument
  // to alert in the bindings.
  try {
    alert(new MyObject());
  } catch (e) {
    alert(e);
  }

  // Call myIpAddress() with wonky arguments 
  myIpAddress(null);
  myIpAddress(null, null);

  return "DIRECT";
}

function fn() {}