Skip to content

Commit

Permalink
Add systemXHR permission
Browse files Browse the repository at this point in the history
  • Loading branch information
Marco Castelluccio committed Dec 8, 2014
1 parent 2178b40 commit 96c17d3
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
Introduction
============

This Firefox extension toggles the mozTCPSocket, mozContacts, mozbrowser and
Notification APIs for web pages in Firefox, so you can test Open Web Apps that
need access to those APIs in the browser.
This Firefox extension toggles the mozTCPSocket, mozContacts, mozbrowser,
Notification APIs and systemXHR for web pages in Firefox, so you can test
Open Web Apps that need access to those APIs in the browser.

Install it, then press the "Plug-In" button in your toolbar while the page
in question is loaded into the active tab, and the extension will enable
Expand Down
6 changes: 5 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const CONTACTS_WRITE_PERM = "contacts-write";
const CONTACTS_CREATE_PERM = "contacts-create";
const BROWSER_PERM = "browser";
const DESKTOP_NOTIFICATION_PERM = "desktop-notification";
const SYSTEMXHR_PERM = "systemXHR";
const LABEL_DISABLED = "mozTCPSocket/mozContacts APIs disabled";
const LABEL_ENABLED = "mozTCPSocket/mozContacts APIs enabled";
const ICON_DISABLED = "./unplugged.svg";
Expand Down Expand Up @@ -60,6 +61,7 @@ var button = ActionButton({
Services.perms.addFromPrincipal(getPrincipal(tabs.activeTab), CONTACTS_CREATE_PERM, Services.perms.ALLOW_ACTION);
Services.perms.addFromPrincipal(getPrincipal(tabs.activeTab), BROWSER_PERM, Services.perms.ALLOW_ACTION);
Services.perms.addFromPrincipal(getPrincipal(tabs.activeTab), DESKTOP_NOTIFICATION_PERM, Services.perms.ALLOW_ACTION);
Services.perms.addFromPrincipal(getPrincipal(tabs.activeTab), SYSTEMXHR_PERM, Services.perms.ALLOW_ACTION);
button.state("tab", STATE_ENABLED);
}
else {
Expand All @@ -69,6 +71,7 @@ var button = ActionButton({
Services.perms.removeFromPrincipal(getPrincipal(tabs.activeTab), CONTACTS_CREATE_PERM);
Services.perms.removeFromPrincipal(getPrincipal(tabs.activeTab), BROWSER_PERM);
Services.perms.removeFromPrincipal(getPrincipal(tabs.activeTab), DESKTOP_NOTIFICATION_PERM);
Services.perms.removeFromPrincipal(getPrincipal(tabs.activeTab), SYSTEMXHR_PERM);
button.state("tab", STATE_DISABLED);
}
},
Expand All @@ -81,7 +84,8 @@ tabs.on("pageshow", function(tab) {
Services.perms.testPermissionFromPrincipal(getPrincipal(tab), CONTACTS_WRITE_PERM) == Services.perms.ALLOW_ACTION &&
Services.perms.testPermissionFromPrincipal(getPrincipal(tab), CONTACTS_CREATE_PERM) == Services.perms.ALLOW_ACTION &&
Services.perms.testPermissionFromPrincipal(getPrincipal(tab), BROWSER_PERM) == Services.perms.ALLOW_ACTION &&
Services.perms.testPermissionFromPrincipal(getPrincipal(tab), DESKTOP_NOTIFICATION_PERM) == Services.perms.ALLOW_ACTION) {
Services.perms.testPermissionFromPrincipal(getPrincipal(tab), DESKTOP_NOTIFICATION_PERM) == Services.perms.ALLOW_ACTION &&
Services.perms.testPermissionFromPrincipal(getPrincipal(tab), SYSTEMXHR_PERM) == Services.perms.ALLOW_ACTION) {
button.state(tab, STATE_ENABLED);
}
else {
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"title": "API Enabler",
"name": "tcpsocketpup",
"version": "0.6.0",
"description": "Toggle mozTCPSocket/mozContacts/mozbrowser/desktop-notification access for a page.",
"version": "0.7.0",
"description": "Toggle mozTCPSocket/mozContacts/mozbrowser/desktop-notification/systemXHR access for a page.",
"main": "index.js",
"author": "Myk Melez",
"engines": {
Expand Down

0 comments on commit 96c17d3

Please sign in to comment.