Skip to content

Commit f47b4c3

Browse files
committed
wip
1 parent d3485d7 commit f47b4c3

2 files changed

Lines changed: 25 additions & 56 deletions

File tree

client/data/panel.html

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -5,32 +5,20 @@
55

66
<script>
77

8-
/*
9-
setInterval(function () {
10-
window.postMessage("hello there 1!", "*");
11-
if (window.parent) {
12-
window.parent.postMessage("hello there 2!", "*");
13-
}
14-
}, 1000);
15-
*/
8+
window.addEventListener("message", function (event) {
169

17-
window.onclick = function() {
18-
console.log('unsafewindow.onclick: ' + window.document.title);
19-
window.postMessage("hello there 1!", "*");
10+
window.port = event.ports[0];
2011

21-
console.log("window", window);
12+
dump("WINDOW PORT: " + (typeof port.emit) + "\n");
2213

23-
}
24-
25-
26-
27-
window.addEventListener("message", receiveMessage, false);
28-
29-
function receiveMessage (event) {
14+
port.onmessage = function (event) {
15+
dump("got message in panel:::1: " + event.data+ "\n");
3016

31-
dump("RECEIVED POST MESSAGE: " + event.data + "\n");
17+
dump("got message in panel:::2: " + JSON.stringify(event.data) + "\n");
3218

33-
}
19+
// port.postMessage("echo");
20+
};
21+
});
3422

3523
</script>
3624

components/ui/devtools-panel.js

Lines changed: 16 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -12,45 +12,32 @@ API.console.log("init panel");
1212
icon: "./FirePHP_16.png",
1313
url: "./panel.html",
1414

15-
/**
16-
* Executed by the framework when an instance of this panel is created.
17-
* There is one instance of this panel per {@Toolbox}. The panel is
18-
* instantiated when selected in the toolbox for the first time.
19-
*/
20-
initialize: function(options) {
2115

22-
API.console.log("initialize()");
23-
API.console.log("initialize() this", this);
24-
API.console.log("initialize() options", options);
2516

17+
setup: function({debuggee}) {
18+
this.debuggee = debuggee;
2619
},
27-
28-
/**
29-
* Executed by the framework when the panel is destroyed.
30-
*/
3120
dispose: function() {
32-
API.console.log("dispose()");
21+
this.debuggee = null;
3322
},
3423

35-
/**
36-
* Executed by the framework when the panel content iframe is
37-
* constructed. Allows e.g to connect the backend through
38-
* `debuggee` object
39-
*/
40-
setup: function(options) {
41-
// TODO: connect to backend using options.debuggee
4224

43-
API.console.log("setup()");
44-
API.console.log("setup() options", options);
25+
onReady: function() {
4526

46-
/*
47-
options.frame.contentWindow.addEventListener("message", function (event) {
48-
API.console.log("GOT MESSAGE IN PANEL:", event.data);
49-
}, false);
50-
*/
27+
API.console.log("this.debuggee", this.debuggee);
28+
29+
this.debuggee.onmessage = function (event) {
30+
31+
API.console.log("received message from devtools panel!!!", event);
32+
33+
}
34+
35+
this.postMessage("message from panel", [this.debuggee]);
36+
},
5137

5238

5339

40+
/*
5441
var panel = API.PANEL.Panel({
5542
contentURL: "./viewer.html",
5643
contentScriptFile: API.SELF.data.url("viewer.js")
@@ -69,14 +56,8 @@ API.TIMERS.setInterval(function () {
6956
7057
}, 2000);
7158
59+
*/
7260

73-
74-
75-
76-
77-
API.console.log("setup() DONE");
78-
79-
}
8061
});
8162

8263
API.console.log("register panel");

0 commit comments

Comments
 (0)