summaryrefslogtreecommitdiffstats
path: root/devtools/server/tests/browser/test-errors-actor.js
blob: 2d2997af505a1b9bdc84a1f11ee5109859a1787e (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
52
53
54
/* Any copyright is dedicated to the Public Domain.
 * http://creativecommons.org/publicdomain/zero/1.0/ */

"use strict";

const protocol = require("devtools/shared/protocol");
const { components, Cr } = require("chrome");

const testErrorsSpec = protocol.generateActorSpec({
  typeName: "testErrors",

  methods: {
    throwsComponentsException: {
      request: {},
      response: {},
    },
    throwsException: {
      request: {},
      response: {},
    },
    throwsJSError: {
      request: {},
      response: {},
    },
  },
});

const TestErrorsActor = protocol.ActorClassWithSpec(testErrorsSpec, {
  initialize: function(conn) {
    protocol.Actor.prototype.initialize.call(this, conn);
    this.conn = conn;
  },

  throwsComponentsException: async function() {
    throw components.Exception("", Cr.NS_ERROR_NOT_IMPLEMENTED);
  },

  throwsException: async function() {
    return this.a.b.c;
  },

  throwsJSError: async function() {
    throw new Error("JSError");
  },
});
exports.TestErrorsActor = TestErrorsActor;

class TestErrorsFront extends protocol.FrontClassWithSpec(testErrorsSpec) {
  constructor(client) {
    super(client);
    this.formAttributeName = "testErrorsActor";
  }
}
protocol.registerFront(TestErrorsFront);