Bug 1320404 - Remove appId from origin attributes - part 2 - NO_APP_ID UNKNOWN_APP_ID, r=Ehsan
☠☠ backed out by ad04ccedc21e ☠ ☠
authorAndrea Marchesini <amarchesini@mozilla.com>
Wed, 01 May 2019 23:21:54 +0000
changeset 531020 557b586f774a9ce81cc2ef79bbd8c991e9d4ecc8
parent 531019 5a20b5f43280e18252fc1637a82f7dfa69e920fd
child 531021 fed7c475d75c645701b7b520bed98fedfba67eae
push id11265
push userffxbld-merge
push dateMon, 13 May 2019 10:53:39 +0000
treeherdermozilla-beta@77e0fe8dbdd3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersEhsan
bugs1320404
milestone68.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 1320404 - Remove appId from origin attributes - part 2 - NO_APP_ID UNKNOWN_APP_ID, r=Ehsan Differential Revision: https://phabricator.services.mozilla.com/D29354
caps/nsIScriptSecurityManager.idl
caps/tests/unit/test_origin.js
dom/ipc/PTabContext.ipdlh
dom/ipc/TabContext.cpp
dom/quota/ActorsParent.cpp
dom/storage/StorageUtils.cpp
mobile/android/components/ContentPermissionPrompt.js
netwerk/base/nsILoadContextInfo.idl
--- a/caps/nsIScriptSecurityManager.idl
+++ b/caps/nsIScriptSecurityManager.idl
@@ -241,19 +241,16 @@ interface nsIScriptSecurityManager : nsI
     nsIPrincipal getChannelResultPrincipalIfNotSandboxed(in nsIChannel aChannel);
 
     /**
      * Get the codebase principal for the channel's URI.
      * aChannel must not be null.
      */
     nsIPrincipal getChannelURIPrincipal(in nsIChannel aChannel);
 
