Bug 1037128 - Regression: Contact API usage is being prompt on webpages r=fabrice
authorMark Finkle <mfinkle@mozilla.com>
Mon, 14 Jul 2014 10:31:16 -0700
changeset 195027 0144a56aef7037e542af87713465bffa1d91a4e5
parent 195026 7af840411ed9f8a5f1a52079d36e1077282717a7
child 195028 8d70f13112e26ea9a8ccf47146e8507bf68df638
push id9056
push userfdesre@mozilla.com
push dateSat, 19 Jul 2014 21:41:51 +0000
treeherderb2g-inbound@8d70f13112e2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfabrice
bugs1037128
milestone33.0a1
Bug 1037128 - Regression: Contact API usage is being prompt on webpages r=fabrice
dom/contacts/ContactManager.js
dom/contacts/tests/mochitest.ini
--- a/dom/contacts/ContactManager.js
+++ b/dom/contacts/ContactManager.js
@@ -243,20 +243,26 @@ ContactManager.prototype = {
       }
 
     // Shortcut for ALLOW_ACTION so we avoid a parent roundtrip
     let principal = this._window.document.nodePrincipal;
     let type = "contacts-" + access;
     let permValue =
       Services.perms.testExactPermissionFromPrincipal(principal, type);
     if (permValue == Ci.nsIPermissionManager.ALLOW_ACTION) {
-      aAllowCallback();
+      if (aAllowCallback) {
+        aAllowCallback();
+      }
       return;
-    } else if (permValue == Ci.nsIPermissionManager.DENY_ACTION) {
-      aCancelCallback();
+    } else if (permValue == Ci.nsIPermissionManager.DENY_ACTION ||
+               permValue == Ci.nsIPermissionManager.UNKNOWN_ACTION) {
+      if (aCancelCallback) {
+        aCancelCallback();
+      }
+      return;
     }
 
     // Create an array with a single nsIContentPermissionType element.
     let type = {
       type: "contacts",
       access: access,
       options: null,
       QueryInterface: XPCOMUtils.generateQI([Ci.nsIContentPermissionType])
@@ -420,34 +426,34 @@ ContactManager.prototype = {
 
     let allowCallback = function() {
       cpmm.sendAsyncMessage("Contacts:GetRevision", {
         requestID: this.getRequestId({ request: request })
       });
     }.bind(this);
 
     let cancelCallback = function() {
-      Services.DOMRequest.fireError(request);
+      Services.DOMRequest.fireError(request, "");
     };
 
     this.askPermission("revision", request, allowCallback, cancelCallback);
     return request;
   },
 
   getCount: function() {
     let request = this.createRequest();
 
     let allowCallback = function() {
       cpmm.sendAsyncMessage("Contacts:GetCount", {
         requestID: this.getRequestId({ request: request })
       });
     }.bind(this);
 
     let cancelCallback = function() {
-      Services.DOMRequest.fireError(request);
+      Services.DOMRequest.fireError(request, "");
     };
 
     this.askPermission("count", request, allowCallback, cancelCallback);
     return request;
   },
 
   init: function(aWindow) {
     // DOMRequestIpcHelper.initHelper sets this._window
--- a/dom/contacts/tests/mochitest.ini
+++ b/dom/contacts/tests/mochitest.ini
@@ -1,20 +1,23 @@
 [DEFAULT]
 skip-if = e10s
 
 [shared.js]
 [test_contacts_basics.html]
 skip-if = (toolkit == 'gonk' && debug) #debug-only failure
 [test_contacts_basics2.html]
+skip-if = (toolkit == 'gonk' && debug) #debug-only failure
 [test_contacts_blobs.html]
+skip-if = (toolkit == 'gonk' && debug) #debug-only failure
 [test_contacts_events.html]
 [test_contacts_getall.html]
 skip-if = (toolkit == 'gonk' && debug) #debug-only failure
 [test_contacts_getall2.html]
+skip-if = (toolkit == 'gonk' && debug) #debug-only failure
 [test_contacts_international.html]
 [test_contacts_substringmatching.html]
 [test_contacts_substringmatchingVE.html]
 [test_contacts_substringmatchingCL.html]
 [test_migration.html]
   support-files =
     test_migration_chrome.js
   skip-if = os == "android"