Fix the value of the caller property of function instances (#4258)

We do not support the caller information for functions, and since a
'null' value represents that there has been no caller, the default value
should be changed to 'undefined' to signal that the information is not
available.

JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai daniel.batyai@h-lab.eu
This commit is contained in:
Dániel Bátyai
2020-10-01 12:10:11 +02:00
committed by GitHub
parent 69d9b2c326
commit b9e4897c71
4 changed files with 49 additions and 32 deletions
@@ -12,8 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.
var props = ['arguments', 'caller'];
function f_simple () {
}
@@ -21,27 +19,48 @@ function f_strict () {
"use strict";
}
for (let prop of props) {
try {
Function.prototype[prop];
assert(false);
} catch (e) {
assert(e instanceof TypeError);
}
assert(f_simple[prop] === null);
try {
f_strict[prop];
assert(false);
} catch (e) {
assert(e instanceof TypeError);
}
let desc = Object.getOwnPropertyDescriptor(f_simple, prop);
assert(desc.value === null);
assert(desc.writable === false);
assert(desc.enumerable === false);
assert(desc.configurable === false);
assert(Object.getOwnPropertyDescriptor(f_strict, prop) === undefined);
try {
Function.prototype["arguments"];
assert(false);
} catch (e) {
assert(e instanceof TypeError);
}
assert(f_simple["arguments"] === null);
try {
f_strict["arguments"];
assert(false);
} catch (e) {
assert(e instanceof TypeError);
}
let desc = Object.getOwnPropertyDescriptor(f_simple, "arguments");
assert(desc.value === null);
assert(desc.writable === false);
assert(desc.enumerable === false);
assert(desc.configurable === false);
assert(Object.getOwnPropertyDescriptor(f_strict, "arguments") === undefined);
try {
Function.prototype["caller"];
assert(false);
} catch (e) {
assert(e instanceof TypeError);
}
assert(f_simple["caller"] === undefined);
try {
f_strict["caller"];
assert(false);
} catch (e) {
assert(e instanceof TypeError);
}
desc = Object.getOwnPropertyDescriptor(f_simple, "caller");
assert(desc.value === undefined);
assert(desc.writable === false);
assert(desc.enumerable === false);
assert(desc.configurable === false);
assert(Object.getOwnPropertyDescriptor(f_strict, "arguments") === undefined);