summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/language/types/reference/put-value-prop-base-primitive-realm.js
blob: 77f2787c70ba83153929e3038101b19cce8bb6e3 (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
44
45
46
47
48
49
50
51
// 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-putvalue
es6id: 6.2.3.2
description: >
  When the base of a property reference is primitive, it is coerced to an
  object during value assignment (honoring the realm of the current execution
  context)
info: |
  [...]
  6. Else if IsPropertyReference(V) is true, then
     a. If HasPrimitiveBase(V) is true, then
        i. Assert: In this case, base will never be null or undefined.
        ii. Set base to ToObject(base).
     b. Let succeeded be ? base.[[Set]](GetReferencedName(V), W,
        GetThisValue(V)).
     c. If succeeded is false and IsStrictReference(V) is true, throw a
        TypeError exception.
     d. Return.
features: [cross-realm, Symbol, Proxy]
---*/

var other = $262.createRealm().global;
var numberCount = 0;
var stringCount = 0;
var booleanCount = 0;
var symbolCount = 0;
var spy;

spy = new Proxy({}, { set: function() { numberCount += 1; return true; } });
Object.setPrototypeOf(other.Number.prototype, spy);
other.eval('0..test262 = null;');
assert.sameValue(numberCount, 1, 'number');

spy = new Proxy({}, { set: function() { stringCount += 1; return true; } });
Object.setPrototypeOf(other.String.prototype, spy);
other.eval('"".test262 = null;');
assert.sameValue(stringCount, 1, 'string');

spy = new Proxy({}, { set: function() { booleanCount += 1; return true; } });
Object.setPrototypeOf(other.Boolean.prototype, spy);
other.eval('true.test262 = null;');
assert.sameValue(booleanCount, 1, 'string');

spy = new Proxy({}, { set: function() { symbolCount += 1; return true; } });
Object.setPrototypeOf(other.Symbol.prototype, spy);
other.eval('Symbol().test262 = null;');
assert.sameValue(symbolCount, 1, 'string');

reportCompare(0, 0);