summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/ShadowRealm/WrappedFunction/length-throws-typeerror.js
blob: e6271daf3deb8162a82ebd25e983bcd3536a45c1 (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
// |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-wrappedfunctioncreate
description: >
  WrappedFunctionCreate throws a TypeError from its caller realm.
info: |
  WrappedFunctionCreate ( callerRealm: a Realm Record, Target: a function object, )

  ...
  7. Let result be CopyNameAndLength(wrapped, Target).
  8. If result is an Abrupt Completion, 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();

assert.throws(TypeError, () => r.evaluate(`
function fn() {}
Object.defineProperty(fn, 'length', {
  get: () => {
    throw new Error('blah');
  },
  enumerable: false,
  configurable: true,
});
fn;
`), 'expect a TypeError on length getter throwing');

reportCompare(0, 0);