зеркало из https://github.com/mozilla/gecko-dev.git
Backed out 1 changesets (bug 1178533) for s4 testfailures
Backed out changeset 8bbdb80f67e0 (bug 1178533) --HG-- extra : rebase_source : 040491f382ad7b03ba803686601f1272416ab47d
This commit is contained in:
Родитель
f2519a89ab
Коммит
58878018ac
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -403,28 +403,6 @@ BasePrincipal::CreateCodebasePrincipal(nsIURI* aURI, OriginAttributes& aAttrs)
|
|||
return codebase.forget();
|
||||
}
|
||||
|
||||
already_AddRefed<BasePrincipal>
|
||||
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<nsIURI> uri;
|
||||
nsresult rv = NS_NewURI(getter_AddRefs(uri), originNoSuffix);
|
||||
NS_ENSURE_SUCCESS(rv, nullptr);
|
||||
|
||||
return BasePrincipal::CreateCodebasePrincipal(uri, attrs);
|
||||
}
|
||||
|
||||
bool
|
||||
BasePrincipal::AddonAllowsLoad(nsIURI* aURI)
|
||||
{
|
||||
|
|
|
@ -137,7 +137,6 @@ public:
|
|||
|
||||
static BasePrincipal* Cast(nsIPrincipal* aPrin) { return static_cast<BasePrincipal*>(aPrin); }
|
||||
static already_AddRefed<BasePrincipal> CreateCodebasePrincipal(nsIURI* aURI, OriginAttributes& aAttrs);
|
||||
static already_AddRefed<BasePrincipal> CreateCodebasePrincipal(const nsACString& aOrigin);
|
||||
|
||||
const OriginAttributes& OriginAttributesRef() { return mOriginAttributes; }
|
||||
uint32_t AppId() const { return mOriginAttributes.mAppId; }
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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<JS::Va
|
|||
return *aPrincipal ? NS_OK : NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsScriptSecurityManager::CreateCodebasePrincipalFromOrigin(const nsACString& aOrigin,
|
||||
nsIPrincipal** aPrincipal)
|
||||
{
|
||||
if (StringBeginsWith(aOrigin, NS_LITERAL_CSTRING("["))) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
if (StringBeginsWith(aOrigin, NS_LITERAL_CSTRING(NS_NULLPRINCIPAL_SCHEME ":"))) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIPrincipal> prin = BasePrincipal::CreateCodebasePrincipal(aOrigin);
|
||||
prin.forget(aPrincipal);
|
||||
return *aPrincipal ? NS_OK : NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsScriptSecurityManager::CreateNullPrincipal(JS::Handle<JS::Value> aOriginAttributes,
|
||||
JSContext* aCx, nsIPrincipal** aPrincipal)
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
});
|
||||
}
|
||||
};
|
||||
|
|
|
@ -113,7 +113,6 @@ DIRS += [
|
|||
'resourcestats',
|
||||
'manifest',
|
||||
'vr',
|
||||
'newapps',
|
||||
]
|
||||
|
||||
if CONFIG['OS_ARCH'] == 'WINNT':
|
||||
|
|
|
@ -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]);
|
|
@ -1,2 +0,0 @@
|
|||
component {5cc6554a-5421-4a5e-b8c2-c62e8b7f4f3f} InstallPackagedWebapp.js
|
||||
contract @mozilla.org/newapps/installpackagedwebapp;1 {5cc6554a-5421-4a5e-b8c2-c62e8b7f4f3f}
|
|
@ -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'
|
|
@ -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);
|
||||
};
|
|
@ -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']
|
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -1,5 +0,0 @@
|
|||
[DEFAULT]
|
||||
head =
|
||||
tail =
|
||||
|
||||
[test_install.js]
|
|
@ -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);
|
||||
},
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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<nsIInputStream> 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<nsIInstallPackagedWebapp> 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;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Загрузка…
Ссылка в новой задаче