archives

« Bugzilla Issues Index

#2856 — 9.2.8 AddRestrictedFunctionProperties: Use %ThrowTypeError% from function's [[Realm]]?


9.2.8 AddRestrictedFunctionProperties Abstract Operation

AddRestrictedFunctionProperties uses the current execution context's realm instead of the function's [[Realm]] (if present for that function - bound functions also call AddRestrictedFunctionProperties, but they don't have a [[Realm]] slot). That means cloning a function with Function.prototype.toMethod() from a different realm won't preserve the original function's %ThrowTypeError%.

Question: Does it need to preserve the original function's %ThrowTypeError%?

Test case:
---
let r = new Reflect.Realm()
let f = r.eval("function f() {'use strict'} f")
let clone = Function.prototype.toMethod.call(f, {})
Object.getPrototypeOf(f) === Object.getPrototypeOf(clone); // Evaluates to true

let foreignThrower = Object.getOwnPropertyDescriptor(f, "caller").get;
let cloneThrower = Object.getOwnPropertyDescriptor(clone, "caller").get;
foreignThrower === cloneThrower; // Evaluates to false
---


yes it does

fixed in rev25 editor's draft


fixed in rev25 editor's draft