-    const unsigned long NO_APP_ID = 0;
-    const unsigned long UNKNOWN_APP_ID = 4294967295; // UINT32_MAX
-
     const unsigned long DEFAULT_USER_CONTEXT_ID = 0;
 
     /**
      * Per-domain controls to enable and disable script. This system is designed
      * to be used by at most one consumer, and enforces this with its semantics.
      *
      * Initially, domainPolicyActive is false. When activateDomainPolicy() is
      * invoked, domainPolicyActive becomes true, and subsequent calls to
--- a/caps/tests/unit/test_origin.js
+++ b/caps/tests/unit/test_origin.js
@@ -98,30 +98,16 @@ function run_test() {
   checkOriginAttributes(nullPrin_browser, {inIsolatedMozBrowser: true}, "^inBrowser=1");
   Assert.equal(exampleOrg_browser.origin, "http://example.org^inBrowser=1");
 
   // First party Uri
   var exampleOrg_firstPartyDomain = ssm.createCodebasePrincipal(makeURI("http://example.org"), {firstPartyDomain: "example.org"});
   checkOriginAttributes(exampleOrg_firstPartyDomain, { firstPartyDomain: "example.org" }, "^firstPartyDomain=example.org");
   Assert.equal(exampleOrg_firstPartyDomain.origin, "http://example.org^firstPartyDomain=example.org");
 
-  // Make sure we don't crash when serializing principals with UNKNOWN_APP_ID.
-  try {
-    let binaryStream = Cc["@mozilla.org/binaryoutputstream;1"].
-                       createInstance(Ci.nsIObjectOutputStream);
-    let pipe = Cc["@mozilla.org/pipe;1"].createInstance(Ci.nsIPipe);
-    pipe.init(false, false, 0, 0xffffffff, null);
-    binaryStream.setOutputStream(pipe.outputStream);
-    binaryStream.writeCompoundObject(simplePrin, Ci.nsISupports, true); // eslint-disable-line no-undef
-    binaryStream.close();
-  } catch (e) {
-    Assert.ok(true);
-  }
-
-
   // Just userContext.
   var exampleOrg_userContext = ssm.createCodebasePrincipal(makeURI("http://example.org"), {userContextId: 42});
   checkOriginAttributes(exampleOrg_userContext, { userContextId: 42 }, "^userContextId=42");
   Assert.equal(exampleOrg_userContext.origin, "http://example.org^userContextId=42");
 
   checkSandboxOriginAttributes(null, {});
   checkSandboxOriginAttributes("http://example.org", {});
   checkSandboxOriginAttributes("http://example.org", {}, {originAttributes: {}});
--- a/dom/ipc/PTabContext.ipdlh
+++ b/dom/ipc/PTabContext.ipdlh
@@ -15,18 +15,17 @@ using mozilla::OriginAttributes from "mo
 namespace mozilla {
 namespace dom {
 
 // An IPCTabContext which corresponds to a PBrowser opened by a child when it
 // receives window.open().
 //
 // If isMozBrowserElement is false, this PopupIPCTabContext is either a
 // <xul:browser> or an app frame.  The frame's app-id and app-frame-owner-app-id
-// will be equal to the opener's values.  For a <xul:browser>, those app IDs
-// will be NO_APP_ID.
+// will be equal to the opener's values.
 //
 // It's an error to set isMozBrowserElement == false if opener is a mozbrowser
 // element.  Such a PopupIPCTabContext should be rejected by code which receives
 // it.
 struct PopupIPCTabContext
 {
   PBrowserOrId opener;
   bool isMozBrowserElement;
--- a/dom/ipc/TabContext.cpp
+++ b/dom/ipc/TabContext.cpp
@@ -7,18 +7,16 @@
 #include "mozilla/dom/TabContext.h"
 #include "mozilla/dom/PTabContext.h"
 #include "mozilla/dom/BrowserParent.h"
 #include "mozilla/dom/BrowserChild.h"
 #include "mozilla/StaticPrefs.h"
 #include "nsIScriptSecurityManager.h"
 #include "nsServiceManagerUtils.h"
 
-#define NO_APP_ID (nsIScriptSecurityManager::NO_APP_ID)
-
 using namespace mozilla::dom::ipc;
 using namespace mozilla::layout;
 
 namespace mozilla {
 namespace dom {
 
 TabContext::TabContext()
     : mInitialized(false),
--- a/dom/quota/ActorsParent.cpp
+++ b/dom/quota/ActorsParent.cpp
@@ -2029,17 +2029,17 @@ void GetJarPrefix(bool aInIsolatedMozBro
   // Fallback.
   if (!aInIsolatedMozBrowser) {
     return;
   }
 
   // AppId is an unused b2g identifier. Let's set it to 0 all the time (see bug
   // 1320404).
   // aJarPrefix = appId + "+" + { 't', 'f' } + "+";
-  aJarPrefix.AppendInt(nsIScriptSecurityManager::NO_APP_ID);
+  aJarPrefix.AppendInt(0);  // TODO: this is the appId, to be removed.
   aJarPrefix.Append('+');
   aJarPrefix.Append(aInIsolatedMozBrowser ? 't' : 'f');
   aJarPrefix.Append('+');
 }
 
 nsresult CreateDirectoryMetadata(nsIFile* aDirectory, int64_t aTimestamp,
                                  const nsACString& aSuffix,
                                  const nsACString& aGroup,
--- a/dom/storage/StorageUtils.cpp
+++ b/dom/storage/StorageUtils.cpp
@@ -114,17 +114,17 @@ nsCString Scheme0Scope(const nsACString&
 
   OriginAttributes oa;
   if (!aOriginSuffix.IsEmpty()) {
     DebugOnly<bool> success = oa.PopulateFromSuffix(aOriginSuffix);
     MOZ_ASSERT(success);
   }
 
   if (oa.mInIsolatedMozBrowser) {
-    result.AppendInt(nsIScriptSecurityManager::NO_APP_ID);
+    result.AppendInt(0);  // This is the appId to be removed.
     result.Append(':');
     result.Append(oa.mInIsolatedMozBrowser ? 't' : 'f');
     result.Append(':');
   }
 
   // If there is more than just appid and/or inbrowser stored in origin
   // attributes, put it to the schema 0 scope as well.  We must do that
   // to keep the scope column unique (same resolution as schema 1 has
--- a/mobile/android/components/ContentPermissionPrompt.js
+++ b/mobile/android/components/ContentPermissionPrompt.js
@@ -19,33 +19,28 @@ const kEntities = {
 
 function ContentPermissionPrompt() {}
 
 ContentPermissionPrompt.prototype = {
   classID: Components.ID("{C6E8C44D-9F39-4AF7-BCC0-76E38A8310F5}"),
 
   QueryInterface: ChromeUtils.generateQI([Ci.nsIContentPermissionPrompt]),
 
-  handleExistingPermission: function handleExistingPermission(request, type, isApp, callback) {
+  handleExistingPermission: function handleExistingPermission(request, type, callback) {
     let result = Services.perms.testExactPermissionFromPrincipal(request.principal, type);
     if (result == Ci.nsIPermissionManager.ALLOW_ACTION) {
       callback(/* allow */ true);
       return true;
     }
 
     if (result == Ci.nsIPermissionManager.DENY_ACTION) {
       callback(/* allow */ false);
       return true;
     }
 
