tor-browser

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

iter-arg-is-string-resolve.js (1032B)


      1 // |reftest| async
      2 // Copyright (C) 2019 Sergey Rubanov. 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: >
      8  Promise.any('non-empty-string') resolves with the first character in the non-empty string
      9 info: |
     10  Promise.any ( iterable )
     11 
     12  ...
     13  3. Let iteratorRecord be GetIterator(iterable).
     14  4. IfAbruptRejectPromise(iteratorRecord, promiseCapability).
     15  ...
     16 
     17  #sec-getiterator
     18  GetIterator ( obj [ , hint [ , method ] ] )
     19 
     20  ...
     21  Let iterator be ? Call(method, obj).
     22  If Type(iterator) is not Object, throw a TypeError exception.
     23  ...
     24 features: [Promise.any, arrow-function]
     25 flags: [async]
     26 ---*/
     27 
     28 try {
     29  Promise.any('xyz').then(v => {
     30    assert.sameValue(v, 'x');
     31    assert.sameValue(v.length, 1);
     32  }, error => {
     33    $DONE(`The promise should be resolved, but was rejected with error: ${error.message}`);
     34  }).then($DONE, $DONE);
     35 } catch (error) {
     36  $DONE(`The promise should be resolved, but threw an exception: ${error.message}`);
     37 }