Skip to content

Commit

Permalink
Merge pull request #58 from rpl/tweaks/firebug-sdk-issue-9
Browse files Browse the repository at this point in the history
mark RDPi internals rdp packages using the customAttributes
  • Loading branch information
janodvarko committed Jul 16, 2015
2 parents 63d89b7 + a17919b commit 7717a8a
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 16 deletions.
2 changes: 1 addition & 1 deletion data/inspector/packets-store.js
Expand Up @@ -190,7 +190,7 @@ PacketsStore.prototype =

if (packet.type == "send") {
// filter sent RDP packets needed to register the RDPi actorInspector actor
if (packet.packet.rdpInspectorInternals == true) {
if (packet.packet.rdpInspectorInternals) {
filterFrom[packet.packet.to] = filterFrom[packet.packet.to] || 0;
filterFrom[packet.packet.to] += 1;

Expand Down
4 changes: 3 additions & 1 deletion lib/inspector-service.js
Expand Up @@ -91,7 +91,9 @@ const InspectorService =
moduleUrl: actorModuleUrl,
// NOTE: the following option asks firebug.sdk to mark custom actors registering RDP packets
// as rdpInspectorInternals (which helps to filter out them from the packet list)
rdpInspectorInternals: true
customAttributes: {
rdpInspectorInternals: true
}
};

let deferred = defer();
Expand Down
4 changes: 2 additions & 2 deletions package.json
Expand Up @@ -26,7 +26,7 @@
"watch-karma-tests": "karma start --no-single-run --reporters spec --auto-watch",
"watch-karma-coverage": "CODE_COVERAGE=true npm run watch-karma-tests",
"jpm-tests": "jpm test",
"travis-ci": "npm run karma-coverage && npm run lint",
"travis-ci": "npm run karma-coverage && npm run jpm-tests && npm run lint",
"lint-content": "eslint data/inspector && eslint karma-tests/",
"lint-addon": "eslint lib",
"lint": "npm run lint-content && npm run lint-addon"
Expand Down Expand Up @@ -73,7 +73,7 @@
}
],
"dependencies": {
"firebug.sdk": "~0.5.5"
"firebug.sdk": "~0.6.3"
},
"devDependencies": {
"eslint": "^0.21.0",
Expand Down
4 changes: 4 additions & 0 deletions test/.eslintrc
@@ -0,0 +1,4 @@
// extends common eslintrc config with addon-sdk specific configs
{
"extends": "../lib/.eslintrc"
}
56 changes: 56 additions & 0 deletions test/test-inspector-service.js
@@ -0,0 +1,56 @@
"use strict";

const { InspectorService } = require("../lib/inspector-service");

const { Cu } = require("chrome");
const { getMostRecentBrowserWindow } = require("sdk/window/utils");

// DevTools
const { gDevTools } = Cu.import("resource:///modules/devtools/gDevTools.jsm", {});
const { devtools } = Cu.import("resource://gre/modules/devtools/Loader.jsm", {});

function showToolbox(toolId) {
let browser = getMostRecentBrowserWindow();
let tab = browser.gBrowser.mCurrentTab;
let target = devtools.TargetFactory.forTab(tab);
return gDevTools.showToolbox(target, toolId);
}

function formatException(e) {
return `\n\t${e.fileName}:${e.lineNumber}\n\t${e}`;
}

exports["test InspectorService"] = function(assert, done) {
showToolbox("webconsole").then((toolbox) => {
assert.ok(toolbox, "toolbox should be defined");

InspectorService.getInspectorClients(toolbox).then((inspectorClients) => {
assert.ok(inspectorClients, "inspectorClients should be defined");
assert.deepEqual(Object.keys(inspectorClients), ["global", "tab"],
"global and tab keys should be defined");
let { global, tab } = inspectorClients;
assert.equal(typeof global.getActors, "function", "global.getActors function is defined");
assert.equal(typeof tab.getActors, "function", "tab.getActors function is defined");

Promise.all([global.getActors(), tab.getActors()]).then(([tabActors, globalActors]) => {
const EXPECTED_ACTOR_KEYS = ["actorPool", "extraPools", "factories", "from"];

assert.deepEqual(Object.keys(globalActors), EXPECTED_ACTOR_KEYS, "globalActors should have the expected attributes");
assert.deepEqual(Object.keys(tabActors), EXPECTED_ACTOR_KEYS, "tabActors should have the expected attributes");

done();
}).catch((e) => {
assert.fail(`Exception catched during getActors: ${formatException(e)}`);
done();
});
}).catch((e) => {
assert.fail(`Exception catched during getInspectorClients: ${formatException(e)}`);
done();
});
}).catch((e) => {
assert.fail(`Exception catched during showToolbox: ${formatException(e)}`);
done();
});
};

require("sdk/test").run(exports);
12 changes: 0 additions & 12 deletions test/test-main.js

This file was deleted.

0 comments on commit 7717a8a

Please sign in to comment.