Added "ping" (beacon/ping) capability control.
This commit is contained in:
parent
98aff58771
commit
e2f7de8fea
|
@ -567,6 +567,9 @@
|
||||||
"cap_fetch": {
|
"cap_fetch": {
|
||||||
"message": "fetch"
|
"message": "fetch"
|
||||||
},
|
},
|
||||||
|
"cap_ping": {
|
||||||
|
"message": "ping"
|
||||||
|
},
|
||||||
"cap_other": {
|
"cap_other": {
|
||||||
"message": "other"
|
"message": "other"
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,6 +1,19 @@
|
||||||
{
|
{
|
||||||
'use strict';
|
'use strict';
|
||||||
|
{
|
||||||
|
let onInstalled = async details => {
|
||||||
|
browser.runtime.onInstalled.removeListener(onInstalled);
|
||||||
|
let {reason, previousVersion} = details;
|
||||||
|
if (reason !== "update") return;
|
||||||
|
let v = previousVersion.split(".").map(n => parseInt(n));
|
||||||
|
if (v[0] > 11 || v[1] > 0 || v[2] > 10) return;
|
||||||
|
log(`Upgrading from 11.0.10 or below (${previousVersion}): configure the "ping" capability.`);
|
||||||
|
await ns.initializing;
|
||||||
|
ns.policy.TRUSTED.capabilities.add("ping")
|
||||||
|
await ns.savePolicy();
|
||||||
|
};
|
||||||
|
browser.runtime.onInstalled.addListener(onInstalled);
|
||||||
|
}
|
||||||
let popupURL = browser.extension.getURL("/ui/popup.html");
|
let popupURL = browser.extension.getURL("/ui/popup.html");
|
||||||
let popupFor = tabId => `${popupURL}#tab${tabId}`;
|
let popupFor = tabId => `${popupURL}#tab${tabId}`;
|
||||||
|
|
||||||
|
|
|
@ -274,7 +274,7 @@ var {Permissions, Policy, Sites} = (() => {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Permissions.ALL = ["script", "object", "media", "frame", "font", "webgl", "fetch", "other"];
|
Permissions.ALL = ["script", "object", "media", "frame", "font", "webgl", "fetch", "ping", "other"];
|
||||||
Permissions.IMMUTABLE = {
|
Permissions.IMMUTABLE = {
|
||||||
UNTRUSTED: {
|
UNTRUSTED: {
|
||||||
"script": false,
|
"script": false,
|
||||||
|
@ -282,6 +282,7 @@ var {Permissions, Policy, Sites} = (() => {
|
||||||
"webgl": false,
|
"webgl": false,
|
||||||
"fetch": false,
|
"fetch": false,
|
||||||
"other": false,
|
"other": false,
|
||||||
|
"ping": false,
|
||||||
},
|
},
|
||||||
TRUSTED: {
|
TRUSTED: {
|
||||||
"script": true,
|
"script": true,
|
||||||
|
|
|
@ -304,7 +304,7 @@ var UI = (() => {
|
||||||
capInput.id = `capability-${capability}-${idSuffix}`
|
capInput.id = `capability-${capability}-${idSuffix}`
|
||||||
capLabel.setAttribute("for", capInput.id);
|
capLabel.setAttribute("for", capInput.id);
|
||||||
capInput.value = capability;
|
capInput.value = capability;
|
||||||
capInput.title = capLabel.textContent = _(`cap_${capability}`);
|
capInput.title = capLabel.textContent = _(`cap_${capability}`) || capability;
|
||||||
let clone = capParent.appendChild(cap.cloneNode(true));
|
let clone = capParent.appendChild(cap.cloneNode(true));
|
||||||
clone.classList.add(capability);
|
clone.classList.add(capability);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue