summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/ShadowRealm/WrappedFunction/throws-typeerror-on-revoked-proxy.js
blob: 5517103de58ef6c9fd2aa1c026b32e9fcd4998bf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// |reftest| shell-option(--enable-shadow-realms) skip-if(!xulRuntime.shell) -- requires shell-options
// Copyright (C) 2022 Chengzhong Wu. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-wrapped-function-exotic-objects-call-thisargument-argumentslist
description: >
    WrappedFunctionCreate throws a TypeError the target is a revoked proxy.

info: |
  WrappedFunctionCreate ( callerRealm: a Realm Record, Target: a function object, )
  1. Let target be F.[[WrappedTargetFunction]].
  2. Assert: IsCallable(target) is true.
  3. Let callerRealm be F.[[Realm]].
  4. NOTE: Any exception objects produced after this point are associated with callerRealm.
  5. Let targetRealm be ? GetFunctionRealm(target).
  ...

  GetFunctionRealm ( obj )
  ...
  3. If obj is a Proxy exotic object, then
    a. If obj.[[ProxyHandler]] is null, throw a TypeError exception.
  ...

features: [ShadowRealm]
---*/

assert.sameValue(
  typeof ShadowRealm.prototype.evaluate,
  'function',
  'This test must fail if ShadowRealm.prototype.evaluate is not a function'
);

const r = new ShadowRealm();

const fn = r.evaluate(`
globalThis.revocable = Proxy.revocable(() => {}, {});

globalThis.revocable.proxy;
`);
r.evaluate('revocable.revoke()');
assert.throws(TypeError, () => fn());

reportCompare(0, 0);