tor-browser

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

iter-assigned-symbol-reject.js (1504B)


      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  Reject when argument's Symbol.iterator property has the value Symbol()
      9 info: |
     10  Promise.any ( iterable )
     11 
     12  ...
     13  4. Let iteratorRecord be GetIterator(iterable).
     14  5. IfAbruptRejectPromise(iteratorRecord, promiseCapability).
     15  ...
     16 
     17  GetIterator ( obj [ , hint [ , method ] ] )
     18 
     19  ...
     20  3. If method is not present, then
     21    a. If hint is async, then
     22      ...
     23    b. Otherwise, set method to ? GetMethod(obj, @@iterator).
     24  4. Let iterator be ? Call(method, obj).
     25  5. If Type(iterator) is not Object, throw a TypeError exception.
     26  ...
     27 
     28  GetMethod
     29 
     30  2. Let func be ? GetV(V, P).
     31  3. If func is either undefined or null, return undefined.
     32  4. If IsCallable(func) is false, throw a TypeError exception.
     33 
     34  Call ( F, V [ , argumentsList ] )
     35 
     36  2. If IsCallable(F) is false, throw a TypeError exception.
     37 features: [Promise.any, Symbol, Symbol.iterator, computed-property-names]
     38 flags: [async]
     39 ---*/
     40 
     41 try {
     42  Promise.any({
     43    [Symbol.iterator]: Symbol()
     44  }).then(function() {
     45    $DONE('The promise should be rejected, but was resolved');
     46  }, function(error) {
     47    assert.sameValue(Object.getPrototypeOf(error), TypeError.prototype);
     48    assert(error instanceof TypeError);
     49  }).then($DONE, $DONE);
     50 } catch (error) {
     51  $DONE(`The promise should be rejected, but threw an exception: ${error.message}`);
     52 }