tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

resolved-sequence-extra-ticks.js (1581B)


      1 // |reftest| async
      2 // Copyright (C) 2020 Rick Waldron. All rights reserved.
      3 // This code is governed by the BSD license found in the LICENSE file.
      4 
      5 /*---
      6 esid: sec-promise.any
      7 description: Resolution ticks are set in a predictable sequence with extra then calls
      8 info: |
      9  Runtime Semantics: PerformPromiseAny ( iteratorRecord, constructor, resultCapability )
     10 
     11  Let remainingElementsCount be a new Record { [[Value]]: 1 }.
     12  ...
     13 
     14  Set remainingElementsCount.[[Value]] to remainingElementsCount.[[Value]] - 1.
     15  If remainingElementsCount.[[Value]] is 0, then
     16    Let error be a newly created AggregateError object.
     17    Perform ! DefinePropertyOrThrow(error, "errors",
     18      Property Descriptor {
     19        [[Configurable]]: true,
     20        [[Enumerable]]: false,
     21        [[Writable]]: true,
     22        [[Value]]: errors
     23      }).
     24    Return ? Call(promiseCapability.[[Reject]], undefined, « error »).
     25  ...
     26 flags: [async]
     27 includes: [promiseHelper.js]
     28 features: [Promise.any]
     29 ---*/
     30 
     31 let sequence = [];
     32 
     33 let p1 = new Promise(resolve => {
     34  resolve({});
     35 });
     36 
     37 sequence.push(1);
     38 
     39 Promise.any([p1]).then((resolved) => {
     40  sequence.push(4);
     41  assert.sameValue(sequence.length, 4);
     42  checkSequence(sequence, 'Expected Promise.any().then to queue second');
     43 }).catch($DONE);
     44 
     45 p1.then(() => {
     46  sequence.push(3);
     47  assert.sameValue(sequence.length, 3);
     48  checkSequence(sequence, 'Expected p1.then to queue first');
     49 }).then(() => {
     50  sequence.push(5);
     51  assert.sameValue(sequence.length, 5);
     52  checkSequence(sequence, 'Expected final then to queue last');
     53 }).then($DONE, $DONE);
     54 
     55 sequence.push(2);