Przeglądaj źródła

[MERGE #3414 @curtisman] Fix issue #3393: Remove throwing accessor for caller property on argument object in strict mode

Merge pull request #3414 from curtisman:fix3393
Curtis Man 8 lat temu
rodzic
commit
90b8e49fce

+ 0 - 2
lib/Runtime/Language/JavascriptOperators.cpp

@@ -6975,8 +6975,6 @@ CommonNumber:
         if (funcCallee->IsStrictMode())
         {
             JavascriptFunction* restrictedPropertyAccessor = library->GetThrowTypeErrorRestrictedPropertyAccessorFunction();
-            argsObj->SetAccessors(PropertyIds::caller, restrictedPropertyAccessor, restrictedPropertyAccessor, PropertyOperation_NonFixedValue);
-
             argsObj->SetAccessors(PropertyIds::callee, restrictedPropertyAccessor, restrictedPropertyAccessor, PropertyOperation_NonFixedValue);
 
         }

+ 0 - 1
lib/Runtime/Types/DictionaryTypeHandler.cpp

@@ -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);

+ 1 - 2
test/DebuggerCommon/ES6_letconst_eval_strict_fn.js.dbg.baseline

@@ -6,7 +6,6 @@
     "locals": {
       "arguments": {
         "#__proto__": "Object {...}",
-        "caller": "Error <large string>",
         "callee": "Error <large string>",
         "length": "number 0",
         "Symbol.iterator": "function <large string>"
@@ -22,4 +21,4 @@
       "a": "number 1"
     }
   }
-]
+]

+ 1 - 1
test/es6/classes.js

@@ -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");
 

+ 1 - 12
test/strict/05.arguments_sm.baseline

@@ -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

+ 1 - 1
test/strict/19.function_sm.baseline

@@ -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

+ 4 - 7
test/strict/19.function_sm.js

@@ -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);
 })();
 

+ 2 - 6
test/strict/22.callerCalleeArguments_sm.baseline

@@ -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
@@ -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
@@ -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
@@ -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});})();
 
@@ -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