michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: "use strict"; michael@0: michael@0: const { Toolbar } = require("sdk/ui/toolbar"); michael@0: const { Frame } = require("sdk/ui/frame"); michael@0: const { ActionButton } = require("sdk/ui/button/action"); michael@0: michael@0: let button = new ActionButton({ michael@0: id: "button", michael@0: label: "send!", michael@0: icon: "./favicon.ico", michael@0: onClick: () => { michael@0: frame.postMessage({ michael@0: hello: "content" michael@0: }); michael@0: } michael@0: }); michael@0: michael@0: let frame = new Frame({ michael@0: url: "./index.html", michael@0: onAttach: () => { michael@0: console.log("frame was attached"); michael@0: }, michael@0: onReady: () => { michael@0: console.log("frame document was loaded"); michael@0: }, michael@0: onLoad: () => { michael@0: console.log("frame load complete"); michael@0: }, michael@0: onMessage: (event) => { michael@0: console.log("got message from frame content", event); michael@0: if (event.data === "ping!") michael@0: event.source.postMessage("pong!", event.source.origin); michael@0: } michael@0: }); michael@0: let toolbar = new Toolbar({ michael@0: items: [frame], michael@0: title: "Addon Demo", michael@0: hidden: false, michael@0: onShow: () => { michael@0: console.log("toolbar was shown"); michael@0: }, michael@0: onHide: () => { michael@0: console.log("toolbar was hidden"); michael@0: } michael@0: });