Skip to content

Commit

Permalink
Merge pull request #13 from erikvold/issue-12
Browse files Browse the repository at this point in the history
using the userstyles module
  • Loading branch information
msujaws committed Aug 24, 2012
2 parents 5c20fa0 + cec6f1e commit 8a3b13a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 50 deletions.
22 changes: 4 additions & 18 deletions lib/main.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
exports.main = function(options) {
const {AboutHandler, ProtocolHandler} = require('protocol'),

const protocol = require('protocol'),
ao = require("achievement-overlay"),
BrandStringBundle = require("app-strings").StringBundle("chrome://branding/locale/brand.properties"),
{Cc,Ci,Cu} = require("chrome"),
Expand All @@ -17,14 +17,6 @@ exports.main = function(options) {
_ = require("l10n").get;

const brandShortName = BrandStringBundle.get("brandShortName");
let protocol = {
about: function(about, handler) {
return AboutHandler.extend(handler, { scheme: about }).new()
},
protocol: function(scheme, handler) {
return ProtocolHandler.extend(handler, { scheme: scheme }).new()
}
}
const aboutCheevosUrl = "about:cheevos";

let objHolder = {};
Expand Down Expand Up @@ -415,13 +407,8 @@ exports.main = function(options) {
id: "cheevos-achievementOverlay",
onCommand: function () { loadCheevosPage(); }
});
let sss = Cc["@mozilla.org/content/style-sheet-service;1"]
.getService(Ci.nsIStyleSheetService);
let ios = Cc["@mozilla.org/network/io-service;1"]
.getService(Ci.nsIIOService);
let chromeStylesheet = data.url("chrome.css");
let chromeStylesheetUri = ios.newURI(chromeStylesheet, null, null);
sss.loadAndRegisterSheet(chromeStylesheetUri, sss.AGENT_SHEET);

require('userstyles').load(data.url("chrome.css"), {type: 'agent'});

// show cheevo for installing the addon
onObservation(cheevos.addOnsOpened, true, "bronze");
Expand Down Expand Up @@ -1014,4 +1001,3 @@ exports.main = function(options) {
}
});
aboutCheevosHandler.register();
};
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"author": "Jared Wein",
"dependencies": ["addon-kit", "api-utils", "protocol", "toolbarbutton", "vold-utils"],
"dependencies": ["addon-kit", "api-utils", "protocol", "toolbarbutton", "vold-utils", "userstyles"],
"description": "Cheevos is an addon for Firefox that makes learning about different parts of the browser fun, as well as giving you the opportunity to brag to your friends about your pro-level web surfing.",
"fullName": "Cheevos",
"icon": "cheevos-toolbar-24x24.png",
Expand Down
45 changes: 14 additions & 31 deletions test/test-main.js
Original file line number Diff line number Diff line change
@@ -1,32 +1,15 @@
const main = require("main");

exports.test_test_run = function(test) {
test.pass("Unit test running!");
};

exports.test_id = function(test) {
test.assert(require("self").id.length > 0);
};

exports.test_url = function(test) {
require("request").Request({
url: "http://www.mozilla.org/",
onComplete: function(response) {
test.assertEqual(response.statusText, "OK");
test.done();
}
}).get();
test.waitUntilDone(20000);
};

exports.test_open_tab = function(test) {
const tabs = require("tabs");
tabs.open({
url: "http://www.mozilla.org/",
onReady: function(tab) {
test.assertEqual(tab.url, "http://www.mozilla.org/");
test.done();
}
});
test.waitUntilDone(20000);
'use strict';

const { Loader } = require('test-harness/loader');
const { data } = require('self');

exports.testStylesheetIsRegistered = function(test) {
let loader = Loader(module);
loader.require('main');
test.assertEqual(
require('userstyles').registered(data.url("chrome.css"), {type: 'agent'}),
true,
'The cheeevos style sheet was registered'
);
loader.unload();
};

0 comments on commit 8a3b13a

Please sign in to comment.