summaryrefslogtreecommitdiffstats
path: root/devtools/server/tests/xpcshell/test_symbolactor.js
blob: 406210fa792247ebe00d0981772d119fdcfb7a12 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/* Any copyright is dedicated to the Public Domain.
   http://creativecommons.org/publicdomain/zero/1.0/ */

"use strict";

const { SymbolActor } = require("devtools/server/actors/object/symbol");

function run_test() {
  test_SA_destroy();
  test_SA_form();
  test_SA_raw();
}

const SYMBOL_NAME = "abc";
const TEST_SYMBOL = Symbol(SYMBOL_NAME);

function makeMockSymbolActor() {
  const symbol = TEST_SYMBOL;
  const mockConn = null;
  const actor = new SymbolActor(mockConn, symbol);
  actor.actorID = "symbol1";
  const parentPool = {
    symbolActors: {
      [symbol]: actor,
    },
    unmanage: () => {},
  };
  actor.getParent = () => parentPool;
  return actor;
}

function test_SA_destroy() {
  const actor = makeMockSymbolActor();
  strictEqual(actor.getParent().symbolActors[TEST_SYMBOL], actor);

  actor.destroy();
  strictEqual(TEST_SYMBOL in actor.getParent().symbolActors, false);
}

function test_SA_form() {
  const actor = makeMockSymbolActor();
  const form = actor.form();
  strictEqual(form.type, "symbol");
  strictEqual(form.actor, actor.actorID);
  strictEqual(form.name, SYMBOL_NAME);
}

function test_SA_raw() {
  const actor = makeMockSymbolActor();
  strictEqual(actor.rawValue(), TEST_SYMBOL);
}