Backed out 2 changesets (bug 1197461) for various test failures. r=backout on a CLOSED TREE
authorSebastian Hengst <archaeopteryx@coole-files.de>
Mon, 15 Feb 2016 19:38:11 +0100
changeset 331091 24876669d491b75f24157f6d55032b48ac7704fb
parent 331090 3c0f35eeadc044a8200a990422414d798426ea59
child 331092 1c173bd383e7a7fb8e33ad12ea814f29add489ad
push id10892
push usercmanchester@mozilla.com
push dateMon, 15 Feb 2016 20:06:39 +0000
reviewersbackout
bugs1197461
milestone47.0a1
backs outd776c61906c17234f60c8df54ed4f913959eb5eb
c046a81ab5a373e8ce2c2a8c16aca43eedf4914f
Backed out 2 changesets (bug 1197461) for various test failures. r=backout on a CLOSED TREE Backed out changeset d776c61906c1 (bug 1197461) Backed out changeset c046a81ab5a3 (bug 1197461)
dom/permission/Permissions.cpp
dom/permission/Permissions.h
dom/permission/tests/test_permissions_api.html
dom/webidl/Permissions.webidl
--- a/dom/permission/Permissions.cpp
+++ b/dom/permission/Permissions.cpp
@@ -116,63 +116,10 @@ Permissions::Query(JSContext* aCx,
     promise->MaybeReject(aRv);
   } else {
     MOZ_ASSERT(status);
     promise->MaybeResolve(status);
   }
   return promise.forget();
 }
 
-already_AddRefed<Promise>
-Permissions::Revoke(JSContext* aCx,
-                    JS::Handle<JSObject*> aPermission,
-                    ErrorResult& aRv)
-{
-  nsCOMPtr<nsIGlobalObject> global = do_QueryInterface(mWindow);
-  if (!global) {
-    aRv.Throw(NS_ERROR_UNEXPECTED);
-    return nullptr;
-  }
-
-  RefPtr<Promise> promise = Promise::Create(global, aRv);
-  if (NS_WARN_IF(aRv.Failed())) {
-    return nullptr;
-  }
-
-  PermissionDescriptor permission;
-  JS::Rooted<JS::Value> value(aCx, JS::ObjectOrNullValue(aPermission));
-  if (NS_WARN_IF(!permission.Init(aCx, value))) {
-    promise->MaybeReject(NS_ERROR_UNEXPECTED);
-    return promise.forget();
-  }
-
-  nsCOMPtr<nsIDocument> document = mWindow->GetExtantDoc();
-  if (!document) {
-    promise->MaybeReject(NS_ERROR_UNEXPECTED);
-    return promise.forget();
-  }
-
-  nsCOMPtr<nsIPermissionManager> permMgr = services::GetPermissionManager();
-  if (NS_WARN_IF(!permMgr)) {
-    promise->MaybeReject(NS_ERROR_FAILURE);
-    return promise.forget();
-  }
-
-  nsresult rv = permMgr->RemoveFromPrincipal(document->NodePrincipal(), PermissionNameToType(permission.mName));
-  if (NS_WARN_IF(NS_FAILED(rv))) {
-    promise->MaybeReject(rv);
-    return promise.forget();
-  }
-
-  RefPtr<PermissionStatus> status =
-    CreatePermissionStatus(aCx, aPermission, mWindow, aRv);
-  if (NS_WARN_IF(aRv.Failed())) {
-    MOZ_ASSERT(!status);
-    promise->MaybeReject(aRv);
-  } else {
-    MOZ_ASSERT(status);
-    promise->MaybeResolve(status);
-  }
-  return promise.forget();
-}
-
 } // namespace dom
 } // namespace mozilla
--- a/dom/permission/Permissions.h
+++ b/dom/permission/Permissions.h
@@ -33,20 +33,16 @@ public:
 
   JSObject* WrapObject(JSContext* aCx,
                        JS::Handle<JSObject*> aGivenProto) override;
 
   already_AddRefed<Promise> Query(JSContext* aCx,
                                   JS::Handle<JSObject*> aPermission,
                                   ErrorResult& aRv);
 
-  already_AddRefed<Promise> Revoke(JSContext* aCx,
-                                   JS::Handle<JSObject*> aPermission,
-                                   ErrorResult& aRv);
-
 private:
   ~Permissions();
 
   nsCOMPtr<nsPIDOMWindowInner> mWindow;
 };
 
 } // namespace dom
 } // namespace mozilla
