Bug 1369314 - Get rid of nsScriptSecurityManager::GetAppCodebasePrincipal, r=bholley
authorAndrea Marchesini <amarchesini@mozilla.com>
Fri, 02 Jun 2017 11:05:28 +0200
changeset 410125 f46160bbc4ec20a480a1305aecfa46107e50b19d
parent 410124 0734a4af21613c3791f21c35aac808fb4f74e07a
child 410126 79b91cee64f10c00a9c9c0ebb11f4d047fd7609f
push id7391
push usermtabara@mozilla.com
push dateMon, 12 Jun 2017 13:08:53 +0000
treeherdermozilla-beta@2191d7f87e2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbholley
bugs1369314
milestone55.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1369314 - Get rid of nsScriptSecurityManager::GetAppCodebasePrincipal, r=bholley
caps/nsIScriptSecurityManager.idl
caps/nsScriptSecurityManager.cpp
dom/push/test/xpcshell/head.js
dom/push/test/xpcshell/test_service_child.js
--- a/caps/nsIScriptSecurityManager.idl
+++ b/caps/nsIScriptSecurityManager.idl
@@ -129,28 +129,16 @@ interface nsIScriptSecurityManager : nsI
     ///////////////// Principals ///////////////////////
 
     /**
      * Return the all-powerful system principal.
      */
     nsIPrincipal getSystemPrincipal();
 
     /**
-     * Returns a principal that has the given information.
-     * @param appId is the app id of the principal. It can't be UNKNOWN_APP_ID.
-     * @param inMozBrowser is true if the principal has to be considered as
-     * inside a mozbrowser frame.
-     *
-     * @deprecated use createCodebasePrincipal instead.
-     */
-    [deprecated] nsIPrincipal getAppCodebasePrincipal(in nsIURI uri,
-                                                      in unsigned long appId,
-                                                      in boolean inMozBrowser);
-
-    /**
      * Returns a principal that has the appId and inMozBrowser of the load
      * context.
      * @param loadContext to get appId/inMozBrowser from.
      */
     nsIPrincipal getLoadContextCodebasePrincipal(in nsIURI uri,
                                                  in nsILoadContext loadContext);
 
     /**
--- a/caps/nsScriptSecurityManager.cpp
+++ b/caps/nsScriptSecurityManager.cpp
@@ -1160,31 +1160,16 @@ nsScriptSecurityManager::CreateNullPrinc
       return NS_ERROR_INVALID_ARG;
   }
   nsCOMPtr<nsIPrincipal> prin = NullPrincipal::Create(attrs);
   prin.forget(aPrincipal);
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsScriptSecurityManager::GetAppCodebasePrincipal(nsIURI* aURI,
-                                                 uint32_t aAppId,
-                                                 bool aInIsolatedMozBrowser,
-                                                 nsIPrincipal** aPrincipal)
-{
-  NS_ENSURE_TRUE(aAppId != nsIScriptSecurityManager::UNKNOWN_APP_ID,
-                 NS_ERROR_INVALID_ARG);
-
-  OriginAttributes attrs(aAppId, aInIsolatedMozBrowser);
-  nsCOMPtr<nsIPrincipal> prin = BasePrincipal::CreateCodebasePrincipal(aURI, attrs);
-  prin.forget(aPrincipal);
-  return *aPrincipal ? NS_OK : NS_ERROR_FAILURE;
-}
-
-NS_IMETHODIMP
 nsScriptSecurityManager::
   GetLoadContextCodebasePrincipal(nsIURI* aURI,
                                   nsILoadContext* aLoadContext,
                                   nsIPrincipal** aPrincipal)
 {
   NS_ENSURE_STATE(aLoadContext);
   OriginAttributes docShellAttrs;
   aLoadContext->GetOriginAttributes(docShellAttrs);
--- a/dom/push/test/xpcshell/head.js
+++ b/dom/push/test/xpcshell/head.js
@@ -425,24 +425,16 @@ var tearDownServiceInParent = Task.async
 
   let record = yield db.getByIdentifiers({
     scope: 'https://example.com/sub/ok',
     originAttributes: '',
   });
   ok(record.pushEndpoint.startsWith('https://example.org/push'),
     'Wrong push endpoint in subscription record');
 
-  record = yield db.getByIdentifiers({
-    scope: 'https://example.net/scope/1',
-    originAttributes: ChromeUtils.originAttributesToSuffix(
-      { appId: 1, inIsolatedMozBrowser: true }),
-  });
-  ok(record.pushEndpoint.startsWith('https://example.org/push'),
-    'Wrong push endpoint in app record');
-
   record = yield db.getByKeyID('3a414737-2fd0-44c0-af05-7efc172475fc');
   ok(!record, 'Unsubscribed record should not exist');
 });
 
 function putTestRecord(db, keyID, scope, quota) {
   return db.put({
     channelID: keyID,
     pushEndpoint: 'https://example.org/push/' + keyID,
--- a/dom/push/test/xpcshell/test_service_child.js
+++ b/dom/push/test/xpcshell/test_service_child.js
@@ -224,37 +224,16 @@ add_test(function test_unsubscribe_error
       strictEqual(success, false, 'Unexpected successful unsubscribe');
 
       do_test_finished();
       run_next_test();
     }
   );
 });
 
-add_test(function test_subscribe_app_principal() {
-  let principal = Services.scriptSecurityManager.getAppCodebasePrincipal(
-    Services.io.newURI('https://example.net/app/1'),
-    1, /* appId */
-    true /* browserOnly */
-  );
-
-  do_test_pending();
-  PushServiceComponent.subscribe('https://example.net/scope/1', principal, (result, subscription) => {
-    ok(Components.isSuccessCode(result), 'Error creating subscription');
-    ok(subscription.endpoint.startsWith('https://example.org/push'),
-      'Wrong push endpoint in app subscription');
-    ok(!subscription.isSystemSubscription,
-      'Unexpected system subscription for app principal');
-    equal(subscription.quota, 16, 'Wrong quota for app subscription');
-
-    do_test_finished();
-    run_next_test();
-  });
-});
-
 add_test(function test_subscribe_origin_principal() {
   let scope = 'https://example.net/origin-principal';
   let principal =
     Services.scriptSecurityManager.createCodebasePrincipalFromOrigin(scope);
 
   do_test_pending();
   PushServiceComponent.subscribe(scope, principal, (result, subscription) => {
     ok(Components.isSuccessCode(result),