tor-browser

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

self-resolve.js (1012B)


      1 // |reftest| skip-if(!xulRuntime.shell) -- needs drainJobQueue
      2 
      3 // Resolve Promise with itself by directly calling the "Promise Resolve Function".
      4 let resolve;
      5 let promise = new Promise(function(x) { resolve = x; });
      6 resolve(promise)
      7 
      8 let results = [];
      9 promise.then(res => assertEq(true, false, "not reached")).catch(res => {
     10    assertEq(res instanceof TypeError, true);
     11    results.push("rejected");
     12 });
     13 
     14 drainJobQueue()
     15 
     16 assertEq(results.length, 1);
     17 assertEq(results[0], "rejected");
     18 
     19 
     20 // Resolve Promise with itself when the "Promise Resolve Function" is called
     21 // from (the fast path in) PromiseReactionJob.
     22 results = [];
     23 
     24 promise = new Promise(x => { resolve = x; });
     25 let promise2 = promise.then(() => promise2);
     26 
     27 promise2.then(() => assertEq(true, false, "not reached"), res => {
     28    assertEq(res instanceof TypeError, true);
     29    results.push("rejected");
     30 });
     31 
     32 resolve();
     33 
     34 drainJobQueue();
     35 
     36 assertEq(results.length, 1);
     37 assertEq(results[0], "rejected");
     38 
     39 
     40 this.reportCompare && reportCompare(0, 0, "ok");