Skip to content

Commit c4b688b

Browse files
committed
wip
1 parent 8ccf127 commit c4b688b

10 files changed

Lines changed: 225 additions & 85 deletions

File tree

README.md

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,45 @@
11
FirePHP for Firebug.Next
22
========================
33

4-
The original [FirePHP Firebug extension](https://github.com/firephp/firephp-extension) re-implemented to leverage the latest [module loader](https://github.com/pinf/pinf-loader-js), [console logging](https://github.com/fireconsole) and [out-of-band communication](https://github.com/firenode) libraries working against [Firebug.Next](https://github.com/firebug/firebug.next).
4+
The original [FirePHP Firebug extension](https://github.com/firephp/firephp-extension) re-implemented to leverage the latest [module loader](https://github.com/pinf/pinf-loader-js), [console logging](https://github.com/fireconsole), [out-of-band communication](https://github.com/firenode) libraries and [development system](https://github.com/devcomp-io) working against [Firebug.Next](https://github.com/firebug/firebug.next) and [Firefox Nightly](https://nightly.mozilla.org/).
55

6-
Instructions
7-
------------
86

9-
*TODO*
7+
Install
8+
=======
9+
10+
1. Open Firefox
11+
2. Install latest release: [github.com/firephp/firephp-for-firebug.next/releases](https://github.com/firephp/firephp-for-firebug.next/releases)
12+
3. Open developer tools toolbox (F12 or Menu -> Developer -> Toogle Tools)
13+
4. See the **FirePHP** panel for further information
14+
15+
Development
16+
-----------
17+
18+
This project is being developed within the [github.com/firebug/dev-system](https://github.com/firebug/dev-system). Once installed you can run:
19+
20+
pio publish --local firephp-for-firebug.next
21+
pio run firephp-for-firebug.next --open
22+
profile run fbn-firephp
23+
profile run fbn-firephp-test
24+
25+
26+
Implementation
27+
==============
28+
29+
This [Firefox add-on](https://developer.mozilla.org/en-US/Add-ons) is built using [github.com/pinf-to](https://github.com/pinf-to) to bundle and [github.com/pinf/pinf-for-mozilla-addon-sdk](https://github.com/pinf/pinf-for-mozilla-addon-sdk) to load source code on demand as the addon is loaded and reloaded triggered by source changes.
30+
31+
The source code is structured as follows:
32+
33+
* `client` - A minimal addon acting as a bootstrapper that loads the root [PINF JavaScript Bundle](https://github.com/pinf/pinf-loader-js) holding the root extension implementation.
34+
* `components` - The extension implementation broken down into logical modules along with any dependencies the client needs.
35+
* `server` - PHP scripts that load the [github.com/firephp/firephp-core](https://github.com/firephp/firephp-core) and [github.com/firephp/firephp](https://github.com/firephp/firephp) libraries and generate test data for the client.
36+
37+
Roadmap
38+
-------
39+
40+
1. Stabilize core featureset
41+
2. Refactor `client` and `components` into [github.com/freedom-platform/fp-for-mozilla-extensions](http://github.com/freedom-platform/fp-for-mozilla-extensions)
42+
3. Support development without needing [github.com/firebug/dev-system](https://github.com/firebug/dev-system) by simply running: `git clone ; bin/install ; bin/run`
1043

1144

1245
License

client/README.md

Lines changed: 0 additions & 10 deletions
This file was deleted.

client/data/panel.html

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,45 @@
22
<html>
33
<head>
44
<meta charset="utf-8"/>
5+
6+
<script>
7+
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+
*/
16+
17+
window.onclick = function() {
18+
console.log('unsafewindow.onclick: ' + window.document.title);
19+
window.postMessage("hello there 1!", "*");
20+
21+
console.log("window", window);
22+
23+
}
24+
25+
26+
27+
window.addEventListener("message", receiveMessage, false);
28+
29+
function receiveMessage (event) {
30+
31+
dump("RECEIVED POST MESSAGE: " + event.data + "\n");
32+
33+
}
34+
35+
</script>
36+
537
</head>
638
<style type="text/css">
739
body {
840
background-color: white;
941
}
1042
</style>
1143
<body>
12-
<h1>Hello World from FirePHP Extension!</h1>
44+
<h1 id="header">Hello World from FirePHP Extension!</h1>
1345
</body>
1446
</html>

client/data/viewer.html

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<html>
2+
<header>
3+
</header>
4+
<body>
5+
VIEWER
6+
</body>
7+
</html>

client/data/viewer.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
2+
setInterval(function () {
3+
4+
self.port.emit("message", "Message data");
5+
6+
}, 1000);
7+
8+
self.port.on("message", function(data) {
9+
dump("GOT MESSAGE IN CONTRENT SCRIPT : " + data);
10+
});
11+

client/lib/main.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
"use strict";
44

55
const { Extension:EXTENSION } = require("./extension.js");
6-
const { Panel:PANEL } = require("./panel.js");
76
const { Cc: CC, Cu:CU, Ci:CI } = require("chrome");
87
const { gDevTools:GDEVTOOLS } = CU.import("resource:///modules/devtools/gDevTools.jsm", {});
98

9+
1010
const { data:DATA } = require("sdk/self");
1111
const { sandbox:SANDBOX } = require("pinf-for-mozilla-addon-sdk");
1212

@@ -29,7 +29,13 @@ function main(options, callbacks) {
2929
CC: CC,
3030
CU: CU,
3131
CI: CI,
32-
GDEVTOOLS: GDEVTOOLS
32+
GDEVTOOLS: GDEVTOOLS,
33+
SELF: require("sdk/self"),
34+
TIMERS: require("sdk/timers"),
35+
CLASS: require("sdk/core/heritage").Class,
36+
DEV_PANEL: require("dev/panel.js").Panel,
37+
DEV_TOOL: require("dev/toolbox").Tool,
38+
PANEL: require("sdk/panel")
3339
});
3440
});
3541

client/lib/panel.js

Lines changed: 0 additions & 53 deletions
This file was deleted.

components/adapters/fbtrace.js

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,20 @@ exports.for = function (API) {
1212
} catch(err) {
1313
}
1414

15-
16-
function log (label, obj) {
17-
if (typeof object === "undefined") {
18-
object = label;
15+
function normalizeLogArguments (label, obj) {
16+
if (typeof obj === "undefined") {
17+
obj = label;
1918
label = ("" + obj);
2019
}
21-
FBTrace.sysout(label, obj);
20+
return {
21+
label: label,
22+
obj: obj
23+
};
24+
}
25+
26+
function log (label, obj) {
27+
var args = normalizeLogArguments(label, obj);
28+
FBTrace.sysout(args.label, args.obj);
2229
}
2330
API.on("log", log);
2431

@@ -39,10 +46,12 @@ exports.for = function (API) {
3946
return (new Console(context));
4047
}
4148
Console.prototype.log = function (label, obj) {
42-
return log(this._prefixLabel(label || ("" + obj)), obj);
49+
var args = normalizeLogArguments(label, obj);
50+
return log(this._prefixLabel(args.label), args.obj);
4351
}
4452
Console.prototype.error = function (label, obj) {
45-
return log(this._prefixLabel("ERROR: " + (label || ("" + obj))), obj);
53+
var args = normalizeLogArguments(label, obj);
54+
return log(this._prefixLabel("ERROR: " + args.label), args.obj);
4655
}
4756

4857

components/main.js

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,33 @@ exports.main = function (API) {
1717
}).console;
1818

1919

20-
console.log("Init components");
20+
console.log("Init components ...");
2121

22+
try {
2223

23-
const HTTP_RESPONSE_OBSERVER_API = makeAPI(API, {
24-
name: "http-response-observer"
25-
});
26-
const HTTP_RESPONSE_OBSERVER_EXPORTS = require("./adapters/http-response-observer").for(HTTP_RESPONSE_OBSERVER_API);
24+
const HTTP_RESPONSE_OBSERVER_API = makeAPI(API, {
25+
name: "http-response-observer"
26+
});
27+
const HTTP_RESPONSE_OBSERVER_EXPORTS = require("./adapters/http-response-observer").for(HTTP_RESPONSE_OBSERVER_API);
2728

29+
HTTP_RESPONSE_OBSERVER_API.on("response", function (response) {
2830

29-
HTTP_RESPONSE_OBSERVER_API.on("response", function (response) {
31+
API.console.log("response in MAIN", response);
3032

31-
API.console.log("response in MAIN", response);
33+
});
3234

33-
});
35+
36+
const UI_DEVTOOLS_PANEL_API = makeAPI(API, {
37+
name: "devtools-panel"
38+
});
39+
const UI_DEVTOOLS_PANEL_EXPORTS = require("./ui/devtools-panel").for(UI_DEVTOOLS_PANEL_API);
40+
41+
} catch (err) {
42+
console.error(err.stack);
43+
throw err;
44+
}
45+
46+
console.log("... init components done!");
3447
}
3548

3649

components/ui/devtools-panel.js

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
2+
exports.for = function (API) {
3+
4+
API.console.log("init panel");
5+
6+
const Panel = API.CLASS(
7+
{
8+
extends: API.DEV_PANEL,
9+
10+
label: "FirePHP",
11+
tooltip: "Log from PHP scripts to Console",
12+
icon: "./FirePHP_16.png",
13+
url: "./panel.html",
14+
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) {
21+
22+
API.console.log("initialize()");
23+
API.console.log("initialize() this", this);
24+
API.console.log("initialize() options", options);
25+
26+
},
27+
28+
/**
29+
* Executed by the framework when the panel is destroyed.
30+
*/
31+
dispose: function() {
32+
API.console.log("dispose()");
33+
},
34+
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
42+
43+
API.console.log("setup()");
44+
API.console.log("setup() options", options);
45+
46+
/*
47+
options.frame.contentWindow.addEventListener("message", function (event) {
48+
API.console.log("GOT MESSAGE IN PANEL:", event.data);
49+
}, false);
50+
*/
51+
52+
53+
54+
var panel = API.PANEL.Panel({
55+
contentURL: "./viewer.html",
56+
contentScriptFile: API.SELF.data.url("viewer.js")
57+
});
58+
59+
panel.port.on("message", function(data) {
60+
61+
API.console.log("GOT MESSAGE", data);
62+
});
63+
64+
panel.show();
65+
66+
API.TIMERS.setInterval(function () {
67+
68+
panel.port.emit("message", "Message from extension!");
69+
70+
}, 2000);
71+
72+
73+
74+
75+
76+
77+
API.console.log("setup() DONE");
78+
79+
}
80+
});
81+
82+
API.console.log("register panel");
83+
84+
const Tool = new API.DEV_TOOL({
85+
name: "FirePHP",
86+
panels: {
87+
panel: Panel
88+
}
89+
});
90+
91+
return {};
92+
}

0 commit comments

Comments
 (0)