tor-browser

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

asyncHelpers-asyncTest-then-rejects.js (1126B)


      1 // |reftest| async
      2 // Copyright (C) 2022 Igalia, S.L. All rights reserved.
      3 // This code is governed by the BSD license found in the LICENSE file.
      4 /*---
      5 description: |
      6    The 'asyncTest' helper calls $DONE with the rejection value if the test function rejects.
      7 flags: [async]
      8 includes: [asyncHelpers.js, compareArray.js]
      9 ---*/
     10 const rejectionValues = [];
     11 var realDone = $DONE;
     12 globalThis.$DONE = function (mustBeDefined) {
     13  rejectionValues.push(mustBeDefined);
     14 };
     15 const someObject = {};
     16 
     17 (async function () {
     18  asyncTest(function () {
     19    return Promise.reject(null);
     20  });
     21 })()
     22  .then(() => {
     23    asyncTest(function () {
     24      return Promise.reject(someObject);
     25    });
     26  })
     27  .then(() => {
     28    asyncTest(function () {
     29      return Promise.reject("hi");
     30    });
     31  })
     32  .then(() => {
     33    asyncTest(function () {
     34      return Promise.reject(10);
     35    });
     36  })
     37  .then(() => {
     38    asyncTest(function () {
     39      return {
     40        then(res, rej) {
     41          rej(true);
     42        },
     43      };
     44    });
     45  })
     46  .then(() => {
     47    assert.compareArray(rejectionValues, [null, someObject, "hi", 10, true]);
     48  })
     49  .then(realDone, realDone);