mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-09 17:31:47 +09:00
Bug 1317389: Change property attributes for generator and async functions to match ES2015/2017.
Tag #1287
This commit is contained in:
parent
086d14cb8b
commit
22cd310e82
6 changed files with 209 additions and 12 deletions
76
js/src/tests/ecma_2017/AsyncFunctions/properties.js
Normal file
76
js/src/tests/ecma_2017/AsyncFunctions/properties.js
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
function assertOwnDescriptor(object, propertyKey, expected) {
|
||||
var desc = Object.getOwnPropertyDescriptor(object, propertyKey);
|
||||
if (desc === undefined) {
|
||||
assertEq(expected, undefined, "Property shouldn't be present");
|
||||
return;
|
||||
}
|
||||
|
||||
assertEq(desc.enumerable, expected.enumerable, `${String(propertyKey)}.[[Enumerable]]`);
|
||||
assertEq(desc.configurable, expected.configurable, `${String(propertyKey)}.[[Configurable]]`);
|
||||
|
||||
if (Object.prototype.hasOwnProperty.call(desc, "value")) {
|
||||
assertEq(desc.value, expected.value, `${String(propertyKey)}.[[Value]]`);
|
||||
assertEq(desc.writable, expected.writable, `${String(propertyKey)}.[[Writable]]`);
|
||||
} else {
|
||||
assertEq(desc.get, expected.get, `${String(propertyKey)}.[[Get]]`);
|
||||
assertEq(desc.set, expected.set, `${String(propertyKey)}.[[Set]]`);
|
||||
}
|
||||
}
|
||||
|
||||
async function asyncFunc(){}
|
||||
var AsyncFunctionPrototype = Object.getPrototypeOf(asyncFunc);
|
||||
var AsyncFunction = AsyncFunctionPrototype.constructor;
|
||||
|
||||
|
||||
// ES2017, 25.5.2 Properties of the AsyncFunction Constructor
|
||||
|
||||
assertEqArray(Object.getOwnPropertyNames(AsyncFunction).sort(), ["length", "name", "prototype"]);
|
||||
assertEqArray(Object.getOwnPropertySymbols(AsyncFunction), []);
|
||||
|
||||
assertOwnDescriptor(AsyncFunction, "length", {
|
||||
value: 1, writable: false, enumerable: false, configurable: true
|
||||
});
|
||||
|
||||
assertOwnDescriptor(AsyncFunction, "name", {
|
||||
value: "AsyncFunction", writable: false, enumerable: false, configurable: true
|
||||
});
|
||||
|
||||
assertOwnDescriptor(AsyncFunction, "prototype", {
|
||||
value: AsyncFunctionPrototype, writable: false, enumerable: false, configurable: false
|
||||
});
|
||||
|
||||
|
||||
// ES2017, 25.5.3 Properties of the AsyncFunction Prototype Object
|
||||
|
||||
assertEqArray(Object.getOwnPropertyNames(AsyncFunctionPrototype).sort(), ["constructor"]);
|
||||
assertEqArray(Object.getOwnPropertySymbols(AsyncFunctionPrototype), [Symbol.toStringTag]);
|
||||
|
||||
assertOwnDescriptor(AsyncFunctionPrototype, "constructor", {
|
||||
value: AsyncFunction, writable: false, enumerable: false, configurable: true
|
||||
});
|
||||
|
||||
assertOwnDescriptor(AsyncFunctionPrototype, Symbol.toStringTag, {
|
||||
value: "AsyncFunction", writable: false, enumerable: false, configurable: true
|
||||
});
|
||||
|
||||
|
||||
// ES2017, 25.5.4 AsyncFunction Instances
|
||||
|
||||
assertEqArray(Object.getOwnPropertyNames(asyncFunc).sort(), ["length", "name"]);
|
||||
assertEqArray(Object.getOwnPropertySymbols(asyncFunc), []);
|
||||
|
||||
assertOwnDescriptor(asyncFunc, "length", {
|
||||
value: 0, writable: false, enumerable: false, configurable: true
|
||||
});
|
||||
|
||||
assertOwnDescriptor(asyncFunc, "name", {
|
||||
value: "asyncFunc", writable: false, enumerable: false, configurable: true
|
||||
});
|
||||
|
||||
|
||||
if (typeof reportCompare == "function")
|
||||
reportCompare(true, true);
|
||||
111
js/src/tests/ecma_6/Generators/properties.js
Normal file
111
js/src/tests/ecma_6/Generators/properties.js
Normal file
|
|
@ -0,0 +1,111 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
function assertOwnDescriptor(object, propertyKey, expected) {
|
||||
var desc = Object.getOwnPropertyDescriptor(object, propertyKey);
|
||||
if (desc === undefined) {
|
||||
assertEq(expected, undefined, "Property shouldn't be present");
|
||||
return;
|
||||
}
|
||||
|
||||
assertEq(desc.enumerable, expected.enumerable, `${String(propertyKey)}.[[Enumerable]]`);
|
||||
assertEq(desc.configurable, expected.configurable, `${String(propertyKey)}.[[Configurable]]`);
|
||||
|
||||
if (Object.prototype.hasOwnProperty.call(desc, "value")) {
|
||||
assertEq(desc.value, expected.value, `${String(propertyKey)}.[[Value]]`);
|
||||
assertEq(desc.writable, expected.writable, `${String(propertyKey)}.[[Writable]]`);
|
||||
} else {
|
||||
assertEq(desc.get, expected.get, `${String(propertyKey)}.[[Get]]`);
|
||||
assertEq(desc.set, expected.set, `${String(propertyKey)}.[[Set]]`);
|
||||
}
|
||||
}
|
||||
|
||||
function* generator(){}
|
||||
var GeneratorFunctionPrototype = Object.getPrototypeOf(generator);
|
||||
var GeneratorFunction = GeneratorFunctionPrototype.constructor;
|
||||
var GeneratorPrototype = GeneratorFunctionPrototype.prototype;
|
||||
|
||||
|
||||
// ES2017, 25.2.2 Properties of the GeneratorFunction Constructor
|
||||
|
||||
assertEqArray(Object.getOwnPropertyNames(GeneratorFunction).sort(), ["length", "name", "prototype"]);
|
||||
assertEqArray(Object.getOwnPropertySymbols(GeneratorFunction), []);
|
||||
|
||||
assertOwnDescriptor(GeneratorFunction, "length", {
|
||||
value: 1, writable: false, enumerable: false, configurable: true
|
||||
});
|
||||
|
||||
assertOwnDescriptor(GeneratorFunction, "name", {
|
||||
value: "GeneratorFunction", writable: false, enumerable: false, configurable: true
|
||||
});
|
||||
|
||||
assertOwnDescriptor(GeneratorFunction, "prototype", {
|
||||
value: GeneratorFunctionPrototype, writable: false, enumerable: false, configurable: false
|
||||
});
|
||||
|
||||
|
||||
// ES2017, 25.2.3 Properties of the GeneratorFunction Prototype Object
|
||||
|
||||
assertEqArray(Object.getOwnPropertyNames(GeneratorFunctionPrototype).sort(), ["constructor", "prototype"]);
|
||||
assertEqArray(Object.getOwnPropertySymbols(GeneratorFunctionPrototype), [Symbol.toStringTag]);
|
||||
|
||||
assertOwnDescriptor(GeneratorFunctionPrototype, "constructor", {
|
||||
value: GeneratorFunction, writable: false, enumerable: false, configurable: true
|
||||
});
|
||||
|
||||
assertOwnDescriptor(GeneratorFunctionPrototype, "prototype", {
|
||||
value: GeneratorPrototype, writable: false, enumerable: false, configurable: true
|
||||
});
|
||||
|
||||
assertOwnDescriptor(GeneratorFunctionPrototype, Symbol.toStringTag, {
|
||||
value: "GeneratorFunction", writable: false, enumerable: false, configurable: true
|
||||
});
|
||||
|
||||
|
||||
// ES2017, 25.2.4 GeneratorFunction Instances
|
||||
|
||||
assertEqArray(Object.getOwnPropertyNames(generator).sort(), ["length", "name", "prototype"]);
|
||||
assertEqArray(Object.getOwnPropertySymbols(generator), []);
|
||||
|
||||
assertOwnDescriptor(generator, "length", {
|
||||
value: 0, writable: false, enumerable: false, configurable: true
|
||||
});
|
||||
|
||||
assertOwnDescriptor(generator, "name", {
|
||||
value: "generator", writable: false, enumerable: false, configurable: true
|
||||
});
|
||||
|
||||
assertOwnDescriptor(generator, "prototype", {
|
||||
value: generator.prototype, writable: true, enumerable: false, configurable: false
|
||||
});
|
||||
|
||||
|
||||
// ES2017, 25.3.1 Properties of Generator Prototype
|
||||
|
||||
assertEqArray(Object.getOwnPropertyNames(GeneratorPrototype).sort(), ["constructor", "next", "return", "throw"]);
|
||||
assertEqArray(Object.getOwnPropertySymbols(GeneratorPrototype), [Symbol.toStringTag]);
|
||||
|
||||
assertOwnDescriptor(GeneratorPrototype, "constructor", {
|
||||
value: GeneratorFunctionPrototype, writable: false, enumerable: false, configurable: true
|
||||
});
|
||||
|
||||
assertOwnDescriptor(GeneratorPrototype, "next", {
|
||||
value: GeneratorPrototype.next, writable: true, enumerable: false, configurable: true
|
||||
});
|
||||
|
||||
assertOwnDescriptor(GeneratorPrototype, "return", {
|
||||
value: GeneratorPrototype.return, writable: true, enumerable: false, configurable: true
|
||||
});
|
||||
|
||||
assertOwnDescriptor(GeneratorPrototype, "throw", {
|
||||
value: GeneratorPrototype.throw, writable: true, enumerable: false, configurable: true
|
||||
});
|
||||
|
||||
assertOwnDescriptor(GeneratorPrototype, Symbol.toStringTag, {
|
||||
value: "Generator", writable: false, enumerable: false, configurable: true
|
||||
});
|
||||
|
||||
|
||||
if (typeof reportCompare == "function")
|
||||
reportCompare(true, true);
|
||||
Loading…
Add table
Add a link
Reference in a new issue