-    if (isApp && result == Ci.nsIPermissionManager.UNKNOWN_ACTION) {
-      callback(/* allow */ false);
-      return true;
-    }
-
     return false;
   },
 
   getChromeWindow: function getChromeWindow(aWindow) {
      let chromeWin = aWindow.docShell.rootTreeItem.domWindow
                             .QueryInterface(Ci.nsIDOMChromeWindow);
      return chromeWin;
   },
@@ -54,18 +49,16 @@ ContentPermissionPrompt.prototype = {
     if (request.window) {
       let requestingWindow = request.window.top;
       return this.getChromeWindow(requestingWindow).wrappedJSObject;
     }
     return request.element.ownerGlobal;
   },
 
   prompt: function(request) {
-    let isApp = request.principal.appId !== Ci.nsIScriptSecurityManager.NO_APP_ID && request.principal.appId !== Ci.nsIScriptSecurityManager.UNKNOWN_APP_ID;
-
     // Only allow exactly one permission rquest here.
     let types = request.types.QueryInterface(Ci.nsIArray);
     if (types.length != 1) {
       request.cancel();
       return;
     }
 
     let perm = types.queryElementAt(0, Ci.nsIContentPermissionType);
@@ -81,17 +74,17 @@ ContentPermissionPrompt.prototype = {
             (granted ? request.allow : request.cancel)();
           });
         return;
       }
       request.allow();
     };
 
     // Returns true if the request was handled
-    if (this.handleExistingPermission(request, perm.type, isApp, callback)) {
+    if (this.handleExistingPermission(request, perm.type, callback)) {
        return;
     }
 
     if (perm.type === "desktop-notification" &&
         Services.prefs.getBoolPref("dom.webnotifications.requireuserinteraction", false) &&
         !request.isHandlingUserInput) {
       request.cancel();
       return;
@@ -111,19 +104,16 @@ ContentPermissionPrompt.prototype = {
       },
     },
     {
       label: browserBundle.GetStringFromName(entityName + ".allow"),
       callback: function(aChecked) {
         // If the user checked "Don't ask again" or this is a desktopNotification, make a permanent exception
         if (aChecked || entityName == "desktopNotification2") {
           Services.perms.addFromPrincipal(request.principal, perm.type, Ci.nsIPermissionManager.ALLOW_ACTION);
-        } else if (isApp) {
-          // Otherwise allow the permission for the current session if the request comes from an app
-          Services.perms.addFromPrincipal(request.principal, perm.type, Ci.nsIPermissionManager.ALLOW_ACTION, Ci.nsIPermissionManager.EXPIRE_SESSION);
         }
 
         callback(/* allow */ true);
       },
       positive: true,
     }];
 
     let chromeWin = this.getChromeForRequest(request);
--- a/netwerk/base/nsILoadContextInfo.idl
+++ b/netwerk/base/nsILoadContextInfo.idl
@@ -18,19 +18,16 @@ interface nsIDOMWindow;
  * encapsulating origin attributes and IsAnonymous, IsPrivite properties.
  * It shall be used where nsILoadContext cannot be used or is not
  * available.
  */
 
 [scriptable, builtinclass, uuid(555e2f8a-a1f6-41dd-88ca-ed4ed6b98a22)]
 interface nsILoadContextInfo : nsISupports
 {
-  const unsigned long NO_APP_ID = 0;
-  const unsigned long UNKNOWN_APP_ID = 4294967295; // UINT32_MAX
-
   /**
    * Whether the context is in a Private Browsing mode
    */
   readonly attribute boolean isPrivate;
 
   /**
    * Whether the load is initiated as anonymous
    */