// Cross-Realm tests. // // Note: When |g| is a cross-compartment global, Promise.allSettled creates // the result array in |g|'s Realm. This doesn't follow the spec, but the code // in js/src/builtin/Promise.cpp claims this is useful when the Promise // compartment is less-privileged. This means for this test we can't use // assertDeepEq below, because the result array may have the wrong prototype.
let g = newGlobal();
if (typeof isSameCompartment !== "function") { var isSameCompartment = SpecialPowers.Cu.getJSTestingFunctions().isSameCompartment;
}
// Test wrapping when neither Promise.allSettled element function is called.
Promise.allSettled.call(g.Promise, []).then(v => {
assertEq(isSameCompartment(v, g), true);
assertEq(v.length, 0);
});
// Test wrapping in `Promise.allSettled Resolve Element Function`.
Promise.allSettled.call(g.Promise, [Promise.resolve(0)]).then(v => {
assertEq(isSameCompartment(v, g), true);
// Test wrapping in `Promise.allSettled Reject Element Function`.
Promise.allSettled.call(g.Promise, [Promise.reject(0)]).then(v => {
assertEq(isSameCompartment(v, g), true);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.