summaryrefslogtreecommitdiffstats
path: root/browser/components/messagepreview/actors/AboutMessagePreviewChild.sys.mjs
blob: d233f682a101839d33cd8a6151e01844aed33441 (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
/* 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/. */

export class AboutMessagePreviewChild extends JSWindowActorChild {
  handleEvent(event) {
    console.log(`Received page event ${event.type}`);
  }

  actorCreated() {
    this.exportFunctions();
  }

  exportFunctions() {
    const window = this.contentWindow;

    Cu.exportFunction(this.MPShowMessage.bind(this), window, {
      defineAs: "MPShowMessage",
    });
  }

  MPShowMessage(message) {
    this.sendAsyncMessage(`MessagePreview:SHOW_MESSAGE`, message);
  }
}