tor-browser

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

test_VariablesView_getString_promise.js (1704B)


      1 /* Any copyright is dedicated to the Public Domain.
      2   http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 "use strict";
      5 
      6 const { VariablesView } = ChromeUtils.importESModule(
      7  "resource://devtools/client/storage/VariablesView.sys.mjs"
      8 );
      9 
     10 const PENDING = {
     11  type: "object",
     12  class: "Promise",
     13  actor: "conn0.obj35",
     14  extensible: true,
     15  frozen: false,
     16  sealed: false,
     17  promiseState: {
     18    state: "pending",
     19  },
     20  preview: {
     21    kind: "Object",
     22    ownProperties: {},
     23    ownPropertiesLength: 0,
     24    safeGetterValues: {},
     25  },
     26 };
     27 
     28 const FULFILLED = {
     29  type: "object",
     30  class: "Promise",
     31  actor: "conn0.obj35",
     32  extensible: true,
     33  frozen: false,
     34  sealed: false,
     35  promiseState: {
     36    state: "fulfilled",
     37    value: 10,
     38  },
     39  preview: {
     40    kind: "Object",
     41    ownProperties: {},
     42    ownPropertiesLength: 0,
     43    safeGetterValues: {},
     44  },
     45 };
     46 
     47 const REJECTED = {
     48  type: "object",
     49  class: "Promise",
     50  actor: "conn0.obj35",
     51  extensible: true,
     52  frozen: false,
     53  sealed: false,
     54  promiseState: {
     55    state: "rejected",
     56    reason: 10,
     57  },
     58  preview: {
     59    kind: "Object",
     60    ownProperties: {},
     61    ownPropertiesLength: 0,
     62    safeGetterValues: {},
     63  },
     64 };
     65 
     66 function run_test() {
     67  equal(VariablesView.getString(PENDING, { concise: true }), "Promise");
     68  equal(VariablesView.getString(PENDING), 'Promise {<state>: "pending"}');
     69 
     70  equal(VariablesView.getString(FULFILLED, { concise: true }), "Promise");
     71  equal(
     72    VariablesView.getString(FULFILLED),
     73    'Promise {<state>: "fulfilled", <value>: 10}'
     74  );
     75 
     76  equal(VariablesView.getString(REJECTED, { concise: true }), "Promise");
     77  equal(
     78    VariablesView.getString(REJECTED),
     79    'Promise {<state>: "rejected", <reason>: 10}'
     80  );
     81 }