summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/Object/prototype/__proto__/set-non-extensible.js
blob: f0bb8212c7c9061a238478b53adbd1dd2e04187f (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
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-object.prototype.__proto__
es6id: B.2.2.1
description: Called on an non-extensible object
info: |
    [...]
    4. Let status be ? O.[[SetPrototypeOf]](proto).
    5. If status is false, throw a TypeError exception.

    9.1.2.1 OrdinarySetPrototypeOf

    [...]
    2. Let extensible be the value of the [[Extensible]] internal slot of O.
    3. Let current be the value of the [[Prototype]] internal slot of O.
    4. If SameValue(V, current) is true, return true.
    5. If extensible is false, return false.
features: [__proto__]
---*/

var proto = {};
var subject = Object.create(proto);

Object.preventExtensions(subject);

subject.__proto__ = proto;

assert.throws(TypeError, function() {
  subject.__proto__ = {};
});

assert.sameValue(Object.getPrototypeOf(subject), proto);

reportCompare(0, 0);