|
1 // |jit-test| error: done |
|
2 |
|
3 var g1 = newGlobal('same-compartment'); |
|
4 var g2 = newGlobal(); |
|
5 var proxyStr = "Proxy.create( "+ |
|
6 " { getOwnPropertyDescriptor: function() assertEq(true,false), "+ |
|
7 " getPropertyDescriptor: function() assertEq(true,false), "+ |
|
8 " getOwnPropertyNames: function() assertEq(true,false), "+ |
|
9 " getPropertyNames: function() assertEq(true,false), "+ |
|
10 " defineProperty: function() assertEq(true,false), "+ |
|
11 " delete: function() assertEq(true,false), "+ |
|
12 " fix: function() assertEq(true,false), }, "+ |
|
13 " Object.prototype "+ |
|
14 "); "; |
|
15 var proxy1 = g1.eval(proxyStr); |
|
16 var proxy2 = g2.eval(proxyStr); |
|
17 |
|
18 function test(str, f) { |
|
19 "use strict"; |
|
20 |
|
21 var x = f(eval(str)); |
|
22 assertEq(x, f(g1.eval(str))); |
|
23 assertEq(x, f(g2.eval(str))); |
|
24 |
|
25 var threw = false; |
|
26 try { |
|
27 f(g1.eval("new Object()")); |
|
28 } catch (e) { |
|
29 assertEq(Object.prototype.toString.call(e), "[object Error]"); |
|
30 threw = true; |
|
31 } |
|
32 assertEq(threw, true); |
|
33 threw = false; |
|
34 try { |
|
35 f(g2.eval("new Object()")); |
|
36 } catch (e) { |
|
37 assertEq(Object.prototype.toString.call(e), "[object Error]"); |
|
38 threw = true; |
|
39 } |
|
40 assertEq(threw, true); |
|
41 threw = false; |
|
42 try { |
|
43 f(proxy1); |
|
44 } catch (e) { |
|
45 assertEq(Object.prototype.toString.call(e), "[object Error]"); |
|
46 threw = true; |
|
47 } |
|
48 assertEq(threw, true); |
|
49 threw = false; |
|
50 try { |
|
51 f(proxy2); |
|
52 } catch (e) { |
|
53 assertEq(Object.prototype.toString.call(e), "[object Error]"); |
|
54 threw = true; |
|
55 } |
|
56 assertEq(threw, true); |
|
57 } |
|
58 |
|
59 test("new Array(1,2,3)", function(a) Array.prototype.toSource.call(a)); |
|
60 test("new Boolean(true)", function(b) Boolean.prototype.toSource.call(b)); |
|
61 test("new Boolean(true)", function(b) Boolean.prototype.toString.call(b)); |
|
62 test("new Boolean(true)", function(b) Boolean.prototype.valueOf.call(b)); |
|
63 test("new Number(1)", function(n) Number.prototype.toSource.call(n)); |
|
64 test("new Number(1)", function(n) Number.prototype.toString.call(n)); |
|
65 test("new Number(1)", function(n) Number.prototype.valueOf.call(n)); |
|
66 test("new Number(1)", function(n) Number.prototype.toFixed.call(n)); |
|
67 test("new Number(1)", function(n) Number.prototype.toExponential.call(n)); |
|
68 test("new Number(1)", function(n) Number.prototype.toPrecision.call(n)); |
|
69 test("new Iterator({x:1})", function(i) Iterator.prototype.next.call(i).toString()); |
|
70 test("(function(){yield 1})()", function(i) (function(){yield})().next.call(i).toString()); |
|
71 test("new String('one')", function(s) String.prototype.toSource.call(s)); |
|
72 test("new String('one')", function(s) String.prototype.toString.call(s)); |
|
73 test("new RegExp('1')", function(r) RegExp.prototype.toString.call(r)); |
|
74 test("new RegExp('1')", function(r) RegExp.prototype.exec.call(r, '1').toString()); |
|
75 test("new RegExp('1')", function(r) RegExp.prototype.test.call(r, '1')); |
|
76 test("new RegExp('1')", function(r) RegExp.prototype.compile.call(r, '1').toString()); |
|
77 test("new RegExp('1')", function(r) assertEq("a1".search(r), 1)); |
|
78 test("new RegExp('1')", function(r) assertEq("a1".match(r)[0], '1')); |
|
79 test("new RegExp('1')", function(r) assertEq("a1".replace(r, 'A'), 'aA')); |
|
80 test("new RegExp('1')", function(r) assertEq(String("a1b".split(r)), "a,b")); |
|
81 test("new RegExp('1')", function(r) assertEq(r, RegExp(r))); |
|
82 test("new RegExp('1')", function(r) assertEq(String(new RegExp(r)), String(r))); |
|
83 test("new RegExp('1')", function(r) assertEq(String(/x/.compile(r)), String(r))); |
|
84 test("new WeakMap()", function(w) WeakMap.prototype.has.call(w, {})); |
|
85 test("new WeakMap()", function(w) WeakMap.prototype.get.call(w, {})); |
|
86 test("new WeakMap()", function(w) WeakMap.prototype.delete.call(w, {})); |
|
87 test("new WeakMap()", function(w) WeakMap.prototype.set.call(w, {})); |
|
88 test("new Map()", function(w) Map.prototype.has.call(w, {})); |
|
89 test("new Map()", function(w) Map.prototype.get.call(w, {})); |
|
90 test("new Map()", function(w) Map.prototype.delete.call(w, {})); |
|
91 test("new Map()", function(w) Map.prototype.set.call(w, {})); |
|
92 test("new Set()", function(w) Set.prototype.has.call(w, {})); |
|
93 test("new Set()", function(w) Set.prototype.add.call(w, {})); |
|
94 test("new Set()", function(w) Set.prototype.delete.call(w, {})); |
|
95 |
|
96 test("new Int8Array(1)", function(a) Int8Array.prototype.subarray.call(a).toString()); |
|
97 test("new Uint8Array(1)", function(a) Uint8Array.prototype.subarray.call(a).toString()); |
|
98 test("new Int16Array(1)", function(a) Int16Array.prototype.subarray.call(a).toString()); |
|
99 test("new Uint16Array(1)", function(a) Uint16Array.prototype.subarray.call(a).toString()); |
|
100 test("new Int32Array(1)", function(a) Int32Array.prototype.subarray.call(a).toString()); |
|
101 test("new Uint32Array(1)", function(a) Uint32Array.prototype.subarray.call(a).toString()); |
|
102 test("new Float32Array(1)", function(a) Float32Array.prototype.subarray.call(a).toString()); |
|
103 test("new Float64Array(1)", function(a) Float64Array.prototype.subarray.call(a).toString()); |
|
104 test("new Uint8ClampedArray(1)", function(a) Uint8ClampedArray.prototype.subarray.call(a).toString()); |
|
105 |
|
106 test("new Int8Array(1)", function(a) Int8Array.subarray(a).toString()); |
|
107 test("new Uint8Array(1)", function(a) Uint8Array.subarray(a).toString()); |
|
108 test("new Int16Array(1)", function(a) Int16Array.subarray(a).toString()); |
|
109 test("new Uint16Array(1)", function(a) Uint16Array.subarray(a).toString()); |
|
110 test("new Int32Array(1)", function(a) Int32Array.subarray(a).toString()); |
|
111 test("new Uint32Array(1)", function(a) Uint32Array.subarray(a).toString()); |
|
112 test("new Float32Array(1)", function(a) Float32Array.subarray(a).toString()); |
|
113 test("new Float64Array(1)", function(a) Float64Array.subarray(a).toString()); |
|
114 test("new Uint8ClampedArray(1)", function(a) Uint8ClampedArray.subarray(a).toString()); |
|
115 |
|
116 test("new Int8Array(1)", function(a) Int8Array.prototype.set.call(a, [])); |
|
117 test("new Uint8Array(1)", function(a) Uint8Array.prototype.set.call(a, [])); |
|
118 test("new Int16Array(1)", function(a) Int16Array.prototype.set.call(a, [])); |
|
119 test("new Uint16Array(1)", function(a) Uint16Array.prototype.set.call(a, [])); |
|
120 test("new Int32Array(1)", function(a) Int32Array.prototype.set.call(a, [])); |
|
121 test("new Uint32Array(1)", function(a) Uint32Array.prototype.set.call(a, [])); |
|
122 test("new Float32Array(1)", function(a) Float32Array.prototype.set.call(a, [])); |
|
123 test("new Float64Array(1)", function(a) Float64Array.prototype.set.call(a, [])); |
|
124 test("new Uint8ClampedArray(1)", function(a) Uint8ClampedArray.prototype.set.call(a, [])); |
|
125 |
|
126 function justDontThrow() {} |
|
127 test("new Date()", function(d) justDontThrow(Date.prototype.getTime.call(d))); |
|
128 test("new Date()", function(d) justDontThrow(Date.prototype.getYear.call(d))); |
|
129 test("new Date()", function(d) justDontThrow(Date.prototype.getFullYear.call(d))); |
|
130 test("new Date()", function(d) justDontThrow(Date.prototype.getUTCFullYear.call(d))); |
|
131 test("new Date()", function(d) justDontThrow(Date.prototype.getMonth.call(d))); |
|
132 test("new Date()", function(d) justDontThrow(Date.prototype.getUTCMonth.call(d))); |
|
133 test("new Date()", function(d) justDontThrow(Date.prototype.getDate.call(d))); |
|
134 test("new Date()", function(d) justDontThrow(Date.prototype.getUTCDate.call(d))); |
|
135 test("new Date()", function(d) justDontThrow(Date.prototype.getDay.call(d))); |
|
136 test("new Date()", function(d) justDontThrow(Date.prototype.getUTCDay.call(d))); |
|
137 test("new Date()", function(d) justDontThrow(Date.prototype.getHours.call(d))); |
|
138 test("new Date()", function(d) justDontThrow(Date.prototype.getUTCHours.call(d))); |
|
139 test("new Date()", function(d) justDontThrow(Date.prototype.getMinutes.call(d))); |
|
140 test("new Date()", function(d) justDontThrow(Date.prototype.getUTCMinutes.call(d))); |
|
141 test("new Date()", function(d) justDontThrow(Date.prototype.getSeconds.call(d))); |
|
142 test("new Date()", function(d) justDontThrow(Date.prototype.getUTCSeconds.call(d))); |
|
143 test("new Date()", function(d) justDontThrow(Date.prototype.getTimezoneOffset.call(d))); |
|
144 test("new Date()", function(d) justDontThrow(Date.prototype.setTime.call(d))); |
|
145 test("new Date()", function(d) justDontThrow(Date.prototype.setMilliseconds.call(d))); |
|
146 test("new Date()", function(d) justDontThrow(Date.prototype.setUTCMilliseconds.call(d))); |
|
147 test("new Date()", function(d) justDontThrow(Date.prototype.setSeconds.call(d))); |
|
148 test("new Date()", function(d) justDontThrow(Date.prototype.setUTCSeconds.call(d))); |
|
149 test("new Date()", function(d) justDontThrow(Date.prototype.setMinutes.call(d))); |
|
150 test("new Date()", function(d) justDontThrow(Date.prototype.setUTCMinutes.call(d))); |
|
151 test("new Date()", function(d) justDontThrow(Date.prototype.setHours.call(d))); |
|
152 test("new Date()", function(d) justDontThrow(Date.prototype.setUTCHours.call(d))); |
|
153 test("new Date()", function(d) justDontThrow(Date.prototype.setDate.call(d))); |
|
154 test("new Date()", function(d) justDontThrow(Date.prototype.setUTCDate.call(d))); |
|
155 test("new Date()", function(d) justDontThrow(Date.prototype.setMonth.call(d))); |
|
156 test("new Date()", function(d) justDontThrow(Date.prototype.setUTCMonth.call(d))); |
|
157 test("new Date()", function(d) justDontThrow(Date.prototype.setFullYear.call(d))); |
|
158 test("new Date()", function(d) justDontThrow(Date.prototype.setUTCFullYear.call(d))); |
|
159 test("new Date()", function(d) justDontThrow(Date.prototype.setYear.call(d))); |
|
160 test("new Date()", function(d) justDontThrow(Date.prototype.toGMTString.call(d))); |
|
161 test("new Date()", function(d) justDontThrow(Date.prototype.toISOString.call(d))); |
|
162 test("new Date()", function(d) justDontThrow(Date.prototype.toLocaleString.call(d))); |
|
163 test("new Date()", function(d) justDontThrow(Date.prototype.toLocaleDateString.call(d))); |
|
164 test("new Date()", function(d) justDontThrow(Date.prototype.toLocaleTimeString.call(d))); |
|
165 test("new Date()", function(d) justDontThrow(Date.prototype.toLocaleFormat.call(d))); |
|
166 test("new Date()", function(d) justDontThrow(Date.prototype.toTimeString.call(d))); |
|
167 test("new Date()", function(d) justDontThrow(Date.prototype.toDateString.call(d))); |
|
168 test("new Date()", function(d) justDontThrow(Date.prototype.toSource.call(d))); |
|
169 test("new Date()", function(d) justDontThrow(Date.prototype.toString.call(d))); |
|
170 test("new Date()", function(d) justDontThrow(Date.prototype.valueOf.call(d))); |
|
171 |
|
172 throw "done"; |