michael@0: // |jit-test| error: done michael@0: michael@0: var g1 = newGlobal('same-compartment'); michael@0: var g2 = newGlobal(); michael@0: var proxyStr = "Proxy.create( "+ michael@0: " { getOwnPropertyDescriptor: function() assertEq(true,false), "+ michael@0: " getPropertyDescriptor: function() assertEq(true,false), "+ michael@0: " getOwnPropertyNames: function() assertEq(true,false), "+ michael@0: " getPropertyNames: function() assertEq(true,false), "+ michael@0: " defineProperty: function() assertEq(true,false), "+ michael@0: " delete: function() assertEq(true,false), "+ michael@0: " fix: function() assertEq(true,false), }, "+ michael@0: " Object.prototype "+ michael@0: "); "; michael@0: var proxy1 = g1.eval(proxyStr); michael@0: var proxy2 = g2.eval(proxyStr); michael@0: michael@0: function test(str, f) { michael@0: "use strict"; michael@0: michael@0: var x = f(eval(str)); michael@0: assertEq(x, f(g1.eval(str))); michael@0: assertEq(x, f(g2.eval(str))); michael@0: michael@0: var threw = false; michael@0: try { michael@0: f(g1.eval("new Object()")); michael@0: } catch (e) { michael@0: assertEq(Object.prototype.toString.call(e), "[object Error]"); michael@0: threw = true; michael@0: } michael@0: assertEq(threw, true); michael@0: threw = false; michael@0: try { michael@0: f(g2.eval("new Object()")); michael@0: } catch (e) { michael@0: assertEq(Object.prototype.toString.call(e), "[object Error]"); michael@0: threw = true; michael@0: } michael@0: assertEq(threw, true); michael@0: threw = false; michael@0: try { michael@0: f(proxy1); michael@0: } catch (e) { michael@0: assertEq(Object.prototype.toString.call(e), "[object Error]"); michael@0: threw = true; michael@0: } michael@0: assertEq(threw, true); michael@0: threw = false; michael@0: try { michael@0: f(proxy2); michael@0: } catch (e) { michael@0: assertEq(Object.prototype.toString.call(e), "[object Error]"); michael@0: threw = true; michael@0: } michael@0: assertEq(threw, true); michael@0: } michael@0: michael@0: test("new Array(1,2,3)", function(a) Array.prototype.toSource.call(a)); michael@0: test("new Boolean(true)", function(b) Boolean.prototype.toSource.call(b)); michael@0: test("new Boolean(true)", function(b) Boolean.prototype.toString.call(b)); michael@0: test("new Boolean(true)", function(b) Boolean.prototype.valueOf.call(b)); michael@0: test("new Number(1)", function(n) Number.prototype.toSource.call(n)); michael@0: test("new Number(1)", function(n) Number.prototype.toString.call(n)); michael@0: test("new Number(1)", function(n) Number.prototype.valueOf.call(n)); michael@0: test("new Number(1)", function(n) Number.prototype.toFixed.call(n)); michael@0: test("new Number(1)", function(n) Number.prototype.toExponential.call(n)); michael@0: test("new Number(1)", function(n) Number.prototype.toPrecision.call(n)); michael@0: test("new Iterator({x:1})", function(i) Iterator.prototype.next.call(i).toString()); michael@0: test("(function(){yield 1})()", function(i) (function(){yield})().next.call(i).toString()); michael@0: test("new String('one')", function(s) String.prototype.toSource.call(s)); michael@0: test("new String('one')", function(s) String.prototype.toString.call(s)); michael@0: test("new RegExp('1')", function(r) RegExp.prototype.toString.call(r)); michael@0: test("new RegExp('1')", function(r) RegExp.prototype.exec.call(r, '1').toString()); michael@0: test("new RegExp('1')", function(r) RegExp.prototype.test.call(r, '1')); michael@0: test("new RegExp('1')", function(r) RegExp.prototype.compile.call(r, '1').toString()); michael@0: test("new RegExp('1')", function(r) assertEq("a1".search(r), 1)); michael@0: test("new RegExp('1')", function(r) assertEq("a1".match(r)[0], '1')); michael@0: test("new RegExp('1')", function(r) assertEq("a1".replace(r, 'A'), 'aA')); michael@0: test("new RegExp('1')", function(r) assertEq(String("a1b".split(r)), "a,b")); michael@0: test("new RegExp('1')", function(r) assertEq(r, RegExp(r))); michael@0: test("new RegExp('1')", function(r) assertEq(String(new RegExp(r)), String(r))); michael@0: test("new RegExp('1')", function(r) assertEq(String(/x/.compile(r)), String(r))); michael@0: test("new WeakMap()", function(w) WeakMap.prototype.has.call(w, {})); michael@0: test("new WeakMap()", function(w) WeakMap.prototype.get.call(w, {})); michael@0: test("new WeakMap()", function(w) WeakMap.prototype.delete.call(w, {})); michael@0: test("new WeakMap()", function(w) WeakMap.prototype.set.call(w, {})); michael@0: test("new Map()", function(w) Map.prototype.has.call(w, {})); michael@0: test("new Map()", function(w) Map.prototype.get.call(w, {})); michael@0: test("new Map()", function(w) Map.prototype.delete.call(w, {})); michael@0: test("new Map()", function(w) Map.prototype.set.call(w, {})); michael@0: test("new Set()", function(w) Set.prototype.has.call(w, {})); michael@0: test("new Set()", function(w) Set.prototype.add.call(w, {})); michael@0: test("new Set()", function(w) Set.prototype.delete.call(w, {})); michael@0: michael@0: test("new Int8Array(1)", function(a) Int8Array.prototype.subarray.call(a).toString()); michael@0: test("new Uint8Array(1)", function(a) Uint8Array.prototype.subarray.call(a).toString()); michael@0: test("new Int16Array(1)", function(a) Int16Array.prototype.subarray.call(a).toString()); michael@0: test("new Uint16Array(1)", function(a) Uint16Array.prototype.subarray.call(a).toString()); michael@0: test("new Int32Array(1)", function(a) Int32Array.prototype.subarray.call(a).toString()); michael@0: test("new Uint32Array(1)", function(a) Uint32Array.prototype.subarray.call(a).toString()); michael@0: test("new Float32Array(1)", function(a) Float32Array.prototype.subarray.call(a).toString()); michael@0: test("new Float64Array(1)", function(a) Float64Array.prototype.subarray.call(a).toString()); michael@0: test("new Uint8ClampedArray(1)", function(a) Uint8ClampedArray.prototype.subarray.call(a).toString()); michael@0: michael@0: test("new Int8Array(1)", function(a) Int8Array.subarray(a).toString()); michael@0: test("new Uint8Array(1)", function(a) Uint8Array.subarray(a).toString()); michael@0: test("new Int16Array(1)", function(a) Int16Array.subarray(a).toString()); michael@0: test("new Uint16Array(1)", function(a) Uint16Array.subarray(a).toString()); michael@0: test("new Int32Array(1)", function(a) Int32Array.subarray(a).toString()); michael@0: test("new Uint32Array(1)", function(a) Uint32Array.subarray(a).toString()); michael@0: test("new Float32Array(1)", function(a) Float32Array.subarray(a).toString()); michael@0: test("new Float64Array(1)", function(a) Float64Array.subarray(a).toString()); michael@0: test("new Uint8ClampedArray(1)", function(a) Uint8ClampedArray.subarray(a).toString()); michael@0: michael@0: test("new Int8Array(1)", function(a) Int8Array.prototype.set.call(a, [])); michael@0: test("new Uint8Array(1)", function(a) Uint8Array.prototype.set.call(a, [])); michael@0: test("new Int16Array(1)", function(a) Int16Array.prototype.set.call(a, [])); michael@0: test("new Uint16Array(1)", function(a) Uint16Array.prototype.set.call(a, [])); michael@0: test("new Int32Array(1)", function(a) Int32Array.prototype.set.call(a, [])); michael@0: test("new Uint32Array(1)", function(a) Uint32Array.prototype.set.call(a, [])); michael@0: test("new Float32Array(1)", function(a) Float32Array.prototype.set.call(a, [])); michael@0: test("new Float64Array(1)", function(a) Float64Array.prototype.set.call(a, [])); michael@0: test("new Uint8ClampedArray(1)", function(a) Uint8ClampedArray.prototype.set.call(a, [])); michael@0: michael@0: function justDontThrow() {} michael@0: test("new Date()", function(d) justDontThrow(Date.prototype.getTime.call(d))); michael@0: test("new Date()", function(d) justDontThrow(Date.prototype.getYear.call(d))); michael@0: test("new Date()", function(d) justDontThrow(Date.prototype.getFullYear.call(d))); michael@0: test("new Date()", function(d) justDontThrow(Date.prototype.getUTCFullYear.call(d))); michael@0: test("new Date()", function(d) justDontThrow(Date.prototype.getMonth.call(d))); michael@0: test("new Date()", function(d) justDontThrow(Date.prototype.getUTCMonth.call(d))); michael@0: test("new Date()", function(d) justDontThrow(Date.prototype.getDate.call(d))); michael@0: test("new Date()", function(d) justDontThrow(Date.prototype.getUTCDate.call(d))); michael@0: test("new Date()", function(d) justDontThrow(Date.prototype.getDay.call(d))); michael@0: test("new Date()", function(d) justDontThrow(Date.prototype.getUTCDay.call(d))); michael@0: test("new Date()", function(d) justDontThrow(Date.prototype.getHours.call(d))); michael@0: test("new Date()", function(d) justDontThrow(Date.prototype.getUTCHours.call(d))); michael@0: test("new Date()", function(d) justDontThrow(Date.prototype.getMinutes.call(d))); michael@0: test("new Date()", function(d) justDontThrow(Date.prototype.getUTCMinutes.call(d))); michael@0: test("new Date()", function(d) justDontThrow(Date.prototype.getSeconds.call(d))); michael@0: test("new Date()", function(d) justDontThrow(Date.prototype.getUTCSeconds.call(d))); michael@0: test("new Date()", function(d) justDontThrow(Date.prototype.getTimezoneOffset.call(d))); michael@0: test("new Date()", function(d) justDontThrow(Date.prototype.setTime.call(d))); michael@0: test("new Date()", function(d) justDontThrow(Date.prototype.setMilliseconds.call(d))); michael@0: test("new Date()", function(d) justDontThrow(Date.prototype.setUTCMilliseconds.call(d))); michael@0: test("new Date()", function(d) justDontThrow(Date.prototype.setSeconds.call(d))); michael@0: test("new Date()", function(d) justDontThrow(Date.prototype.setUTCSeconds.call(d))); michael@0: test("new Date()", function(d) justDontThrow(Date.prototype.setMinutes.call(d))); michael@0: test("new Date()", function(d) justDontThrow(Date.prototype.setUTCMinutes.call(d))); michael@0: test("new Date()", function(d) justDontThrow(Date.prototype.setHours.call(d))); michael@0: test("new Date()", function(d) justDontThrow(Date.prototype.setUTCHours.call(d))); michael@0: test("new Date()", function(d) justDontThrow(Date.prototype.setDate.call(d))); michael@0: test("new Date()", function(d) justDontThrow(Date.prototype.setUTCDate.call(d))); michael@0: test("new Date()", function(d) justDontThrow(Date.prototype.setMonth.call(d))); michael@0: test("new Date()", function(d) justDontThrow(Date.prototype.setUTCMonth.call(d))); michael@0: test("new Date()", function(d) justDontThrow(Date.prototype.setFullYear.call(d))); michael@0: test("new Date()", function(d) justDontThrow(Date.prototype.setUTCFullYear.call(d))); michael@0: test("new Date()", function(d) justDontThrow(Date.prototype.setYear.call(d))); michael@0: test("new Date()", function(d) justDontThrow(Date.prototype.toGMTString.call(d))); michael@0: test("new Date()", function(d) justDontThrow(Date.prototype.toISOString.call(d))); michael@0: test("new Date()", function(d) justDontThrow(Date.prototype.toLocaleString.call(d))); michael@0: test("new Date()", function(d) justDontThrow(Date.prototype.toLocaleDateString.call(d))); michael@0: test("new Date()", function(d) justDontThrow(Date.prototype.toLocaleTimeString.call(d))); michael@0: test("new Date()", function(d) justDontThrow(Date.prototype.toLocaleFormat.call(d))); michael@0: test("new Date()", function(d) justDontThrow(Date.prototype.toTimeString.call(d))); michael@0: test("new Date()", function(d) justDontThrow(Date.prototype.toDateString.call(d))); michael@0: test("new Date()", function(d) justDontThrow(Date.prototype.toSource.call(d))); michael@0: test("new Date()", function(d) justDontThrow(Date.prototype.toString.call(d))); michael@0: test("new Date()", function(d) justDontThrow(Date.prototype.valueOf.call(d))); michael@0: michael@0: throw "done";