Skip to content

Commit 0d6e42a

Browse files
committed
Update comments
1 parent 5e0ca68 commit 0d6e42a

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

MessageManager/lib/myPanel.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ const MyPanel = Class(
2323
icon: "./icon-16.png",
2424
url: "./myPanel.html",
2525

26+
// Initialization
27+
2628
/**
2729
* Executed by the framework when an instance of this panel is created.
2830
* There is one instance of this panel per {@Toolbox}. The panel is
@@ -43,6 +45,9 @@ const MyPanel = Class(
4345
* ready (document state == interactive).
4446
*/
4547
onReady: function() {
48+
// This is the way how to get access to the inner <iframe> element.
49+
// The frame is using type="content" and so, the access to the inner
50+
// document must be done through a message manager.
4651
this.panelFrame = viewFor(this);
4752

4853
// Get frame's message manager. Read more about message managers on MDN:
@@ -51,7 +56,7 @@ const MyPanel = Class(
5156
messageManager.addMessageListener("message/from/content",
5257
this.onMessage);
5358

54-
// Load frame script with content API for receiving
59+
// Load helper frame script with content API for receiving
5560
// and sending messages.
5661
let url = self.data.url("frame-script.js");
5762
messageManager.loadFrameScript(url, false);
@@ -62,12 +67,20 @@ const MyPanel = Class(
6267

6368
// Chrome <-> Content Communication
6469

70+
/**
71+
* Handle messages coming from the content scope (see 'frame-script.js'
72+
* that is responsible for sending them).
73+
*/
6574
onMessage: function(message) {
6675
const { type, data } = message.data;
6776

6877
console.log("Message from content: " + data);
6978
},
7079

80+
/**
81+
* Send message to the content scope (see 'frame-script.js'
82+
* that is responsible for handling them).
83+
*/
7184
postContentMessage: function(type, data) {
7285
let { messageManager } = this.panelFrame.frameLoader;
7386
messageManager.sendAsyncMessage("message/from/chrome", {
@@ -77,6 +90,7 @@ const MyPanel = Class(
7790
},
7891
});
7992

93+
// Register panel
8094
const myTool = new Tool({
8195
name: "MyTool",
8296
panels: {

0 commit comments

Comments
 (0)