From 4a41450395010b119c446cd48245ad144f2420a9 Mon Sep 17 00:00:00 2001 From: Myk Melez Date: Sun, 12 Oct 2014 22:20:29 -0700 Subject: [PATCH] also set mozbrowser access --- index.js | 11 +++++++++-- package.json | 4 ++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index 180353d..7581683 100644 --- a/index.js +++ b/index.js @@ -8,11 +8,14 @@ var { Cu } = require("chrome"); Cu.import("resource://gre/modules/Services.jsm"); // dom.mozTCPSocket.enabled is not set by default, but it's observed. -// dom.mozContacts.enabled is set by default but ignored, which is why +// dom.mozBrowserFramesEnabled is also not set by default but observed. +// dom.mozContacts.enabled is set by default but ignored! Which is why // we have to import ContactService.jsm below. So it actually doesn't // do anything now, but it'll do something in the future, when the bug // is fixed. +// XXX File the bug! Services.prefs.setBoolPref("dom.mozTCPSocket.enabled", true); +Services.prefs.setBoolPref("dom.mozBrowserFramesEnabled", true); Services.prefs.setBoolPref("dom.mozContacts.enabled", true); // We don't use this directly (which is why we import it into an object literal @@ -24,6 +27,7 @@ const TCP_SOCKET_PERM = "tcp-socket"; const CONTACTS_READ_PERM = "contacts-read"; const CONTACTS_WRITE_PERM = "contacts-write"; const CONTACTS_CREATE_PERM = "contacts-create"; +const BROWSER_PERM = "browser"; const LABEL_DISABLED = "mozTCPSocket/mozContacts APIs disabled"; const LABEL_ENABLED = "mozTCPSocket/mozContacts APIs enabled"; const ICON_DISABLED = "./unplugged.svg"; @@ -53,6 +57,7 @@ var button = ActionButton({ Services.perms.addFromPrincipal(getPrincipal(tabs.activeTab), CONTACTS_READ_PERM, Services.perms.ALLOW_ACTION); Services.perms.addFromPrincipal(getPrincipal(tabs.activeTab), CONTACTS_WRITE_PERM, Services.perms.ALLOW_ACTION); 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); button.state("tab", STATE_ENABLED); } else { @@ -60,6 +65,7 @@ var button = ActionButton({ Services.perms.removeFromPrincipal(getPrincipal(tabs.activeTab), CONTACTS_READ_PERM); Services.perms.removeFromPrincipal(getPrincipal(tabs.activeTab), CONTACTS_WRITE_PERM); Services.perms.removeFromPrincipal(getPrincipal(tabs.activeTab), CONTACTS_CREATE_PERM); + Services.perms.removeFromPrincipal(getPrincipal(tabs.activeTab), BROWSER_PERM); button.state("tab", STATE_DISABLED); } }, @@ -70,7 +76,8 @@ tabs.on("pageshow", function(tab) { if (Services.perms.testPermissionFromPrincipal(getPrincipal(tab), TCP_SOCKET_PERM) == Services.perms.ALLOW_ACTION && Services.perms.testPermissionFromPrincipal(getPrincipal(tab), CONTACTS_READ_PERM) == Services.perms.ALLOW_ACTION && 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), CONTACTS_CREATE_PERM) == Services.perms.ALLOW_ACTION && + Services.perms.testPermissionFromPrincipal(getPrincipal(tab), BROWSER_PERM) == Services.perms.ALLOW_ACTION) { button.state(tab, STATE_ENABLED); } else { diff --git a/package.json b/package.json index 0e5a2d5..5ebe947 100644 --- a/package.json +++ b/package.json @@ -1,8 +1,8 @@ { "title": "API Enabler", "name": "tcpsocketpup", - "version": "0.4.0", - "description": "Toggle mozTCPSocket/mozContacts access for a page.", + "version": "0.5.0", + "description": "Toggle mozTCPSocket/mozContacts/mozbrowser access for a page.", "main": "index.js", "author": "Myk Melez", "engines": {