mirror of https://github.com/tc39/test262.git
Relax [[DefineOwnProperty]] on module namespace exotic objects.
See https://github.com/tc39/ecma262/pull/858.
This commit is contained in:
parent
c0b520b8c9
commit
fd5054f463
|
@ -3,9 +3,8 @@
|
||||||
/*---
|
/*---
|
||||||
esid: sec-module-namespace-exotic-objects-defineownproperty-p-desc
|
esid: sec-module-namespace-exotic-objects-defineownproperty-p-desc
|
||||||
description: >
|
description: >
|
||||||
The [[DefineOwnProperty]] internal method consistently returns `false`
|
The [[DefineOwnProperty]] internal method returns `true` if no change is
|
||||||
info: |
|
requested, and `false` otherwise.
|
||||||
1. Return false.
|
|
||||||
flags: [module]
|
flags: [module]
|
||||||
features: [Reflect, Symbol, Symbol.toStringTag]
|
features: [Reflect, Symbol, Symbol.toStringTag]
|
||||||
---*/
|
---*/
|
||||||
|
@ -17,63 +16,101 @@ export { local2 as renamed };
|
||||||
export { local1 as indirect } from './define-own-property.js';
|
export { local1 as indirect } from './define-own-property.js';
|
||||||
var sym = Symbol('test262');
|
var sym = Symbol('test262');
|
||||||
|
|
||||||
assert.sameValue(
|
const exported = ['local1', 'renamed', 'indirect'];
|
||||||
Reflect.defineProperty(ns, 'local1', {}),
|
|
||||||
false,
|
|
||||||
'Reflect.defineProperty: local1'
|
// Non-existant properties.
|
||||||
);
|
|
||||||
assert.throws(TypeError, function() {
|
for (const key of ['local2', 0, sym, Symbol.iterator]) {
|
||||||
Object.defineProperty(ns, 'local1', {});
|
assert.sameValue(
|
||||||
}, 'Object.defineProperty: local1');
|
Reflect.defineProperty(ns, key, {}),
|
||||||
|
false,
|
||||||
|
'Reflect.defineProperty: ' + key.toString()
|
||||||
|
);
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
Object.defineProperty(ns, key, {});
|
||||||
|
}, 'Object.defineProperty: ' + key.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Own properties. No change requested.
|
||||||
|
|
||||||
|
for (const key of ([...exported, Symbol.toStringTag])) {
|
||||||
|
assert.sameValue(
|
||||||
|
Reflect.defineProperty(ns, key, {}),
|
||||||
|
true,
|
||||||
|
'Reflect.defineProperty: ' + key.toString()
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
Object.defineProperty(ns, key, {}),
|
||||||
|
ns,
|
||||||
|
'Object.defineProperty: ' + key.toString()
|
||||||
|
);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
assert.sameValue(
|
assert.sameValue(
|
||||||
Reflect.defineProperty(ns, 'local2', {}),
|
Reflect.defineProperty(ns, 'indirect',
|
||||||
false,
|
{writable: true, enumerable: true, configurable: false}),
|
||||||
'Reflect.defineProperty: local2'
|
true,
|
||||||
|
'Reflect.defineProperty: indirect'
|
||||||
|
);
|
||||||
|
assert.sameValue(
|
||||||
|
Object.defineProperty(ns, 'indirect',
|
||||||
|
{writable: true, enumerable: true, configurable: false}),
|
||||||
|
ns,
|
||||||
|
'Object.defineProperty: indirect'
|
||||||
);
|
);
|
||||||
assert.throws(TypeError, function() {
|
|
||||||
Object.defineProperty(ns, 'local2', {});
|
|
||||||
}, 'Object.defineProperty: local2');
|
|
||||||
|
|
||||||
assert.sameValue(
|
assert.sameValue(
|
||||||
Reflect.defineProperty(ns, 'renamed', {}),
|
Reflect.defineProperty(ns, Symbol.toStringTag,
|
||||||
false,
|
{value: "Module", writable: false, enumerable: false,
|
||||||
'Reflect.defineProperty: renamed'
|
configurable: false}),
|
||||||
|
true,
|
||||||
|
'Reflect.defineProperty: Symbol.toStringTag'
|
||||||
);
|
);
|
||||||
assert.throws(TypeError, function() {
|
assert.sameValue(
|
||||||
Object.defineProperty(ns, 'renamed', {});
|
Object.defineProperty(ns, Symbol.toStringTag,
|
||||||
}, 'Object.defineProperty: renamed');
|
{value: "Module", writable: false, enumerable: false,
|
||||||
|
configurable: false}),
|
||||||
|
ns,
|
||||||
|
'Object.defineProperty: Symbol.toStringTag'
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
// Own properties. Change requested.
|
||||||
|
|
||||||
|
for (const key of ([...exported, Symbol.toStringTag])) {
|
||||||
|
assert.sameValue(
|
||||||
|
Reflect.defineProperty(ns, key, {value: 123}),
|
||||||
|
false,
|
||||||
|
'Reflect.defineProperty: ' + key.toString()
|
||||||
|
);
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
Object.defineProperty(ns, key, {value: 123});
|
||||||
|
}, 'Object.defineProperty: ' + key.toString());
|
||||||
|
}
|
||||||
|
|
||||||
assert.sameValue(
|
assert.sameValue(
|
||||||
Reflect.defineProperty(ns, 'indirect', {}),
|
Reflect.defineProperty(ns, 'indirect',
|
||||||
|
{writable: true, enumerable: true, configurable: true}),
|
||||||
false,
|
false,
|
||||||
'Reflect.defineProperty: indirect'
|
'Reflect.defineProperty: indirect'
|
||||||
);
|
);
|
||||||
assert.throws(TypeError, function() {
|
assert.throws(TypeError, function() {
|
||||||
Object.defineProperty(ns, 'indirect', {});
|
Object.defineProperty(ns, 'indirect',
|
||||||
|
{writable: true, enumerable: true, configurable: true});
|
||||||
}, 'Object.defineProperty: indirect');
|
}, 'Object.defineProperty: indirect');
|
||||||
|
|
||||||
assert.sameValue(
|
assert.sameValue(
|
||||||
Reflect.defineProperty(ns, 'default', {}),
|
Reflect.defineProperty(ns, Symbol.toStringTag,
|
||||||
false,
|
{value: "module", writable: false, enumerable: false,
|
||||||
'Reflect.defineProperty: default'
|
configurable: false}),
|
||||||
);
|
|
||||||
assert.throws(TypeError, function() {
|
|
||||||
Object.defineProperty(ns, 'default', {});
|
|
||||||
}, 'Object.defineProperty: default');
|
|
||||||
|
|
||||||
assert.sameValue(
|
|
||||||
Reflect.defineProperty(ns, Symbol.toStringTag, {}),
|
|
||||||
false,
|
false,
|
||||||
'Reflect.defineProperty: Symbol.toStringTag'
|
'Reflect.defineProperty: Symbol.toStringTag'
|
||||||
);
|
);
|
||||||
assert.throws(TypeError, function() {
|
assert.throws(TypeError, function() {
|
||||||
Object.defineProperty(ns, Symbol.toStringTag, {});
|
Object.defineProperty(ns, Symbol.toStringTag,
|
||||||
|
{value: "module", writable: false, enumerable: false,
|
||||||
|
configurable: false});
|
||||||
}, 'Object.defineProperty: Symbol.toStringTag');
|
}, 'Object.defineProperty: Symbol.toStringTag');
|
||||||
|
|
||||||
assert.sameValue(
|
|
||||||
Reflect.defineProperty(ns, sym, {}), false, 'Reflect.defineProperty: sym'
|
|
||||||
);
|
|
||||||
assert.throws(TypeError, function() {
|
|
||||||
Object.defineProperty(ns, sym, {});
|
|
||||||
}, 'Object.defineProperty: symbol');
|
|
||||||
|
|
Loading…
Reference in New Issue