Bug 1037128 - Regression: Contact API usage is being prompt on webpages. r=fabrice, a=2.0+
authorMark Finkle <mfinkle@mozilla.com>
Mon, 14 Jul 2014 10:31:16 -0700
changeset 208133 9779e1a3c05b253138ff0a508e752fdd47698faa
parent 208132 dfeac3d29b5e71016beca4c77642ad9a2acf1258
child 208134 69030cc2f1783b6d7454cffc80f6f75be21bea3c
push id3741
push userasasaki@mozilla.com
push dateMon, 21 Jul 2014 20:25:18 +0000
treeherdermozilla-beta@4d6f46f5af68 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfabrice, 2
bugs1037128
milestone32.0a2
Bug 1037128 - Regression: Contact API usage is being prompt on webpages. r=fabrice, a=2.0+
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"