summaryrefslogtreecommitdiffstats
path: root/devtools/server/tests/unit/registertestactors-03.js
blob: 8d42fdbd80ddc1d87fe534a90b812827cc2bee1f (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
/* Any copyright is dedicated to the Public Domain.
   http://creativecommons.org/publicdomain/zero/1.0/ */

var {method, RetVal, Actor, ActorClassWithSpec, Front, FrontClassWithSpec,
     generateActorSpec} = require("devtools/shared/protocol");
var Services = require("Services");

const lazySpec = generateActorSpec({
  typeName: "lazy",

  methods: {
    hello: {
      response: { str: RetVal("string") }
    }
  }
});

exports.LazyActor = ActorClassWithSpec(lazySpec, {
  initialize: function (conn, id) {
    Actor.prototype.initialize.call(this, conn);

    Services.obs.notifyObservers(null, "actor", "instantiated");
  },

  hello: function (str) {
    return "world";
  }
});

Services.obs.notifyObservers(null, "actor", "loaded");

exports.LazyFront = FrontClassWithSpec(lazySpec, {
  initialize: function (client, form) {
    Front.prototype.initialize.call(this, client);
    this.actorID = form.lazyActor;

    client.addActorPool(this);
    this.manage(this);
  }
});