--- a/dom/permission/tests/test_permissions_api.html
+++ b/dom/permission/tests/test_permissions_api.html
@@ -37,49 +37,27 @@ function setPermissions(action) {
   });
   return new Promise((resolve, reject) => {
     SpecialPowers.popPermissions(() => {
       SpecialPowers.pushPermissions(permissions, resolve);
     });
   });
 }
 
-function revokePermissions(action) {
-  return Promise.all(PERMISSIONS.map(x =>
-    navigator.permissions.revoke({ name: x.name }).then(
-      result => is(result.state, "prompt", `correct state for '${x.name}'`),
-      error => ok(false, `query should not have rejected for '${x.name}'`))
-  ));
-}
-
-function revokeUnsupportedPermissions() {
-  return Promise.all(UNSUPPORTED_PERMISSIONS.map(name =>
-    navigator.permissions.revoke({ name: name }).then(
-      result => ok(false, `revoke should not have resolved for '${name}'`),
-      error => is(error.name, 'TypeError', `revoke should have thrown TypeError for '${name}'`))
-  ));
-}
-
-function revokeUserVisiblePushPermission() {
-  return navigator.permissions.revoke({ name: 'push', userVisible: true }).then(
-    result => ok(false, `revoke should not have resolved for userVisible push`),
-    error => ok(true, `revoke should have rejected for userVisible push`));
-}
-
 function checkPermissions(state) {
   return Promise.all(PERMISSIONS.map(x => {
     return navigator.permissions.query({ name: x.name }).then(
       result => is(result.state, state, `correct state for '${x.name}'`),
       error => ok(false, `query should not have rejected for '${x.name}'`));
   }));
 }
 
 function checkUnsupportedPermissions() {
   return Promise.all(UNSUPPORTED_PERMISSIONS.map(name => {
-    return navigator.permissions.query({ name: name }).then(
+    return navigator.permissions.query({ name }).then(
       result => ok(false, `query should not have resolved for '${name}'`),
       error => {
         is(error.name, 'TypeError',
            `query should have thrown TypeError for '${name}'`);
       });
   }));
 }
 
@@ -119,40 +97,29 @@ function testStatusOnChange() {
 }
 
 function testInvalidQuery() {
   navigator.permissions.query({ name: 'invalid' }).then(
     result => ok(false, 'invalid query should not have resolved'),
     error => ok(true, 'invalid query should have rejected'));
 }
 
-function testInvalidRevoke() {
-  navigator.permissions.revoke({ name: 'invalid' }).then(
-    result => ok(false, 'invalid revoke should not have resolved'),
-    error => ok(true, 'invalid revoke should have rejected'));
-}
-
 function runTests() {
   checkUnsupportedPermissions()
     .then(checkUserVisiblePushPermission)
     .then(() => setPermissions(UNKNOWN_ACTION))
     .then(() => checkPermissions('prompt'))
     .then(() => setPermissions(PROMPT_ACTION))
     .then(() => checkPermissions('prompt'))
     .then(() => setPermissions(ALLOW_ACTION))
     .then(() => checkPermissions('granted'))
     .then(() => setPermissions(DENY_ACTION))
     .then(() => checkPermissions('denied'))
     .then(testStatusOnChange)
     .then(testInvalidQuery)
-    .then(revokeUnsupportedPermissions)
-    .then(revokeUserVisiblePushPermission)
-    .then(revokePermissions)
-    .then(() => checkPermissions('prompt'))
-    .then(testInvalidRevoke)
     .then(SimpleTest.finish)
     .catch ((e) => {
       ok(false, 'Unexpected error ' + e);
       SimpleTest.finish();
     });
 }
 </script>
 </pre>
--- a/dom/webidl/Permissions.webidl
+++ b/dom/webidl/Permissions.webidl
@@ -21,11 +21,9 @@ dictionary PermissionDescriptor {
 dictionary PushPermissionDescriptor : PermissionDescriptor {
   boolean userVisible = false;
 };
 
 [Exposed=(Window)]
 interface Permissions {
   [Throws]
   Promise<PermissionStatus> query(object permission);
-  [Throws]
-  Promise<PermissionStatus> revoke(object permission);
 };