From 58878018ac3c4c4803213111a8c1db89399da5af Mon Sep 17 00:00:00 2001 From: "Carsten \"Tomcat\" Book" Date: Wed, 23 Sep 2015 10:17:54 +0200 Subject: [PATCH] Backed out 1 changesets (bug 1178533) for s4 testfailures Backed out changeset 8bbdb80f67e0 (bug 1178533) --HG-- extra : rebase_source : 040491f382ad7b03ba803686601f1272416ab47d --- b2g/installer/package-manifest.in | 5 - .../preferences/in-content/advanced.js | 3 +- browser/components/preferences/translation.js | 5 +- .../sessionstore/SessionStorage.jsm | 3 +- browser/installer/package-manifest.in | 5 - caps/BasePrincipal.cpp | 22 ---- caps/BasePrincipal.h | 1 - caps/nsIScriptSecurityManager.idl | 9 +- caps/nsScriptSecurityManager.cpp | 18 --- caps/tests/unit/test_origin.js | 5 +- dom/apps/PermissionsInstaller.jsm | 9 +- dom/moz.build | 1 - dom/newapps/InstallPackagedWebapp.js | 63 --------- dom/newapps/InstallPackagedWebapp.manifest | 2 - dom/newapps/interfaces/moz.build | 11 -- .../interfaces/nsIInstallPackagedWebapp.idl | 13 -- dom/newapps/moz.build | 14 -- dom/newapps/test/xpcshell/test_install.js | 121 ------------------ dom/newapps/test/xpcshell/xpcshell.ini | 5 - dom/permission/PermissionSettings.jsm | 52 +++----- dom/push/PushRecord.jsm | 4 +- dom/requestsync/RequestSyncService.jsm | 3 +- .../b2gdroid/installer/package-manifest.in | 4 - netwerk/protocol/http/PackagedAppService.cpp | 43 +------ netwerk/protocol/http/PackagedAppService.h | 13 +- toolkit/modules/BrowserUtils.jsm | 24 ++++ toolkit/modules/PermissionsUtils.jsm | 4 +- 27 files changed, 67 insertions(+), 395 deletions(-) delete mode 100644 dom/newapps/InstallPackagedWebapp.js delete mode 100644 dom/newapps/InstallPackagedWebapp.manifest delete mode 100644 dom/newapps/interfaces/moz.build delete mode 100644 dom/newapps/interfaces/nsIInstallPackagedWebapp.idl delete mode 100644 dom/newapps/moz.build delete mode 100644 dom/newapps/test/xpcshell/test_install.js delete mode 100644 dom/newapps/test/xpcshell/xpcshell.ini diff --git a/b2g/installer/package-manifest.in b/b2g/installer/package-manifest.in index 26f980fd3e0e..7951bb470ff3 100644 --- a/b2g/installer/package-manifest.in +++ b/b2g/installer/package-manifest.in @@ -185,7 +185,6 @@ @RESPATH@/components/dom.xpt @RESPATH@/components/dom_activities.xpt @RESPATH@/components/dom_apps.xpt -@RESPATH@/components/dom_newapps.xpt @RESPATH@/components/dom_audiochannel.xpt @RESPATH@/components/dom_base.xpt @RESPATH@/components/dom_system.xpt @@ -728,10 +727,6 @@ @RESPATH@/components/@DLL_PREFIX@mozgnome@DLL_SUFFIX@ #endif -; Signed Packaged Content -@RESPATH@/components/InstallPackagedWebapp.manifest -@RESPATH@/components/InstallPackagedWebapp.js - ; ANGLE on Win32 #ifdef XP_WIN32 #ifndef HAVE_64BIT_BUILD diff --git a/browser/components/preferences/in-content/advanced.js b/browser/components/preferences/in-content/advanced.js index 90949210aee9..7ec64ba4e6d8 100644 --- a/browser/components/preferences/in-content/advanced.js +++ b/browser/components/preferences/in-content/advanced.js @@ -6,6 +6,7 @@ Components.utils.import("resource://gre/modules/DownloadUtils.jsm"); Components.utils.import("resource://gre/modules/LoadContextInfo.jsm"); Components.utils.import("resource://gre/modules/XPCOMUtils.jsm"); +Components.utils.import("resource://gre/modules/BrowserUtils.jsm"); var gAdvancedPane = { _inited: false, @@ -571,7 +572,7 @@ var gAdvancedPane = { var list = document.getElementById("offlineAppsList"); var item = list.selectedItem; var origin = item.getAttribute("origin"); - var principal = Services.scriptSecurityManager.createCodebasePrincipalFromOrigin(origin); + var principal = BrowserUtils.principalFromOrigin(origin); var prompts = Components.classes["@mozilla.org/embedcomp/prompt-service;1"] .getService(Components.interfaces.nsIPromptService); diff --git a/browser/components/preferences/translation.js b/browser/components/preferences/translation.js index 8341740362ac..b10baf761e32 100644 --- a/browser/components/preferences/translation.js +++ b/browser/components/preferences/translation.js @@ -9,6 +9,7 @@ const {classes: Cc, interfaces: Ci, utils: Cu} = Components; Cu.import("resource://gre/modules/XPCOMUtils.jsm"); Cu.import("resource://gre/modules/Services.jsm"); +Cu.import("resource://gre/modules/BrowserUtils.jsm"); XPCOMUtils.defineLazyGetter(this, "gLangBundle", () => Services.strings.createBundle("chrome://global/locale/languageNames.properties")); @@ -189,7 +190,7 @@ var gTranslationExceptions = { onSiteDeleted: function() { let removedSites = this._siteTree.getSelectedItems(); for (let origin of removedSites) { - let principal = Services.scriptSecurityManager.createCodebasePrincipalFromOrigin(origin); + let principal = BrowserUtils.principalFromOrigin(origin); Services.perms.removeFromPrincipal(principal, kPermissionType); } }, @@ -202,7 +203,7 @@ var gTranslationExceptions = { this._siteTree.boxObject.rowCountChanged(0, -removedSites.length); for (let origin of removedSites) { - let principal = Services.scriptSecurityManager.createCodebasePrincipalFromOrigin(origin); + let principal = BrowserUtils.principalFromOrigin(origin); Services.perms.removeFromPrincipal(principal, kPermissionType); } diff --git a/browser/components/sessionstore/SessionStorage.jsm b/browser/components/sessionstore/SessionStorage.jsm index a2322e0181f9..5ed1dbdfa865 100644 --- a/browser/components/sessionstore/SessionStorage.jsm +++ b/browser/components/sessionstore/SessionStorage.jsm @@ -9,6 +9,7 @@ this.EXPORTED_SYMBOLS = ["SessionStorage"]; const Cu = Components.utils; const Ci = Components.interfaces; +Cu.import("resource://gre/modules/BrowserUtils.jsm"); Cu.import("resource://gre/modules/Services.jsm"); Cu.import("resource://gre/modules/XPCOMUtils.jsm"); @@ -104,7 +105,7 @@ var SessionStorageInternal = { restore: function (aDocShell, aStorageData) { for (let origin of Object.keys(aStorageData)) { let data = aStorageData[origin]; - let principal = Services.scriptSecurityManager.createCodebasePrincipalFromOrigin(origin); + let principal = BrowserUtils.principalFromOrigin(origin); let storageManager = aDocShell.QueryInterface(Ci.nsIDOMStorageManager); let window = aDocShell.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindow); diff --git a/browser/installer/package-manifest.in b/browser/installer/package-manifest.in index 3e19abd1d436..aaf28ca4a54f 100644 --- a/browser/installer/package-manifest.in +++ b/browser/installer/package-manifest.in @@ -193,7 +193,6 @@ @RESPATH@/components/dom_messages.xpt #endif @RESPATH@/components/dom_apps.xpt -@RESPATH@/components/dom_newapps.xpt @RESPATH@/components/dom_base.xpt @RESPATH@/components/dom_system.xpt #ifdef MOZ_B2G_BT @@ -637,10 +636,6 @@ @RESPATH@/components/PrivateBrowsing.manifest @RESPATH@/components/PrivateBrowsingTrackingProtectionWhitelist.js -; Signed Packaged Content -@RESPATH@/components/InstallPackagedWebapp.manifest -@RESPATH@/components/InstallPackagedWebapp.js - ; ANGLE GLES-on-D3D rendering library #ifdef MOZ_ANGLE_RENDERER @BINPATH@/libEGL.dll diff --git a/caps/BasePrincipal.cpp b/caps/BasePrincipal.cpp index 4faa72190d88..a864c85a234d 100644 --- a/caps/BasePrincipal.cpp +++ b/caps/BasePrincipal.cpp @@ -403,28 +403,6 @@ BasePrincipal::CreateCodebasePrincipal(nsIURI* aURI, OriginAttributes& aAttrs) return codebase.forget(); } -already_AddRefed -BasePrincipal::CreateCodebasePrincipal(const nsACString& aOrigin) -{ - MOZ_ASSERT(!StringBeginsWith(aOrigin, NS_LITERAL_CSTRING("[")), - "CreateCodebasePrincipal does not support System and Expanded principals"); - - MOZ_ASSERT(!StringBeginsWith(aOrigin, NS_LITERAL_CSTRING(NS_NULLPRINCIPAL_SCHEME ":")), - "CreateCodebasePrincipal does not support nsNullPrincipal"); - - nsAutoCString originNoSuffix; - mozilla::OriginAttributes attrs; - if (!attrs.PopulateFromOrigin(aOrigin, originNoSuffix)) { - return nullptr; - } - - nsCOMPtr uri; - nsresult rv = NS_NewURI(getter_AddRefs(uri), originNoSuffix); - NS_ENSURE_SUCCESS(rv, nullptr); - - return BasePrincipal::CreateCodebasePrincipal(uri, attrs); -} - bool BasePrincipal::AddonAllowsLoad(nsIURI* aURI) { diff --git a/caps/BasePrincipal.h b/caps/BasePrincipal.h index 67b4831de95f..01ed3927fa8a 100644 --- a/caps/BasePrincipal.h +++ b/caps/BasePrincipal.h @@ -137,7 +137,6 @@ public: static BasePrincipal* Cast(nsIPrincipal* aPrin) { return static_cast(aPrin); } static already_AddRefed CreateCodebasePrincipal(nsIURI* aURI, OriginAttributes& aAttrs); - static already_AddRefed CreateCodebasePrincipal(const nsACString& aOrigin); const OriginAttributes& OriginAttributesRef() { return mOriginAttributes; } uint32_t AppId() const { return mOriginAttributes.mAppId; } diff --git a/caps/nsIScriptSecurityManager.idl b/caps/nsIScriptSecurityManager.idl index cac4beec6a78..916563d85870 100644 --- a/caps/nsIScriptSecurityManager.idl +++ b/caps/nsIScriptSecurityManager.idl @@ -26,7 +26,7 @@ class DomainPolicyClone; [ptr] native JSObjectPtr(JSObject); [ptr] native DomainPolicyClonePtr(mozilla::dom::DomainPolicyClone); -[scriptable, uuid(b7ae2310-576e-11e5-a837-0800200c9a66)] +[scriptable, uuid(6e8a4d1e-d9c6-4d86-bf53-d73f58f36148)] interface nsIScriptSecurityManager : nsISupports { /** @@ -197,13 +197,6 @@ interface nsIScriptSecurityManager : nsISupports [implicit_jscontext] nsIPrincipal createCodebasePrincipal(in nsIURI uri, in jsval originAttributes); - /** - * Returns a principal whose origin is the one we pass in. - * See nsIPrincipal.idl for a description of origin attributes, and - * ChromeUtils.webidl for a list of origin attributes and their defaults. - */ - nsIPrincipal createCodebasePrincipalFromOrigin(in ACString origin); - /** * Returns a unique nonce principal with |originAttributes|. * See nsIPrincipal.idl for a description of origin attributes, and diff --git a/caps/nsScriptSecurityManager.cpp b/caps/nsScriptSecurityManager.cpp index 1b2b825a95dd..b9d414b3b2fd 100644 --- a/caps/nsScriptSecurityManager.cpp +++ b/caps/nsScriptSecurityManager.cpp @@ -67,7 +67,6 @@ #include "nsContentUtils.h" #include "nsJSUtils.h" #include "nsILoadInfo.h" -#include "nsXPCOMStrings.h" // This should be probably defined on some other place... but I couldn't find it #define WEBAPPS_PERM_NAME "webapps-manage" @@ -1044,23 +1043,6 @@ nsScriptSecurityManager::CreateCodebasePrincipal(nsIURI* aURI, JS::Handle prin = BasePrincipal::CreateCodebasePrincipal(aOrigin); - prin.forget(aPrincipal); - return *aPrincipal ? NS_OK : NS_ERROR_FAILURE; -} - NS_IMETHODIMP nsScriptSecurityManager::CreateNullPrincipal(JS::Handle aOriginAttributes, JSContext* aCx, nsIPrincipal** aPrincipal) diff --git a/caps/tests/unit/test_origin.js b/caps/tests/unit/test_origin.js index ff2d2449ab5e..8a84102d2d89 100644 --- a/caps/tests/unit/test_origin.js +++ b/caps/tests/unit/test_origin.js @@ -3,6 +3,7 @@ const Ci = Components.interfaces; const Cu = Components.utils; Cu.import("resource://gre/modules/Services.jsm"); +Cu.import("resource://gre/modules/BrowserUtils.jsm"); var ssm = Services.scriptSecurityManager; function makeURI(uri) { return Services.io.newURI(uri, null, null); } @@ -27,9 +28,9 @@ function checkOriginAttributes(prin, attrs, suffix) { do_check_eq(prin.originAttributes.inBrowser, attrs.inBrowser || false); do_check_eq(prin.originSuffix, suffix || ''); if (!prin.isNullPrincipal && !prin.origin.startsWith('[')) { - do_check_true(ssm.createCodebasePrincipalFromOrigin(prin.origin).equals(prin)); + do_check_true(BrowserUtils.principalFromOrigin(prin.origin).equals(prin)); } else { - checkThrows(() => ssm.createCodebasePrincipalFromOrigin(prin.origin)); + checkThrows(() => BrowserUtils.principalFromOrigin(prin.origin)); } } diff --git a/dom/apps/PermissionsInstaller.jsm b/dom/apps/PermissionsInstaller.jsm index e3ed3aca83d3..208b681dfbf8 100644 --- a/dom/apps/PermissionsInstaller.jsm +++ b/dom/apps/PermissionsInstaller.jsm @@ -164,8 +164,7 @@ this.PermissionsInstaller = { PermissionSettingsModule.getPermission(expandedPermNames[idx], aApp.manifestURL, aApp.origin, - false, - aApp.isCachedPackage); + false); if (permValue === "unknown") { permValue = PERM_TO_STRING[permission]; } @@ -193,7 +192,7 @@ this.PermissionsInstaller = { * The permission value. * @param object aApp * The just-installed app configuration. - * The properties used are manifestURL, origin, appId, isCachedPackage. + * The properties used are manifestURL and origin. * @returns void **/ _setPermission: function setPermission(aPermName, aPermValue, aApp) { @@ -202,9 +201,7 @@ this.PermissionsInstaller = { origin: aApp.origin, manifestURL: aApp.manifestURL, value: aPermValue, - browserFlag: false, - localId: aApp.localId, - isCachedPackage: aApp.isCachedPackage, + browserFlag: false }); } }; diff --git a/dom/moz.build b/dom/moz.build index 59c67682ceb7..4279c8ff757f 100644 --- a/dom/moz.build +++ b/dom/moz.build @@ -113,7 +113,6 @@ DIRS += [ 'resourcestats', 'manifest', 'vr', - 'newapps', ] if CONFIG['OS_ARCH'] == 'WINNT': diff --git a/dom/newapps/InstallPackagedWebapp.js b/dom/newapps/InstallPackagedWebapp.js deleted file mode 100644 index 5577e23b0db3..000000000000 --- a/dom/newapps/InstallPackagedWebapp.js +++ /dev/null @@ -1,63 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * * License, v. 2.0. If a copy of the MPL was not distributed with this file, - * * You can obtain one at http://mozilla.org/MPL/2.0/. */ - -const { classes: Cc, interfaces: Ci, utils: Cu, results: Cr, Constructor: CC } = Components; - -Cu.import("resource://gre/modules/XPCOMUtils.jsm"); -Cu.import("resource://gre/modules/AppsUtils.jsm"); - -XPCOMUtils.defineLazyModuleGetter(this, "PermissionsInstaller", - "resource://gre/modules/PermissionsInstaller.jsm"); - -function debug(aMsg) { - dump("-*-*- InstallPackagedWebapps.js : " + aMsg + "\n"); -} - -function InstallPackagedWebapp() { -} - -InstallPackagedWebapp.prototype = { - QueryInterface: XPCOMUtils.generateQI([Ci.nsIInstallPackagedWebapp]), - classID: Components.ID("{5cc6554a-5421-4a5e-b8c2-c62e8b7f4f3f}"), - - /** - * Install permissions for signed packaged web content - * @param string manifestContent - * The manifest content of the cached package. - * @param string aOrigin - * The package origin. - * @param string aManifestURL - * The manifest URL of the package. - * @returns boolean - **/ - - installPackagedWebapp: function(aManifestContent, aOrigin, aManifestURL) { - - try { - let isSuccess = true; - let manifest = JSON.parse(aManifestContent); - - PermissionsInstaller.installPermissions({ - manifest: manifest, - manifestURL: aManifestURL, - origin: aOrigin, - isPreinstalled: false, - isCachedPackage: true - }, false, function() { - Cu.reportError(ex); - }); - - // TODO Bug 1206058 - Register app handlers (system msg) on navigation - // to signed packages. - - return isSuccess; - } - catch(ex) { - Cu.reportError(ex); - return false; - } - }, -}; - -this.NSGetFactory = XPCOMUtils.generateNSGetFactory([InstallPackagedWebapp]); diff --git a/dom/newapps/InstallPackagedWebapp.manifest b/dom/newapps/InstallPackagedWebapp.manifest deleted file mode 100644 index 62699dc434f8..000000000000 --- a/dom/newapps/InstallPackagedWebapp.manifest +++ /dev/null @@ -1,2 +0,0 @@ -component {5cc6554a-5421-4a5e-b8c2-c62e8b7f4f3f} InstallPackagedWebapp.js -contract @mozilla.org/newapps/installpackagedwebapp;1 {5cc6554a-5421-4a5e-b8c2-c62e8b7f4f3f} diff --git a/dom/newapps/interfaces/moz.build b/dom/newapps/interfaces/moz.build deleted file mode 100644 index f9eb7a739b09..000000000000 --- a/dom/newapps/interfaces/moz.build +++ /dev/null @@ -1,11 +0,0 @@ -# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*- -# vim: set filetype=python: -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. - -XPIDL_SOURCES += [ - 'nsIInstallPackagedWebapp.idl' -] - -XPIDL_MODULE = 'dom_newapps' diff --git a/dom/newapps/interfaces/nsIInstallPackagedWebapp.idl b/dom/newapps/interfaces/nsIInstallPackagedWebapp.idl deleted file mode 100644 index b61ae1ed9ef1..000000000000 --- a/dom/newapps/interfaces/nsIInstallPackagedWebapp.idl +++ /dev/null @@ -1,13 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this file, - * You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#include "nsISupports.idl" - -[scriptable, uuid(3b4b69a0-56dc-11e5-a837-0800200c9a66)] -interface nsIInstallPackagedWebapp : nsISupports -{ - boolean installPackagedWebapp(in string aManifestContent, - in string aOrigin, - in string aManifestURL); -}; diff --git a/dom/newapps/moz.build b/dom/newapps/moz.build deleted file mode 100644 index f213894e296c..000000000000 --- a/dom/newapps/moz.build +++ /dev/null @@ -1,14 +0,0 @@ -# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*- -# vim: set filetype=python: -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. - -DIRS += ['interfaces'] - -EXTRA_COMPONENTS += [ - 'InstallPackagedWebapp.js', - 'InstallPackagedWebapp.manifest', -] - -XPCSHELL_TESTS_MANIFESTS += ['test/xpcshell/xpcshell.ini'] diff --git a/dom/newapps/test/xpcshell/test_install.js b/dom/newapps/test/xpcshell/test_install.js deleted file mode 100644 index 344120d99afb..000000000000 --- a/dom/newapps/test/xpcshell/test_install.js +++ /dev/null @@ -1,121 +0,0 @@ -/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ -/* Any copyright is dedicated to the Public Domain. - * http://creativecommons.org/publicdomain/zero/1.0/ */ - -'use strict'; - -const { classes: Cc, interfaces: Ci, utils: Cu } = Components; - -Cu.import('resource://gre/modules/XPCOMUtils.jsm'); -Cu.import('resource://gre/modules/Services.jsm'); -Cu.import("resource://gre/modules/PermissionSettings.jsm"); -Cu.import("resource://gre/modules/PermissionsTable.jsm"); -Cu.import("resource://gre/modules/AppsUtils.jsm"); - -const mod = Cc['@mozilla.org/newapps/installpackagedwebapp;1'] - .getService(Ci.nsIInstallPackagedWebapp); - -XPCOMUtils.defineLazyServiceGetter(this, - "appsService", - "@mozilla.org/AppsService;1", - "nsIAppsService"); - -function run_test() { - - let manifestWithPerms = { - name: "Test App", - launch_path: "/index.html", - type: "privileged", - permissions: { - "alarms": { }, - "wifi-manage": { }, - "tcp-socket": { }, - "desktop-notification": { }, - "geolocation": { }, - }, - }; - - let manifestNoPerms = { - name: "Test App", - launch_path: "/index.html", - type: "privileged", - }; - - let appStatus = "privileged"; - - // Triggering error due to bad manifest - let origin = ""; - let manifestURL = ""; - let manifestString = "boum"; - - let res = mod.installPackagedWebapp(manifestString, origin, manifestURL); - equal(res, false); - - // Install a package with permissions - origin = "http://test.com^appId=1019&inBrowser=1"; - manifestURL = "http://test.com/manifest.json"; - manifestString = JSON.stringify(manifestWithPerms); - let manifestHelper = new ManifestHelper(manifestWithPerms, origin, manifestURL); - - cleanDB(manifestHelper, origin, manifestURL); - - res = mod.installPackagedWebapp(manifestString, origin, manifestURL); - equal(res, true); - checkPermissions(manifestHelper, origin, manifestURL, appStatus); - - // Install a package with permissions - origin = "http://test.com"; - manifestHelper = new ManifestHelper(manifestWithPerms, origin, manifestURL); - - cleanDB(manifestHelper, origin, manifestURL); - - res = mod.installPackagedWebapp(manifestString, origin, manifestURL); - equal(res, true); - checkPermissions(manifestHelper, origin, manifestURL, appStatus); - - - // Install a package with no permission - origin = "http://bar.com^appId=1337&inBrowser=1"; - manifestURL = "http://bar.com/manifest.json"; - manifestString = JSON.stringify(manifestNoPerms); - manifestHelper = new ManifestHelper(manifestNoPerms, origin, manifestURL); - - cleanDB(manifestHelper, origin, manifestURL); - - res = mod.installPackagedWebapp(manifestString, origin, manifestURL); - equal(res, true); - checkPermissions(manifestHelper, origin, manifestURL, appStatus); -} - -// Cleaning permissions database before running a test -function cleanDB(manifestHelper, origin, manifestURL) { - for (let permName in manifestHelper.permissions) { - PermissionSettingsModule.removePermission(permName, manifestURL, origin, "", true); - } -} - -// Check permissions are correctly set in the database -function checkPermissions(manifestHelper, origin, manifestURL, appStatus) { - let perm; - for (let permName in manifestHelper.permissions) { - let permValue = PermissionSettingsModule.getPermission( - permName, manifestURL, origin, "", true); - switch (PermissionsTable[permName][appStatus]) { - case Ci.nsIPermissionManager.UNKNOWN_ACTION: - perm = "unknown"; - break; - case Ci.nsIPermissionManager.ALLOW_ACTION: - perm = "allow"; - break; - case Ci.nsIPermissionManager.DENY_ACTION: - perm = "deny"; - break; - case Ci.nsIPermissionManager.PROMPT_ACTION: - perm = "prompt"; - break; - default: - break; - } - equal(permValue, perm); - } -} diff --git a/dom/newapps/test/xpcshell/xpcshell.ini b/dom/newapps/test/xpcshell/xpcshell.ini deleted file mode 100644 index 5c1329e6e8be..000000000000 --- a/dom/newapps/test/xpcshell/xpcshell.ini +++ /dev/null @@ -1,5 +0,0 @@ -[DEFAULT] -head = -tail = - -[test_install.js] diff --git a/dom/permission/PermissionSettings.jsm b/dom/permission/PermissionSettings.jsm index ddd3a19c45d1..8cda5e09a043 100644 --- a/dom/permission/PermissionSettings.jsm +++ b/dom/permission/PermissionSettings.jsm @@ -67,23 +67,13 @@ this.PermissionSettingsModule = { _internalAddPermission: function _internalAddPermission(aData, aAllowAllChanges, aCallbacks) { - // TODO: Bug 1196644 - Add signPKg parameter into PermissionSettings.jsm. - let app; - let principal; - // Test if app is cached (signed streamable package) or installed via DOMApplicationRegistry - if (aData.isCachedPackage) { - // If the app is from packaged web app, the origin includes origin attributes already. - principal = - Services.scriptSecurityManager.createCodebasePrincipalFromOrigin(aData.origin); - app = {localId: principal.appId}; - } else { - app = appsService.getAppByManifestURL(aData.manifestURL); - let uri = Services.io.newURI(aData.origin, null, null); - principal = - Services.scriptSecurityManager.createCodebasePrincipal(uri, - {appId: app.localId, - inBrowser: aData.browserFlag}); - } + // TODO: Bug 1196644 - Add signPKg parameter into PermissionSettings.jsm + let uri = Services.io.newURI(aData.origin, null, null); + let app = appsService.getAppByManifestURL(aData.manifestURL); + let principal = + Services.scriptSecurityManager.createCodebasePrincipal(uri, + {appId: app.localId, + inBrowser: aData.browserFlag}); let action; switch (aData.value) @@ -116,24 +106,17 @@ this.PermissionSettingsModule = { } }, - getPermission: function getPermission(aPermName, aManifestURL, aOrigin, aBrowserFlag, aIsCachedPackage) { + getPermission: function getPermission(aPermName, aManifestURL, aOrigin, aBrowserFlag) { // TODO: Bug 1196644 - Add signPKg parameter into PermissionSettings.jsm debug("getPermission: " + aPermName + ", " + aManifestURL + ", " + aOrigin); - let principal; - // Test if app is cached (signed streamable package) or installed via DOMApplicationRegistry - if (aIsCachedPackage) { - // If the app is from packaged web app, the origin includes origin attributes already. - principal = - Services.scriptSecurityManager.createCodebasePrincipalFromOrigin(aOrigin); - } else { - let uri = Services.io.newURI(aOrigin, null, null); - let appID = appsService.getAppLocalIdByManifestURL(aManifestURL); - principal = - Services.scriptSecurityManager.createCodebasePrincipal(uri, - {appId: appID, - inBrowser: aBrowserFlag}); - } + let uri = Services.io.newURI(aOrigin, null, null); + let appID = appsService.getAppLocalIdByManifestURL(aManifestURL); + let principal = + Services.scriptSecurityManager.createCodebasePrincipal(uri, + {appId: appID, + inBrowser: aBrowserFlag}); let result = Services.perms.testExactPermissionFromPrincipal(principal, aPermName); + switch (result) { case Ci.nsIPermissionManager.UNKNOWN_ACTION: @@ -150,14 +133,13 @@ this.PermissionSettingsModule = { } }, - removePermission: function removePermission(aPermName, aManifestURL, aOrigin, aBrowserFlag, aIsCachedPackage) { + removePermission: function removePermission(aPermName, aManifestURL, aOrigin, aBrowserFlag) { let data = { type: aPermName, origin: aOrigin, manifestURL: aManifestURL, value: "unknown", - browserFlag: aBrowserFlag, - isCachedPackage: aIsCachedPackage + browserFlag: aBrowserFlag }; this._internalAddPermission(data, true); }, diff --git a/dom/push/PushRecord.jsm b/dom/push/PushRecord.jsm index b2e3c0e24150..a468ddd39cd4 100644 --- a/dom/push/PushRecord.jsm +++ b/dom/push/PushRecord.jsm @@ -19,6 +19,8 @@ XPCOMUtils.defineLazyModuleGetter(this, "PlacesUtils", XPCOMUtils.defineLazyModuleGetter(this, "PrivateBrowsingUtils", "resource://gre/modules/PrivateBrowsingUtils.jsm"); +XPCOMUtils.defineLazyModuleGetter(this, "BrowserUtils", + "resource://gre/modules/BrowserUtils.jsm"); this.EXPORTED_SYMBOLS = ["PushRecord"]; @@ -216,7 +218,7 @@ Object.defineProperties(PushRecord.prototype, { // Allow tests to omit origin attributes. url += this.originAttributes; } - principal = Services.scriptSecurityManager.createCodebasePrincipalFromOrigin(url); + principal = BrowserUtils.principalFromOrigin(url); principals.set(this, principal); } return principal; diff --git a/dom/requestsync/RequestSyncService.jsm b/dom/requestsync/RequestSyncService.jsm index 4e6bdda06973..c771f6438e1b 100644 --- a/dom/requestsync/RequestSyncService.jsm +++ b/dom/requestsync/RequestSyncService.jsm @@ -20,6 +20,7 @@ const RSYNC_STATE_ENABLED = "enabled"; const RSYNC_STATE_DISABLED = "disabled"; const RSYNC_STATE_WIFIONLY = "wifiOnly"; +Cu.import("resource://gre/modules/BrowserUtils.jsm"); Cu.import('resource://gre/modules/IndexedDBHelper.jsm'); Cu.import("resource://gre/modules/XPCOMUtils.jsm"); Cu.import("resource://gre/modules/Services.jsm"); @@ -174,7 +175,7 @@ this.RequestSyncService = { let dbKeys = []; for (let key in this._registrations) { - let prin = Services.scriptSecurityManager.createCodebasePrincipalFromOrigin(key); + let prin = BrowserUtils.principalFromOrigin(key); if (!ChromeUtils.originAttributesMatchPattern(prin.originAttributes, pattern)) { continue; } diff --git a/mobile/android/b2gdroid/installer/package-manifest.in b/mobile/android/b2gdroid/installer/package-manifest.in index 10d101962390..94ff64b2f381 100644 --- a/mobile/android/b2gdroid/installer/package-manifest.in +++ b/mobile/android/b2gdroid/installer/package-manifest.in @@ -138,7 +138,6 @@ @BINPATH@/components/dom.xpt @BINPATH@/components/dom_activities.xpt @BINPATH@/components/dom_apps.xpt -@BINPATH@/components/dom_newapps.xpt @BINPATH@/components/dom_base.xpt @BINPATH@/components/dom_canvas.xpt @BINPATH@/components/dom_core.xpt @@ -678,9 +677,6 @@ bin/libfreebl_32int64_3.so @BINPATH@/components/SystemMessageCache.js @BINPATH@/components/SystemMessageManager.manifest -@BINPATH@/components/InstallPackagedWebapp.manifest -@BINPATH@/components/InstallPackagedWebapp.js - @BINPATH@/components/B2GComponents.manifest @BINPATH@/components/AlertsService.js @BINPATH@/components/ContentPermissionPrompt.js diff --git a/netwerk/protocol/http/PackagedAppService.cpp b/netwerk/protocol/http/PackagedAppService.cpp index 1d5998584f05..a9205370954a 100644 --- a/netwerk/protocol/http/PackagedAppService.cpp +++ b/netwerk/protocol/http/PackagedAppService.cpp @@ -17,7 +17,6 @@ #include "mozilla/DebugOnly.h" #include "nsIHttpHeaderVisitor.h" #include "mozilla/LoadContext.h" -#include "nsIInstallPackagedWebapp.h" namespace mozilla { namespace net { @@ -431,7 +430,6 @@ PackagedAppService::PackagedAppDownloader::Init(nsILoadContextInfo* aInfo, mPackageKey = aKey; mPackageOrigin = aPackageOrigin; - mProcessingFirstRequest = true; return NS_OK; } @@ -625,8 +623,6 @@ PackagedAppService::PackagedAppDownloader::OnStopRequest(nsIRequest *aRequest, LOG(("[%p] PackagedAppDownloader::OnStopRequest > status:%X multiChannel:%p\n", this, aStatusCode, multiChannel.get())); - mProcessingFirstRequest = false; - // lastPart will be true if this is the last part in the package, // or if aRequest isn't a multipart channel bool lastPart = true; @@ -707,11 +703,6 @@ PackagedAppService::PackagedAppDownloader::ConsumeData(nsIInputStream *aStream, self->mWriter->ConsumeData(aFromRawSegment, aCount, aWriteCount); - if (self->mProcessingFirstRequest) { - // mProcessingFirstRequest will be set to false on the first OnStopRequest. - self->mManifestContent.Append(aFromRawSegment, aCount); - } - nsCOMPtr stream = CreateSharedStringStream(aFromRawSegment, aCount); return self->mVerifier->OnDataAvailable(nullptr, nullptr, stream, 0, aCount); } @@ -867,39 +858,11 @@ PackagedAppService::PackagedAppDownloader::NotifyOnStartSignedPackageRequest(con LOG(("Notifying the signed package is ready to load.")); } -void PackagedAppService::PackagedAppDownloader::InstallSignedPackagedApp(const ResourceCacheInfo* aInfo) +void PackagedAppService::PackagedAppDownloader::InstallSignedPackagedApp() { // TODO: Bug 1178533 to register permissions, system messages etc on navigation to // signed packages. LOG(("Install this packaged app.")); - bool isSuccess = false; - - nsCOMPtr installer = - do_GetService("@mozilla.org/newapps/installpackagedwebapp;1"); - - if (!installer) { - LOG(("InstallSignedPackagedApp: fail to get InstallPackagedWebapp service")); - return OnError(ERROR_GET_INSTALLER_FAILED); - } - - nsCString manifestURL; - aInfo->mURI->GetAsciiSpec(manifestURL); - - // Use the origin stored in the verifier since the signed packaged app would - // have a specifi package identifer defined in the manifest file. - nsCString packageOrigin; - mVerifier->GetPackageOrigin(packageOrigin); - - installer->InstallPackagedWebapp(mManifestContent.get(), - packageOrigin.get(), - manifestURL.get(), - &isSuccess); - if (!isSuccess) { - LOG(("InstallSignedPackagedApp: failed to install permissions")); - return OnError(ERROR_INSTALL_RESOURCE_FAILED); - } - - LOG(("InstallSignedPackagedApp: success.")); } //------------------------------------------------------------------ @@ -957,7 +920,7 @@ PackagedAppService::PackagedAppDownloader::OnManifestVerified(const ResourceCach nsCString packageOrigin; mVerifier->GetPackageOrigin(packageOrigin); NotifyOnStartSignedPackageRequest(packageOrigin); - InstallSignedPackagedApp(aInfo); + InstallSignedPackagedApp(); } void @@ -1124,7 +1087,7 @@ PackagedAppService::GetResource(nsIChannel *aChannel, downloader = new PackagedAppDownloader(); nsCString packageOrigin; - principal->GetOrigin(packageOrigin); + principal->GetOriginNoSuffix(packageOrigin); rv = downloader->Init(loadContextInfo, key, packageOrigin); if (NS_WARN_IF(NS_FAILED(rv))) { return rv; diff --git a/netwerk/protocol/http/PackagedAppService.h b/netwerk/protocol/http/PackagedAppService.h index e1ae1b01d250..4dd04dd00806 100644 --- a/netwerk/protocol/http/PackagedAppService.h +++ b/netwerk/protocol/http/PackagedAppService.h @@ -106,8 +106,6 @@ private: enum EErrorType { ERROR_MANIFEST_VERIFIED_FAILED, ERROR_RESOURCE_VERIFIED_FAILED, - ERROR_GET_INSTALLER_FAILED, - ERROR_INSTALL_RESOURCE_FAILED, }; public: @@ -174,7 +172,7 @@ private: // Handle all tasks about app installation like permission and system message // registration. - void InstallSignedPackagedApp(const ResourceCacheInfo* aInfo); + void InstallSignedPackagedApp(); // Calls all the callbacks registered for the given URI. // aURI is the full URI of a subresource, composed of packageURI + !// + subresourcePath @@ -213,15 +211,6 @@ private: // If you need the origin with the signity taken into account, use // PackagedAppVerifier::GetPackageOrigin(). nsCString mPackageOrigin; - - //The app id of the package loaded from the LoadContextInfo - uint32_t mAppId; - - // A flag to indicate if we are processing the first request. - bool mProcessingFirstRequest; - - // A in-memory copy of the manifest content. - nsCString mManifestContent; }; // Intercepts OnStartRequest, OnDataAvailable*, OnStopRequest method calls diff --git a/toolkit/modules/BrowserUtils.jsm b/toolkit/modules/BrowserUtils.jsm index 920c18ade006..bdeacf918403 100644 --- a/toolkit/modules/BrowserUtils.jsm +++ b/toolkit/modules/BrowserUtils.jsm @@ -100,6 +100,30 @@ this.BrowserUtils = { return Services.io.newURI(aCPOWURI.spec, aCPOWURI.originCharset, null); }, + // Creates a codebase principal from a canonical origin string. This is + // the inverse operation of .origin on a codebase principal. + principalFromOrigin: function(aOriginString) { + if (aOriginString.startsWith('[')) { + throw new Error("principalFromOrigin does not support System and Expanded principals"); + } + + if (aOriginString.startsWith("moz-nullprincipal:")) { + throw new Error("principalFromOrigin does not support nsNullPrincipal"); + } + + var parts = aOriginString.split('^'); + if (parts.length > 2) { + throw new Error("bad origin string: " + aOriginString); + } + + var uri = Services.io.newURI(parts[0], null, null); + var attrs = {}; + // Parse the parameters string into a dictionary. + (parts[1] || "").split("&").map((x) => x.split('=')).forEach((x) => attrs[x[0]] = x[1]); + + return Services.scriptSecurityManager.createCodebasePrincipal(uri, attrs); + }, + /** * For a given DOM element, returns its position in "screen" * coordinates. In a content process, the coordinates returned will diff --git a/toolkit/modules/PermissionsUtils.jsm b/toolkit/modules/PermissionsUtils.jsm index 7996d86a1c7a..3f95437fb248 100644 --- a/toolkit/modules/PermissionsUtils.jsm +++ b/toolkit/modules/PermissionsUtils.jsm @@ -7,6 +7,8 @@ this.EXPORTED_SYMBOLS = ["PermissionsUtils"]; const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components; Cu.import("resource://gre/modules/Services.jsm"); +Cu.import("resource://gre/modules/BrowserUtils.jsm") + var gImportedPrefBranches = new Set(); @@ -27,7 +29,7 @@ function importPrefBranch(aPrefBranch, aPermission, aAction) { for (let origin of origins) { let principals = []; try { - principals = [ Services.scriptSecurityManager.createCodebasePrincipalFromOrigin(origin) ]; + principals = [ BrowserUtils.principalFromOrigin(origin) ]; } catch (e) { // This preference used to contain a list of hosts. For back-compat // reasons, we convert these hosts into http:// and https:// permissions