toolkit/actors/TestChild.jsm
author Csoregi Natalia <ncsoregi@mozilla.com>
Fri, 10 May 2019 12:44:22 +0300
changeset 532186 012ce6437a4cbb2bdffb1d641dd08f0a4ca66b75
parent 532183 a098226e42117f59f17112ed7be9e39710e18681
child 532227 849fff1c1663f3be35656e771c6e82ec00496fae
permissions -rw-r--r--
Backed out 3 changesets (bug 1538979) for bustage on JSWindowActor.cpp. CLOSED TREE Backed out changeset a098226e4211 (bug 1538979) Backed out changeset 8e065761738c (bug 1538979) Backed out changeset 9df2b856b655 (bug 1538979)

/* vim: set ts=2 sw=2 sts=2 et tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";

var EXPORTED_SYMBOLS = ["TestChild"];

class TestChild extends JSWindowActorChild {
  constructor() {
     super();
  }

  receiveMessage(aMessage) {
    switch (aMessage.name) {
      case "toChild":
        aMessage.data.toChild = true;
        this.sendAsyncMessage("toParent", aMessage.data);
        break;
      case "asyncAdd":
        let {a, b} = aMessage.data;
        return new Promise(resolve => {
          resolve({ result: a + b });
        });
      case "done":
        this.done(aMessage.data);
        break;
    }

    return undefined;
  }

  handleEvent(aEvent) {
    this.sendAsyncMessage("event", { type: aEvent.type });
  }

  observe(subject, topic, data) {
    this.lastObserved = {subject, topic, data};
  }

  show() {
    return "TestChild";
  }
}