summaryrefslogtreecommitdiffstats
path: root/js/src/jsfun.cpp
diff options
context:
space:
mode:
authorGaming4JC <g4jc@hyperbola.info>2019-06-08 15:15:05 -0400
committerGaming4JC <g4jc@hyperbola.info>2019-07-18 22:38:15 -0400
commit7535217e1b164417d9aa05c38e5c23048c8d47ce (patch)
tree6e6712cafd514c11770c1a1d0c4496c4e0bc6480 /js/src/jsfun.cpp
parent90d999c59a08bfc3145317aa4f0a92db0597632e (diff)
downloadUXP-7535217e1b164417d9aa05c38e5c23048c8d47ce.tar
UXP-7535217e1b164417d9aa05c38e5c23048c8d47ce.tar.gz
UXP-7535217e1b164417d9aa05c38e5c23048c8d47ce.tar.lz
UXP-7535217e1b164417d9aa05c38e5c23048c8d47ce.tar.xz
UXP-7535217e1b164417d9aa05c38e5c23048c8d47ce.zip
1325473 - A TypeError should be thrown when accessing 'arguments' or 'caller' on any of the new function types.
Diffstat (limited to 'js/src/jsfun.cpp')
-rw-r--r--js/src/jsfun.cpp13
1 files changed, 11 insertions, 2 deletions
diff --git a/js/src/jsfun.cpp b/js/src/jsfun.cpp
index 304700da2..ef5aea768 100644
--- a/js/src/jsfun.cpp
+++ b/js/src/jsfun.cpp
@@ -129,6 +129,11 @@ IsFunctionInStrictMode(JSFunction* fun)
return IsAsmJSStrictModeModuleOrFunction(fun);
}
+static bool
+IsNewerTypeFunction(JSFunction* fun) {
+ return fun->isArrow() || fun->isGenerator() || fun->isAsync() || fun->isMethod();
+}
+
// Beware: this function can be invoked on *any* function! That includes
// natives, strict mode functions, bound functions, arrow functions,
// self-hosted functions and constructors, asm.js functions, functions with
@@ -142,7 +147,9 @@ ArgumentsRestrictions(JSContext* cx, HandleFunction fun)
// a strict mode function, or a bound function.
// TODO (bug 1057208): ensure semantics are correct for all possible
// pairings of callee/caller.
- if (fun->isBuiltin() || IsFunctionInStrictMode(fun) || fun->isBoundFunction()) {
+ if (fun->isBuiltin() || IsFunctionInStrictMode(fun) ||
+ fun->isBoundFunction() || IsNewerTypeFunction(fun))
+ {
ThrowTypeErrorBehavior(cx);
return false;
}
@@ -229,7 +236,9 @@ CallerRestrictions(JSContext* cx, HandleFunction fun)
// a strict mode function, or a bound function.
// TODO (bug 1057208): ensure semantics are correct for all possible
// pairings of callee/caller.
- if (fun->isBuiltin() || IsFunctionInStrictMode(fun) || fun->isBoundFunction()) {
+ if (fun->isBuiltin() || IsFunctionInStrictMode(fun) ||
+ fun->isBoundFunction() || IsNewerTypeFunction(fun))
+ {
ThrowTypeErrorBehavior(cx);
return false;
}