diff options
author | Ben Noordhuis <info@bnoordhuis.nl> | 2015-06-19 13:23:56 +0200 |
---|---|---|
committer | Rod Vagg <rod@vagg.org> | 2015-08-04 11:56:14 -0700 |
commit | 70d1f32f5605465a1a630a64f6f0d35f96c7709d (patch) | |
tree | 0a349040a686eafcb0a09943ebc733477dce2781 /deps/v8/test/webkit/fast/js | |
parent | 4643b8b6671607a7aff60cbbd0b384dcf2f6959e (diff) | |
download | node-new-70d1f32f5605465a1a630a64f6f0d35f96c7709d.tar.gz |
deps: update v8 to 4.4.63.9
Upgrade the bundled V8 and update code in src/ and lib/ to the new API.
Notable backwards incompatible changes are the removal of the smalloc
module and dropped support for CESU-8 decoding. CESU-8 support can be
brought back if necessary by doing UTF-8 decoding ourselves.
This commit includes https://codereview.chromium.org/1192973004 to fix
a build error on python 2.6 systems. The original commit log follows:
Use optparse in js2c.py for python compatibility
Without this change, V8 won't build on RHEL/CentOS 6 because the
distro python is too old to know about the argparse module.
PR-URL: https://github.com/nodejs/io.js/pull/2022
Reviewed-By: Rod Vagg <rod@vagg.org>
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
Diffstat (limited to 'deps/v8/test/webkit/fast/js')
6 files changed, 39 insertions, 171 deletions
diff --git a/deps/v8/test/webkit/fast/js/Object-getOwnPropertyNames-expected.txt b/deps/v8/test/webkit/fast/js/Object-getOwnPropertyNames-expected.txt index 0e00f23cad..1948700fca 100644 --- a/deps/v8/test/webkit/fast/js/Object-getOwnPropertyNames-expected.txt +++ b/deps/v8/test/webkit/fast/js/Object-getOwnPropertyNames-expected.txt @@ -38,12 +38,12 @@ PASS getSortedOwnPropertyNames(parseInt) is ['arguments', 'caller', 'length', 'n PASS getSortedOwnPropertyNames(parseFloat) is ['arguments', 'caller', 'length', 'name'] PASS getSortedOwnPropertyNames(isNaN) is ['arguments', 'caller', 'length', 'name'] PASS getSortedOwnPropertyNames(isFinite) is ['arguments', 'caller', 'length', 'name'] -PASS getSortedOwnPropertyNames(escape) is ['arguments', 'caller', 'length', 'name'] -PASS getSortedOwnPropertyNames(unescape) is ['arguments', 'caller', 'length', 'name'] -PASS getSortedOwnPropertyNames(decodeURI) is ['arguments', 'caller', 'length', 'name'] -PASS getSortedOwnPropertyNames(decodeURIComponent) is ['arguments', 'caller', 'length', 'name'] -PASS getSortedOwnPropertyNames(encodeURI) is ['arguments', 'caller', 'length', 'name'] -PASS getSortedOwnPropertyNames(encodeURIComponent) is ['arguments', 'caller', 'length', 'name'] +PASS getSortedOwnPropertyNames(escape) is ['length', 'name'] +PASS getSortedOwnPropertyNames(unescape) is ['length', 'name'] +PASS getSortedOwnPropertyNames(decodeURI) is ['length', 'name'] +PASS getSortedOwnPropertyNames(decodeURIComponent) is ['length', 'name'] +PASS getSortedOwnPropertyNames(encodeURI) is ['length', 'name'] +PASS getSortedOwnPropertyNames(encodeURIComponent) is ['length', 'name'] PASS getSortedOwnPropertyNames(Object) is ['arguments', 'caller', 'create', 'defineProperties', 'defineProperty', 'deliverChangeRecords', 'freeze', 'getNotifier', 'getOwnPropertyDescriptor', 'getOwnPropertyNames', 'getOwnPropertySymbols', 'getPrototypeOf', 'is', 'isExtensible', 'isFrozen', 'isSealed', 'keys', 'length', 'name', 'observe', 'preventExtensions', 'prototype', 'seal', 'setPrototypeOf', 'unobserve'] PASS getSortedOwnPropertyNames(Object.prototype) is ['__defineGetter__', '__defineSetter__', '__lookupGetter__', '__lookupSetter__', '__proto__', 'constructor', 'hasOwnProperty', 'isPrototypeOf', 'propertyIsEnumerable', 'toLocaleString', 'toString', 'valueOf'] PASS getSortedOwnPropertyNames(Function) is ['arguments', 'caller', 'length', 'name', 'prototype'] diff --git a/deps/v8/test/webkit/fast/js/Object-getOwnPropertyNames.js b/deps/v8/test/webkit/fast/js/Object-getOwnPropertyNames.js index 72bd21b426..20e509ba96 100644 --- a/deps/v8/test/webkit/fast/js/Object-getOwnPropertyNames.js +++ b/deps/v8/test/webkit/fast/js/Object-getOwnPropertyNames.js @@ -64,12 +64,12 @@ var expectedPropertyNamesSet = { "parseFloat": "['arguments', 'caller', 'length', 'name']", "isNaN": "['arguments', 'caller', 'length', 'name']", "isFinite": "['arguments', 'caller', 'length', 'name']", - "escape": "['arguments', 'caller', 'length', 'name']", - "unescape": "['arguments', 'caller', 'length', 'name']", - "decodeURI": "['arguments', 'caller', 'length', 'name']", - "decodeURIComponent": "['arguments', 'caller', 'length', 'name']", - "encodeURI": "['arguments', 'caller', 'length', 'name']", - "encodeURIComponent": "['arguments', 'caller', 'length', 'name']", + "escape": "['length', 'name']", + "unescape": "['length', 'name']", + "decodeURI": "['length', 'name']", + "decodeURIComponent": "['length', 'name']", + "encodeURI": "['length', 'name']", + "encodeURIComponent": "['length', 'name']", // Built-in ECMA objects "Object": "['arguments', 'caller', 'create', 'defineProperties', 'defineProperty', 'deliverChangeRecords', 'freeze', 'getNotifier', 'getOwnPropertyDescriptor', 'getOwnPropertyNames', 'getOwnPropertySymbols', 'getPrototypeOf', 'is', 'isExtensible', 'isFrozen', 'isSealed', 'keys', 'length', 'name', 'observe', 'preventExtensions', 'prototype', 'seal', 'setPrototypeOf', 'unobserve']", "Object.prototype": "['__defineGetter__', '__defineSetter__', '__lookupGetter__', '__lookupSetter__', '__proto__', 'constructor', 'hasOwnProperty', 'isPrototypeOf', 'propertyIsEnumerable', 'toLocaleString', 'toString', 'valueOf']", diff --git a/deps/v8/test/webkit/fast/js/basic-strict-mode-expected.txt b/deps/v8/test/webkit/fast/js/basic-strict-mode-expected.txt index 0e6228e161..1fcf0c1acb 100644 --- a/deps/v8/test/webkit/fast/js/basic-strict-mode-expected.txt +++ b/deps/v8/test/webkit/fast/js/basic-strict-mode-expected.txt @@ -81,20 +81,22 @@ PASS (function (){'use strict'; with(1){};}) threw exception SyntaxError: Strict PASS (function(){(function (){'use strict'; with(1){};})}) threw exception SyntaxError: Strict mode code may not include a with statement. PASS (function (){'use strict'; arguments.callee; })() threw exception TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them. PASS (function (){'use strict'; arguments.caller; })() threw exception TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them. -PASS (function f(){'use strict'; f.arguments; })() threw exception TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them. -PASS (function f(){'use strict'; f.caller; })() threw exception TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them. -PASS (function f(){'use strict'; f.arguments=5; })() threw exception TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them. -PASS (function f(){'use strict'; f.caller=5; })() threw exception TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them. +PASS (function f(){'use strict'; f.arguments; })() threw exception TypeError: 'caller' and 'arguments' are restricted function properties and cannot be accessed in this context.. +PASS (function f(){'use strict'; f.caller; })() threw exception TypeError: 'caller' and 'arguments' are restricted function properties and cannot be accessed in this context.. +PASS (function f(){'use strict'; f.arguments=5; })() threw exception TypeError: 'caller' and 'arguments' are restricted function properties and cannot be accessed in this context.. +PASS (function f(){'use strict'; f.caller=5; })() threw exception TypeError: 'caller' and 'arguments' are restricted function properties and cannot be accessed in this context.. PASS (function (arg){'use strict'; arguments.callee; })() threw exception TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them. PASS (function (arg){'use strict'; arguments.caller; })() threw exception TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them. -PASS (function f(arg){'use strict'; f.arguments; })() threw exception TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them. -PASS (function f(arg){'use strict'; f.caller; })() threw exception TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them. -PASS (function f(arg){'use strict'; f.arguments=5; })() threw exception TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them. -PASS (function f(arg){'use strict'; f.caller=5; })() threw exception TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them. +PASS (function f(arg){'use strict'; f.arguments; })() threw exception TypeError: 'caller' and 'arguments' are restricted function properties and cannot be accessed in this context.. +PASS (function f(arg){'use strict'; f.caller; })() threw exception TypeError: 'caller' and 'arguments' are restricted function properties and cannot be accessed in this context.. +PASS (function f(arg){'use strict'; f.arguments=5; })() threw exception TypeError: 'caller' and 'arguments' are restricted function properties and cannot be accessed in this context.. +PASS (function f(arg){'use strict'; f.caller=5; })() threw exception TypeError: 'caller' and 'arguments' are restricted function properties and cannot be accessed in this context.. PASS "caller" in function(){"use strict"} is true -PASS (function(){"use strict";}).hasOwnProperty("caller") is true +PASS (function(){"use strict";}).hasOwnProperty("caller") is false +PASS (function(){"use strict";}).__proto__.hasOwnProperty("caller") is true PASS "arguments" in function(){"use strict"} is true -PASS (function(){"use strict";}).hasOwnProperty("arguments") is true +PASS (function(){"use strict";}).hasOwnProperty("arguments") is false +PASS (function(){"use strict";}).__proto__.hasOwnProperty("arguments") is true PASS 'use strict'; (function (){with(1){};}) threw exception SyntaxError: Strict mode code may not include a with statement. PASS (function(){'use strict'; (function (){with(1){};})}) threw exception SyntaxError: Strict mode code may not include a with statement. PASS 'use strict'; (function (){var a; delete a;}) threw exception SyntaxError: Delete of an unqualified identifier in strict mode.. @@ -195,14 +197,14 @@ PASS (function (a){'use strict'; var local; (function (){local;})(); arguments[0 PASS (function (){'use strict'; var local; (function (){local;})(); arguments[0]=true; return arguments; })()[0] is true PASS 'use strict'; (function (){var a = true; eval('var a = false'); return a; })() is true PASS (function (){var a = true; eval('"use strict"; var a = false'); return a; })() is true -PASS (function f(arg){'use strict'; return Object.getOwnPropertyDescriptor(f, 'arguments').value; })() is undefined. -PASS (function f(arg){'use strict'; return Object.getOwnPropertyDescriptor(f, 'caller').value; })() is undefined. +PASS (function f(arg){'use strict'; return Object.getOwnPropertyDescriptor(f.__proto__, 'arguments').value; })() is undefined. +PASS (function f(arg){'use strict'; return Object.getOwnPropertyDescriptor(f.__proto__, 'caller').value; })() is undefined. PASS (function f(arg){'use strict'; return Object.getOwnPropertyDescriptor(arguments, 'callee').value; })() is undefined. PASS (function f(arg){'use strict'; return Object.getOwnPropertyDescriptor(arguments, 'caller').value; })() is undefined. PASS (function f(arg){'use strict'; var descriptor = Object.getOwnPropertyDescriptor(arguments, 'caller'); return descriptor.get === descriptor.set; })() is true PASS (function f(arg){'use strict'; var descriptor = Object.getOwnPropertyDescriptor(arguments, 'callee'); return descriptor.get === descriptor.set; })() is true -PASS (function f(arg){'use strict'; var descriptor = Object.getOwnPropertyDescriptor(f, 'caller'); return descriptor.get === descriptor.set; })() is true -PASS (function f(arg){'use strict'; var descriptor = Object.getOwnPropertyDescriptor(f, 'arguments'); return descriptor.get === descriptor.set; })() is true +PASS (function f(arg){'use strict'; var descriptor = Object.getOwnPropertyDescriptor(f.__proto__, 'caller'); return descriptor.get === descriptor.set; })() is true +PASS (function f(arg){'use strict'; var descriptor = Object.getOwnPropertyDescriptor(f.__proto__, 'arguments'); return descriptor.get === descriptor.set; })() is true PASS 'use strict'; (function f() { for(var i in this); })(); true; is true PASS 'use strict'̻ threw exception SyntaxError: Unexpected token ILLEGAL. PASS (function(){'use strict'̻}) threw exception SyntaxError: Unexpected token ILLEGAL. @@ -228,7 +230,7 @@ PASS (function () {'use strict'; try { throw 1; } catch (e) { aGlobal = true; } PASS try { throw 1; } catch (e) { aGlobal = true; } is true PASS (function () { try { throw 1; } catch (e) { aGlobal = true; }})(); aGlobal; is true PASS (function () {try { throw 1; } catch (e) { aGlobal = true; }})(); aGlobal; is true -FAIL String(Object.getOwnPropertyDescriptor(function() { "use strict"; }, "caller").get) should be function () { +FAIL String(Object.getOwnPropertyDescriptor((function() { "use strict"; }).__proto__, "caller").get) should be function () { [native code] }. Was function ThrowTypeError() { [native code] }. PASS successfullyParsed is true diff --git a/deps/v8/test/webkit/fast/js/basic-strict-mode.js b/deps/v8/test/webkit/fast/js/basic-strict-mode.js index f34b14e7ae..1687b2e5e7 100644 --- a/deps/v8/test/webkit/fast/js/basic-strict-mode.js +++ b/deps/v8/test/webkit/fast/js/basic-strict-mode.js @@ -109,11 +109,13 @@ shouldThrow("(function f(arg){'use strict'; f.caller; })()"); shouldThrow("(function f(arg){'use strict'; f.arguments=5; })()"); shouldThrow("(function f(arg){'use strict'; f.caller=5; })()"); -// arguments/caller poisoning should be visible but not throw with 'in' & 'hasOwnProperty'. +// arguments/caller poisoning should be visible on the intrinsic %FunctionPrototype%, but not throw with 'in' & 'hasOwnProperty'. shouldBeTrue('"caller" in function(){"use strict"}'); -shouldBeTrue('(function(){"use strict";}).hasOwnProperty("caller")'); +shouldBeFalse('(function(){"use strict";}).hasOwnProperty("caller")'); +shouldBeTrue('(function(){"use strict";}).__proto__.hasOwnProperty("caller")'); shouldBeTrue('"arguments" in function(){"use strict"}'); -shouldBeTrue('(function(){"use strict";}).hasOwnProperty("arguments")'); +shouldBeFalse('(function(){"use strict";}).hasOwnProperty("arguments")'); +shouldBeTrue('(function(){"use strict";}).__proto__.hasOwnProperty("arguments")'); shouldBeSyntaxError("'use strict'; (function (){with(1){};})"); shouldBeSyntaxError("'use strict'; (function (){var a; delete a;})"); @@ -194,14 +196,14 @@ shouldBeTrue("(function (){'use strict'; var local; (function (){local;})(); ar shouldBeTrue("'use strict'; (function (){var a = true; eval('var a = false'); return a; })()"); shouldBeTrue("(function (){var a = true; eval('\"use strict\"; var a = false'); return a; })()"); -shouldBeUndefined("(function f(arg){'use strict'; return Object.getOwnPropertyDescriptor(f, 'arguments').value; })()"); -shouldBeUndefined("(function f(arg){'use strict'; return Object.getOwnPropertyDescriptor(f, 'caller').value; })()"); +shouldBeUndefined("(function f(arg){'use strict'; return Object.getOwnPropertyDescriptor(f.__proto__, 'arguments').value; })()"); +shouldBeUndefined("(function f(arg){'use strict'; return Object.getOwnPropertyDescriptor(f.__proto__, 'caller').value; })()"); shouldBeUndefined("(function f(arg){'use strict'; return Object.getOwnPropertyDescriptor(arguments, 'callee').value; })()"); shouldBeUndefined("(function f(arg){'use strict'; return Object.getOwnPropertyDescriptor(arguments, 'caller').value; })()"); shouldBeTrue("(function f(arg){'use strict'; var descriptor = Object.getOwnPropertyDescriptor(arguments, 'caller'); return descriptor.get === descriptor.set; })()"); shouldBeTrue("(function f(arg){'use strict'; var descriptor = Object.getOwnPropertyDescriptor(arguments, 'callee'); return descriptor.get === descriptor.set; })()"); -shouldBeTrue("(function f(arg){'use strict'; var descriptor = Object.getOwnPropertyDescriptor(f, 'caller'); return descriptor.get === descriptor.set; })()"); -shouldBeTrue("(function f(arg){'use strict'; var descriptor = Object.getOwnPropertyDescriptor(f, 'arguments'); return descriptor.get === descriptor.set; })()"); +shouldBeTrue("(function f(arg){'use strict'; var descriptor = Object.getOwnPropertyDescriptor(f.__proto__, 'caller'); return descriptor.get === descriptor.set; })()"); +shouldBeTrue("(function f(arg){'use strict'; var descriptor = Object.getOwnPropertyDescriptor(f.__proto__, 'arguments'); return descriptor.get === descriptor.set; })()"); shouldBeTrue("'use strict'; (function f() { for(var i in this); })(); true;") shouldBeSyntaxError("'use strict'\u033b"); @@ -228,4 +230,4 @@ aGlobal = false; shouldBeTrue("(function () {try { throw 1; } catch (e) { aGlobal = true; }})(); aGlobal;"); // Make sure this doesn't crash! -shouldBe('String(Object.getOwnPropertyDescriptor(function() { "use strict"; }, "caller").get)', "'function () {\\n [native code]\\n}'"); +shouldBe('String(Object.getOwnPropertyDescriptor((function() { "use strict"; }).__proto__, "caller").get)', "'function () {\\n [native code]\\n}'"); diff --git a/deps/v8/test/webkit/fast/js/caller-property-expected.txt b/deps/v8/test/webkit/fast/js/caller-property-expected.txt deleted file mode 100644 index a5d4dd2c14..0000000000 --- a/deps/v8/test/webkit/fast/js/caller-property-expected.txt +++ /dev/null @@ -1,51 +0,0 @@ -# Copyright 2013 the V8 project authors. All rights reserved. -# Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY -# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -# DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY -# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -This tests for caller property in functions. Only functions that are called from inside of other functions and have a parent should have this property set. Tests return true when caller is found and false when the caller is null. - -On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". - - -PASS childHasCallerWhenExecutingGlobalCode is false -PASS childHasCallerWhenCalledWithoutParent is false -PASS childHasCallerWhenCalledFromWithinParent is true -PASS nonStrictCaller(nonStrictCallee) is nonStrictCaller -FAIL nonStrictCaller(strictCallee) should throw TypeError: Type error. Threw exception TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them. -FAIL strictCaller(nonStrictCallee) should throw TypeError: Function.caller used to retrieve strict caller. Was null. -FAIL strictCaller(strictCallee) should throw TypeError: Type error. Threw exception TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them. -PASS nonStrictCaller(boundNonStrictCallee) is nonStrictCaller -FAIL nonStrictCaller(boundStrictCallee) should throw TypeError: Type error. Threw exception TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them. -FAIL strictCaller(boundNonStrictCallee) should throw TypeError: Function.caller used to retrieve strict caller. Was null. -FAIL strictCaller(boundStrictCallee) should throw TypeError: Type error. Threw exception TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them. -PASS nonStrictGetter(nonStrictAccessor) is nonStrictGetter -PASS nonStrictSetter(nonStrictAccessor) is true -FAIL nonStrictGetter(strictAccessor) should throw TypeError: Type error. Threw exception TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them. -FAIL nonStrictSetter(strictAccessor) should throw TypeError: Type error. Threw exception TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them. -FAIL strictGetter(nonStrictAccessor) should throw TypeError: Function.caller used to retrieve strict caller. Was null. -FAIL strictSetter(nonStrictAccessor) should throw TypeError: Function.caller used to retrieve strict caller. Was undefined. -FAIL strictGetter(strictAccessor) should throw TypeError: Type error. Threw exception TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them. -FAIL strictSetter(strictAccessor) should throw TypeError: Type error. Threw exception TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them. -PASS successfullyParsed is true - -TEST COMPLETE - diff --git a/deps/v8/test/webkit/fast/js/caller-property.js b/deps/v8/test/webkit/fast/js/caller-property.js deleted file mode 100644 index d28ccf8c50..0000000000 --- a/deps/v8/test/webkit/fast/js/caller-property.js +++ /dev/null @@ -1,85 +0,0 @@ -// Copyright 2013 the V8 project authors. All rights reserved. -// Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions -// are met: -// 1. Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// 2. Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND ANY -// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY -// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -description( -'This tests for caller property in functions. Only functions that are called from inside of other functions and have a parent should have this property set. Tests return true when caller is found and false when the caller is null.' -) -function child() -{ - return (child.caller !== null); -} - -function parent() -{ - return child(); -} - -var childHasCallerWhenExecutingGlobalCode = (child.caller !== null); -var childHasCallerWhenCalledWithoutParent = child(); -var childHasCallerWhenCalledFromWithinParent = parent(); - -shouldBe('childHasCallerWhenExecutingGlobalCode', 'false'); -shouldBe('childHasCallerWhenCalledWithoutParent', 'false'); -shouldBe('childHasCallerWhenCalledFromWithinParent', 'true') - -// The caller property should throw in strict mode, and a non-strict function cannot use caller to reach a strict caller (see ES5.1 15.3.5.4). -function nonStrictCallee() { return nonStrictCallee.caller; } -function strictCallee() { "use strict"; return strictCallee.caller; } -function nonStrictCaller(x) { return x(); } -function strictCaller(x) { "use strict"; return x(); } -shouldBe("nonStrictCaller(nonStrictCallee)", "nonStrictCaller"); -shouldThrow("nonStrictCaller(strictCallee)", '"TypeError: Type error"'); -shouldThrow("strictCaller(nonStrictCallee)", '"TypeError: Function.caller used to retrieve strict caller"'); -shouldThrow("strictCaller(strictCallee)", '"TypeError: Type error"'); - -// .caller within a bound function reaches the caller, ignoring the binding. -var boundNonStrictCallee = nonStrictCallee.bind(); -var boundStrictCallee = strictCallee.bind(); -shouldBe("nonStrictCaller(boundNonStrictCallee)", "nonStrictCaller"); -shouldThrow("nonStrictCaller(boundStrictCallee)", '"TypeError: Type error"'); -shouldThrow("strictCaller(boundNonStrictCallee)", '"TypeError: Function.caller used to retrieve strict caller"'); -shouldThrow("strictCaller(boundStrictCallee)", '"TypeError: Type error"'); - -// Check that .caller works (or throws) as expected, over an accessor call. -function getFooGetter(x) { return Object.getOwnPropertyDescriptor(x, 'foo').get; } -function getFooSetter(x) { return Object.getOwnPropertyDescriptor(x, 'foo').set; } -var nonStrictAccessor = { - get foo() { return getFooGetter(nonStrictAccessor).caller; }, - set foo(x) { if (getFooSetter(nonStrictAccessor).caller !==x) throw false; } -}; -var strictAccessor = { - get foo() { "use strict"; return getFooGetter(strictAccessor).caller; }, - set foo(x) { "use strict"; if (getFooSetter(strictAccessor).caller !==x) throw false; } -}; -function nonStrictGetter(x) { return x.foo; } -function nonStrictSetter(x) { x.foo = nonStrictSetter; return true; } -function strictGetter(x) { "use strict"; return x.foo; } -function strictSetter(x) { "use strict"; x.foo = nonStrictSetter; return true; } -shouldBe("nonStrictGetter(nonStrictAccessor)", "nonStrictGetter"); -shouldBeTrue("nonStrictSetter(nonStrictAccessor)"); -shouldThrow("nonStrictGetter(strictAccessor)", '"TypeError: Type error"'); -shouldThrow("nonStrictSetter(strictAccessor)", '"TypeError: Type error"'); -shouldThrow("strictGetter(nonStrictAccessor)", '"TypeError: Function.caller used to retrieve strict caller"'); -shouldThrow("strictSetter(nonStrictAccessor)", '"TypeError: Function.caller used to retrieve strict caller"'); -shouldThrow("strictGetter(strictAccessor)", '"TypeError: Type error"'); -shouldThrow("strictSetter(strictAccessor)", '"TypeError: Type error"'); |