mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 991970 - Part 3: add permission check. r=smaug
From 6462cdf51f04b81479932f1b7b1d809970820620 Mon Sep 17 00:00:00 2001 --- dom/nfc/nsNfc.js | 23 +++++++++++++++++++++++ dom/webidl/MozNFC.webidl | 1 + 2 files changed, 24 insertions(+)
This commit is contained in:
parent
3361c10397
commit
9ce3e8090c
@ -224,6 +224,10 @@ mozNfc.prototype = {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this.checkPermissions(["nfc-read", "nfc-write"])) {
|
||||
return;
|
||||
}
|
||||
|
||||
let tag = new MozNFCTag(this._window, sessionToken);
|
||||
let tagContentObj = this._window.MozNFCTag._create(this._window, tag);
|
||||
|
||||
@ -253,6 +257,10 @@ mozNfc.prototype = {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this.checkPermissions(["nfc-read", "nfc-write"])) {
|
||||
return;
|
||||
}
|
||||
|
||||
debug("fire ontaglost " + sessionToken);
|
||||
let event = new this._window.Event("taglost");
|
||||
this.__DOM_IMPL__.dispatchEvent(event);
|
||||
@ -297,6 +305,21 @@ mozNfc.prototype = {
|
||||
this.__DOM_IMPL__.dispatchEvent(event);
|
||||
},
|
||||
|
||||
checkPermissions: function checkPermissions(perms) {
|
||||
let principal = this._window.document.nodePrincipal;
|
||||
for (let perm of perms) {
|
||||
let permValue =
|
||||
Services.perms.testExactPermissionFromPrincipal(principal, perm);
|
||||
if (permValue == Ci.nsIPermissionManager.ALLOW_ACTION) {
|
||||
return true;
|
||||
} else {
|
||||
debug("doesn't have " + perm + " permission.");
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
},
|
||||
|
||||
hasDeadWrapper: function hasDeadWrapper() {
|
||||
return Cu.isDeadWrapper(this._window) || Cu.isDeadWrapper(this.__DOM_IMPL__);
|
||||
},
|
||||
|
@ -82,6 +82,7 @@ interface MozNFC : EventTarget {
|
||||
/**
|
||||
* This event will be fired if the tag detected in ontagfound has been removed.
|
||||
*/
|
||||
[CheckPermissions="nfc-read nfc-write"]
|
||||
attribute EventHandler ontaglost;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user