tor-browser

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

cause_abrupt.js (1426B)


      1 // Copyright (C) 2021 Chengzhong Wu. All rights reserved.
      2 // This code is governed by the BSD license found in the LICENSE file.
      3 
      4 /*---
      5 description: InstallErrorCause on abrupt completions
      6 info: |
      7  Error ( message [ , options ] )
      8 
      9  ...
     10  4. Perform ? InstallErrorCause(O, options).
     11  ...
     12 
     13  20.5.8.1 InstallErrorCause ( O, options )
     14 
     15  1. If Type(options) is Object and ? HasProperty(options, "cause") is true, then
     16    a. Let cause be ? Get(options, "cause").
     17    b. Perform ! CreateNonEnumerableDataPropertyOrThrow(O, "cause", cause).
     18  ...
     19 
     20 esid: sec-error-message
     21 features: [error-cause]
     22 ---*/
     23 
     24 var message = "my-message";
     25 var options;
     26 
     27 //////////////////////////////////////////////////////////////////////////////
     28 // CHECK#0
     29 options = new Proxy({}, {
     30  has(target, prop) {
     31    if (prop === "cause") {
     32      throw new Test262Error("HasProperty");
     33    }
     34    return prop in target;
     35  },
     36 });
     37 assert.throws(Test262Error, function () {
     38  new Error(message, options);
     39 }, "HasProperty");
     40 //////////////////////////////////////////////////////////////////////////////
     41 
     42 //////////////////////////////////////////////////////////////////////////////
     43 // CHECK#1
     44 options = {
     45  get cause() {
     46    throw new Test262Error("Get Cause");
     47  },
     48 };
     49 assert.throws(Test262Error, function () {
     50  new Error(message, options);
     51 }, "Get Cause");
     52 //////////////////////////////////////////////////////////////////////////////
     53 
     54 reportCompare(0, 0);