Skip to content
This repository has been archived by the owner on Oct 15, 2020. It is now read-only.

Commit

Permalink
[Merge chakra-core/ChakraCore@3c659bbe63] [1.6>1.7] [MERGE #3414 @cur…
Browse files Browse the repository at this point in the history
…tisman] Fix issue #3393: Remove throwing accessor for caller property on argument object in strict mode

Merge pull request #3414 from curtisman:fix3393
  • Loading branch information
chakrabot committed Jul 25, 2017
1 parent f9033a5 commit f421160
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6983,8 +6983,6 @@ namespace Js
if (funcCallee->IsStrictMode())
{
JavascriptFunction* restrictedPropertyAccessor = library->GetThrowTypeErrorRestrictedPropertyAccessorFunction();
argsObj->SetAccessors(PropertyIds::caller, restrictedPropertyAccessor, restrictedPropertyAccessor, PropertyOperation_NonFixedValue);

argsObj->SetAccessors(PropertyIds::callee, restrictedPropertyAccessor, restrictedPropertyAccessor, PropertyOperation_NonFixedValue);

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ namespace Js
{
DictionaryTypeHandlerBase<T> * dictTypeHandler = New(recycler, 8, 0, 0);

dictTypeHandler->Add(scriptContext->GetPropertyName(Js::PropertyIds::caller), PropertyWritable, scriptContext);
dictTypeHandler->Add(scriptContext->GetPropertyName(Js::PropertyIds::callee), PropertyWritable, scriptContext);
dictTypeHandler->Add(scriptContext->GetPropertyName(Js::PropertyIds::length), PropertyBuiltInMethodDefaults, scriptContext);
dictTypeHandler->Add(scriptContext->GetPropertyName(Js::PropertyIds::_symbolIterator), PropertyBuiltInMethodDefaults, scriptContext);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
"locals": {
"arguments": {
"#__proto__": "Object {...}",
"caller": "Error <large string>",
"callee": "Error <large string>",
"length": "number 0",
"Symbol.iterator": "function <large string>"
Expand All @@ -22,4 +21,4 @@
"a": "number 1"
}
}
]
]
2 changes: 1 addition & 1 deletion deps/chakrashim/core/test/es6/classes.js
Original file line number Diff line number Diff line change
Expand Up @@ -948,7 +948,7 @@ var tests = [
{
name: "Extends expression of a class declaration or expression is strict mode",
body: function() {
var BadClass = class extends function() { arguments.caller; } {};
var BadClass = class extends function() { arguments.callee; } {};
assert.throws(function() { Object.getPrototypeOf(BadClass).arguments; }, TypeError, "The extends expression of a class expression should be parsed in strict mode", "'arguments', 'callee' and 'caller' are restricted function properties and cannot be accessed in this context");
assert.throws(function() { new BadClass(); }, TypeError, "New'ing a class with a parent constructor that throws in strict mode, should throw", "'arguments', 'callee' and 'caller' are restricted function properties and cannot be accessed in this context");

Expand Down
13 changes: 1 addition & 12 deletions deps/chakrashim/core/test/strict/05.arguments_sm.baseline
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,6 @@ arguments.callee:setter : function() {
[native code]
}
arguments.callee:value : undefined
arguments.caller:configurable : false
arguments.caller:enumerable : false
arguments.caller:writable : undefined
arguments.caller:getter : function() {
[native code]
}
arguments.caller:setter : function() {
[native code]
}
arguments.caller:value : undefined
Exception: 'arguments', 'callee' and 'caller' are restricted function properties and cannot be accessed in this context
Exception: 'arguments', 'callee' and 'caller' are restricted function properties and cannot be accessed in this context
arguments.caller :propDesc undefined
Exception: 'arguments', 'callee' and 'caller' are restricted function properties and cannot be accessed in this context
Exception: 'arguments', 'callee' and 'caller' are restricted function properties and cannot be accessed in this context
2 changes: 1 addition & 1 deletion deps/chakrashim/core/test/strict/19.function_sm.baseline
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ Exception: function.caller set TypeError
Exception: function.arguments get TypeError
Exception: function.arguments set TypeError
Return: true true: function.arguments and function.caller descriptors are undefined
Return: true true: arguments.caller and arguments.callee are equal/strictEqual to each other
Return: true true: arguments.caller is not defined and arguments.callee getter and setter are equal/strictEqual to each other
Exception: function.caller's value is a strict mode function TypeError
11 changes: 4 additions & 7 deletions deps/chakrashim/core/test/strict/19.function_sm.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,19 +90,16 @@ function exceptToString(ee) {

(function Test5() {
"use strict";
var str = "arguments.caller and arguments.callee are equal/strictEqual to each other";
var str = "arguments.caller is not defined and arguments.callee getter and setter are equal/strictEqual to each other";

// Properties on the arguments object.
var argumentsCallerGet = Object.getOwnPropertyDescriptor(arguments, 'caller').get;
var argumentsCallerSet = Object.getOwnPropertyDescriptor(arguments, 'caller').set;
var argumentsCallerDescriptor = Object.getOwnPropertyDescriptor(arguments, 'caller');
var argumentsCalleeGet = Object.getOwnPropertyDescriptor(arguments, 'callee').get;
var argumentsCalleeSet = Object.getOwnPropertyDescriptor(arguments, 'callee').set;

write("Return: " +
(argumentsCallerGet == argumentsCalleeGet && argumentsCallerSet == argumentsCalleeSet &&
argumentsCallerGet == argumentsCallerSet).toString() + " " +
(argumentsCallerGet === argumentsCalleeGet && argumentsCallerSet === argumentsCalleeSet &&
argumentsCallerGet === argumentsCallerSet).toString() + ": " +
(argumentsCallerDescriptor === undefined).toString() + " " +
(argumentsCalleeGet === argumentsCalleeSet).toString() + ": " +
str);
})();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
(function(){"use strict";echo("hasOwnProperty(caller): ", arguments.hasOwnProperty("caller"));})();
hasOwnProperty(caller): true
hasOwnProperty(caller): false

var foo = function(){"use strict";};(function(){echo("hasOwnProperty(caller): ", foo.hasOwnProperty("caller"));})();
hasOwnProperty(caller): false
Expand All @@ -17,7 +17,6 @@ var foo = function(){"use strict";};(function(){"use strict";echo("hasOwnPropert
hasOwnProperty(arguments): false

(function(){"use strict";arguments.caller;})();
TypeError: 'arguments', 'callee' and 'caller' are restricted function properties and cannot be accessed in this context

var foo = function(){"use strict";};(function(){foo.caller;})();
TypeError: 'arguments', 'callee' and 'caller' are restricted function properties and cannot be accessed in this context
Expand All @@ -35,7 +34,6 @@ var foo = function(){"use strict";};(function(){"use strict";foo.arguments;})();
TypeError: 'arguments', 'callee' and 'caller' are restricted function properties and cannot be accessed in this context

(function(){"use strict";arguments.caller = 0;})();
TypeError: 'arguments', 'callee' and 'caller' are restricted function properties and cannot be accessed in this context

var foo = function(){"use strict";};(function(){foo.caller = 0;})();
TypeError: 'arguments', 'callee' and 'caller' are restricted function properties and cannot be accessed in this context
Expand All @@ -53,7 +51,6 @@ var foo = function(){"use strict";};(function(){"use strict";foo.arguments = 0;}
TypeError: 'arguments', 'callee' and 'caller' are restricted function properties and cannot be accessed in this context

(function(){"use strict";Object.defineProperty(arguments, "caller", {value: 0});})();
TypeError: Cannot redefine non-configurable property 'caller'

var foo = function(){"use strict";};(function(){Object.defineProperty(foo, "caller", {value: 0});})();

Expand All @@ -67,8 +64,7 @@ var foo = function(){"use strict";};(function(){Object.defineProperty(foo, "argu
var foo = function(){"use strict";};(function(){"use strict";Object.defineProperty(foo, "arguments", {value: 0});})();

(function(){"use strict";var descriptor = Object.getOwnPropertyDescriptor(arguments, "caller");if(descriptor.hasOwnProperty("get")) safeCall(descriptor.get);if(descriptor.hasOwnProperty("set")) safeCall(descriptor.set);})();
TypeError: 'arguments', 'callee' and 'caller' are restricted function properties and cannot be accessed in this context
TypeError: 'arguments', 'callee' and 'caller' are restricted function properties and cannot be accessed in this context
TypeError: Unable to get property 'hasOwnProperty' of undefined or null reference

var foo = function(){"use strict";};(function(){var descriptor = Object.getOwnPropertyDescriptor(foo, "caller");if(descriptor.hasOwnProperty("get")) safeCall(descriptor.get);if(descriptor.hasOwnProperty("set")) safeCall(descriptor.set);})();
TypeError: Unable to get property 'hasOwnProperty' of undefined or null reference
Expand Down

0 comments on commit f421160

Please sign in to comment.