tor-browser

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

2nd-param-with-non-object.js (1980B)


      1 // |reftest| async
      2 // Copyright (C) 2021 the V8 project authors. All rights reserved.
      3 // This code is governed by the BSD license found in the LICENSE file.
      4 /*---
      5 description: >
      6  Rejects promise when the `assert` property of the second argument is neither
      7  undefined nor an object
      8 esid: sec-import-call-runtime-semantics-evaluation
      9 info: |
     10  2.1.1.1 EvaluateImportCall ( specifierExpression [ , optionsExpression ] )
     11    [...]
     12    6. Let promiseCapability be ! NewPromiseCapability(%Promise%).
     13    7. Let specifierString be ToString(specifier).
     14    8. IfAbruptRejectPromise(specifierString, promiseCapability).
     15    9. Let assertions be a new empty List.
     16    10. If options is not undefined, then
     17        a. If Type(options) is not Object,
     18           [...]
     19        b. Let assertionsObj be Get(options, "assert").
     20        c. IfAbruptRejectPromise(assertionsObj, promiseCapability).
     21        d. If assertionsObj is not undefined,
     22           i. If Type(assertionsObj) is not Object,
     23              1. Perform ! Call(promiseCapability.[[Reject]], undefined, « a
     24                 newly created TypeError object »).
     25              2. Return promiseCapability.[[Promise]].
     26    [...]
     27 features: [dynamic-import, import-attributes, Symbol, BigInt]
     28 flags: [async]
     29 ---*/
     30 
     31 function test(promise, valueType) {
     32  return promise.then(function() {
     33      throw new Test262Error('Promise for ' + valueType + ' was not rejected.');
     34    }, function(error) {
     35      assert.sameValue(error.constructor, TypeError, valueType);
     36    });
     37 }
     38 
     39 Promise.all([
     40    test(import('./2nd-param_FIXTURE.js', {with:null}), 'null'),
     41    test(import('./2nd-param_FIXTURE.js', {with:false}), 'boolean'),
     42    test(import('./2nd-param_FIXTURE.js', {with:23}), 'number'),
     43    test(import('./2nd-param_FIXTURE.js', {with:''}), 'string'),
     44    test(import('./2nd-param_FIXTURE.js', {with:Symbol('')}), 'symbol'),
     45    test(import('./2nd-param_FIXTURE.js', {with:23n}), 'bigint')
     46  ])
     47  .then(function() {})
     48  .then($DONE, $DONE);