Backed out 5 changesets (bug 1180921) for build failures in BasePrincipal.cpp

Backed out changeset d8c1a2e11a9a (bug 1180921)
Backed out changeset f4dd8c53df5f (bug 1180921)
Backed out changeset b272a0ebf5d8 (bug 1180921)
Backed out changeset 8e86b6a7d201 (bug 1180921)
Backed out changeset bbdebd7b8881 (bug 1180921)
This commit is contained in:
Wes Kocher 2015-07-09 17:43:08 -07:00
Родитель c9102e3238
Коммит 45be9b06a3
22 изменённых файлов: 60 добавлений и 286 удалений

Просмотреть файл

@ -436,8 +436,7 @@
@RESPATH@/components/addoncompat.manifest
@RESPATH@/components/multiprocessShims.js
@RESPATH@/components/defaultShims.js
@RESPATH@/components/utils.manifest
@RESPATH@/components/simpleServices.js
@RESPATH@/components/remoteTagService.js
@RESPATH@/components/pluginGlue.manifest
@RESPATH@/components/ProcessSingleton.manifest
@RESPATH@/components/MainProcessSingleton.js

Просмотреть файл

@ -6,7 +6,6 @@
#include "mozilla/BasePrincipal.h"
#include "nsIAddonPolicyService.h"
#include "nsIContentSecurityPolicy.h"
#include "nsIObjectInputStream.h"
#include "nsIObjectOutputStream.h"
@ -42,10 +41,6 @@ OriginAttributes::CreateSuffix(nsACString& aStr) const
params->Set(NS_LITERAL_STRING("inBrowser"), NS_LITERAL_STRING("1"));
}
if (!mAddonId.IsEmpty()) {
params->Set(NS_LITERAL_STRING("addonId"), mAddonId);
}
aStr.Truncate();
params->Serialize(value);
@ -93,12 +88,6 @@ public:
return true;
}
if (aName.EqualsLiteral("addonId")) {
MOZ_RELEASE_ASSERT(mOriginAttributes->mAddonId.IsEmpty());
mOriginAttributes->mAddonId.Assign(aValue);
return true;
}
// No other attributes are supported.
return false;
}
@ -357,19 +346,4 @@ BasePrincipal::CreateCodebasePrincipal(nsIURI* aURI, OriginAttributes& aAttrs)
return codebase.forget();
}
bool
BasePrincipal::AddonAllowsLoad(nsIURI* aURI)
{
if (mOriginAttributes.mAddonId.IsEmpty()) {
return false;
}
nsCOMPtr<nsIAddonPolicyService> aps = do_GetService("@mozilla.org/addons/policy-service;1");
NS_ENSURE_TRUE(aps, false);
bool allowed = false;
nsresult rv = aps->AddonMayLoadURI(mOriginAttributes.mAddonId, aURI, &allowed);
return NS_SUCCEEDED(rv) && allowed;
}
} // namespace mozilla

Просмотреть файл

@ -34,8 +34,7 @@ public:
bool operator==(const OriginAttributes& aOther) const
{
return mAppId == aOther.mAppId &&
mInBrowser == aOther.mInBrowser &&
mAddonId == aOther.mAddonId;
mInBrowser == aOther.mInBrowser;
}
bool operator!=(const OriginAttributes& aOther) const
{
@ -107,10 +106,6 @@ protected:
virtual nsresult GetOriginInternal(nsACString& aOrigin) = 0;
virtual bool SubsumesInternal(nsIPrincipal* aOther, DocumentDomainConsideration aConsider) = 0;
// Helper to check whether this principal is associated with an addon that
// allows unprivileged code to load aURI.
bool AddonAllowsLoad(nsIURI* aURI);
nsCOMPtr<nsIContentSecurityPolicy> mCSP;
OriginAttributes mOriginAttributes;
};

Просмотреть файл

@ -9,7 +9,6 @@ MOCHITEST_CHROME_MANIFESTS += ['tests/mochitest/chrome.ini']
XPCSHELL_TESTS_MANIFESTS += ['tests/unit/xpcshell.ini']
XPIDL_SOURCES += [
'nsIAddonPolicyService.idl',
'nsIDomainPolicy.idl',
'nsIPrincipal.idl',
'nsIScriptSecurityManager.idl',

Просмотреть файл

@ -1,22 +0,0 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
*
* 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"
#include "nsIURI.idl"
/**
* This interface allows the security manager to query custom per-addon security
* policy.
*/
[scriptable,uuid(fedf126c-988e-42df-82c9-f2ac99cd65f3)]
interface nsIAddonPolicyService : nsISupports
{
/**
* Returns true if unprivileged code associated with the given addon may load
* data from |aURI|.
*/
boolean addonMayLoadURI(in AString aAddonId, in nsIURI aURI);
};

Просмотреть файл

@ -23,8 +23,8 @@
class nsIURI;
#define NS_NULLPRINCIPAL_CID \
{ 0x34a19ab6, 0xca47, 0x4098, \
{ 0xa7, 0xb8, 0x4a, 0xfc, 0xdd, 0xcd, 0x8f, 0x88 } }
{ 0xe502ffb8, 0x5d95, 0x48e8, \
{ 0x82, 0x3c, 0x0d, 0x29, 0xd8, 0x3a, 0x59, 0x33 } }
#define NS_NULLPRINCIPAL_CONTRACTID "@mozilla.org/nullprincipal;1"
#define NS_NULLPRINCIPAL_SCHEME "moz-nullprincipal"

Просмотреть файл

@ -236,12 +236,6 @@ nsPrincipal::CheckMayLoad(nsIURI* aURI, bool aReport, bool aAllowIfInheritsPrinc
return NS_OK;
}
// If this principal is associated with an addon, check whether that addon
// has been given permission to load from this domain.
if (AddonAllowsLoad(aURI)) {
return NS_OK;
}
if (nsScriptSecurityManager::SecurityCompareURIs(mCodebase, aURI)) {
return NS_OK;
}

Просмотреть файл

@ -112,12 +112,12 @@ private:
#define NS_PRINCIPAL_CONTRACTID "@mozilla.org/principal;1"
#define NS_PRINCIPAL_CID \
{ 0xb02c3023, 0x5b37, 0x472a, \
{ 0xa2, 0xcd, 0x35, 0xaa, 0x5e, 0xe2, 0xa8, 0x19 } }
{ 0xb7c8505e, 0xc56d, 0x4191, \
{ 0xa1, 0x5e, 0x5d, 0xcb, 0x88, 0x9b, 0xa0, 0x94 }}
#define NS_EXPANDEDPRINCIPAL_CONTRACTID "@mozilla.org/expandedprincipal;1"
#define NS_EXPANDEDPRINCIPAL_CID \
{ 0xe8ee88b0, 0x5571, 0x4086, \
{ 0xa4, 0x5b, 0x39, 0xa7, 0x16, 0x90, 0x6b, 0xdb } }
{ 0x38539471, 0x68cc, 0x4a6f, \
{ 0x81, 0x20, 0xdb, 0xd5, 0x4a, 0x22, 0x0a, 0x13 }}
#endif // nsPrincipal_h__

Просмотреть файл

@ -4,7 +4,6 @@ support-files =
file_disableScript.html
[test_bug995943.xul]
[test_addonMayLoad.html]
[test_disableScript.xul]
[test_principal_jarprefix_origin_appid_appstatus.html]
# jarPrefix test doesn't work on Windows, see bug 776296.

Просмотреть файл

@ -1 +0,0 @@
server data fetched over XHR

Просмотреть файл

@ -1,6 +1,5 @@
[DEFAULT]
support-files =
file_data.txt
file_disableScript.html
[test_app_principal_equality.html]

Просмотреть файл

@ -1,97 +0,0 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=1180921
-->
<head>
<meta charset="utf-8">
<title>Test for Bug 1180921</title>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://global/skin"/>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/>
<script type="application/javascript;version=1.8">
/** Test for Bug 1180921 **/
const Cc = Components.classes;
const Ci = Components.interfaces;
const Cu = Components.utils;
Cu.import("resource://gre/modules/Services.jsm");
let ssm = Services.scriptSecurityManager;
let aps = Cc["@mozilla.org/addons/policy-service;1"].getService(Ci.nsIAddonPolicyService).wrappedJSObject;
SimpleTest.waitForExplicitFinish();
SimpleTest.registerCleanupFunction(function() {
aps.setAddonLoadURICallback('addonA', null);
aps.setAddonLoadURICallback('addonB', null);
});
function tryLoad(sb, uri) {
let p = new Promise(function(resolve, reject) {
Cu.exportFunction(resolve, sb, { defineAs: "finish" });
Cu.exportFunction(reject, sb, { defineAs: "error" });
sb.eval("try { (function () { " +
" var xhr = new XMLHttpRequest();" +
" xhr.onreadystatechange = function() { if (xhr.readyState == XMLHttpRequest.DONE) { finish(xhr.status == 200); } };" +
" xhr.open('GET', '" + uri + "', true);" +
" xhr.send();" +
"})() } catch (e) { error(e); }");
});
return p;
}
let exampleCom_addonA = new Cu.Sandbox(ssm.createCodebasePrincipal(Services.io.newURI('http://example.com', null, null), {addonId: 'addonA'}),
{wantGlobalProperties: ['XMLHttpRequest']});
let nullPrin_addonA = new Cu.Sandbox(ssm.createNullPrincipal({addonId: 'addonA'}),
{wantGlobalProperties: ['XMLHttpRequest']});
let exampleCom_addonB = new Cu.Sandbox(ssm.createCodebasePrincipal(Services.io.newURI('http://example.com', null, null), {addonId: 'addonB'}),
{wantGlobalProperties: ['XMLHttpRequest']});
function uriForDomain(d) { return d + '/tests/caps/tests/mochitest/file_data.txt' }
tryLoad(exampleCom_addonA, uriForDomain('http://example.com'))
.then(function(success) {
ok(success, "same-origin load should succeed for addon A");
return tryLoad(nullPrin_addonA, uriForDomain('http://example.com'));
}).then(function(success) {
ok(!success, "null-principal load should fail for addon A");
return tryLoad(exampleCom_addonB, uriForDomain('http://example.com'));
}).then(function(success) {
ok(success, "same-origin load should succeed for addon B");
return tryLoad(exampleCom_addonA, uriForDomain('http://test1.example.org'));
}).then(function(success) {
ok(!success, "cross-origin load should fail for addon A");
aps.setAddonLoadURICallback('addonA', function(uri) { return /test1/.test(uri.host); });
aps.setAddonLoadURICallback('addonB', function(uri) { return /test2/.test(uri.host); });
return tryLoad(exampleCom_addonA, uriForDomain('http://test1.example.org'));
}).then(function(success) {
ok(success, "whitelisted cross-origin load of test1 should succeed for addon A");
return tryLoad(nullPrin_addonA, uriForDomain('http://test1.example.org'));
}).then(function(success) {
ok(!success, "whitelisted null principal load of test1 should still fail for addon A");
return tryLoad(exampleCom_addonB, uriForDomain('http://test1.example.org'));
}).then(function(success) {
ok(!success, "non-whitelisted cross-origin load of test1 should fail for addon B");
return tryLoad(exampleCom_addonB, uriForDomain('http://test2.example.org'));
}).then(function(success) {
ok(success, "whitelisted cross-origin load of test2 should succeed for addon B");
return tryLoad(exampleCom_addonA, uriForDomain('http://test2.example.org'));
}).then(function(success) {
ok(!success, "non-whitelisted cross-origin load of test2 should fail for addon A");
SimpleTest.finish();
}, function(e) {
ok(false, "Rejected promise chain: " + e);
SimpleTest.finish();
});
</script>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1180921">Mozilla Bug 1180921</a>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">
</pre>
</body>
</html>

Просмотреть файл

@ -25,10 +25,9 @@ function checkCrossOrigin(a, b) {
a.originAttributes.inBrowser == b.originAttributes.inBrowser);
}
function checkOriginAttributes(prin, attrs, suffix) {
attrs = attrs || {};
do_check_eq(prin.originAttributes.appId, attrs.appId || 0);
do_check_eq(prin.originAttributes.inBrowser, attrs.inBrowser || false);
function checkOriginAttributes(prin, appId, inBrowser, suffix) {
do_check_eq(prin.originAttributes.appId, appId || 0);
do_check_eq(prin.originAttributes.inBrowser, inBrowser || false);
do_check_eq(prin.originSuffix, suffix || '');
if (!prin.isNullPrincipal && !prin.origin.startsWith('[')) {
do_check_true(BrowserUtils.principalFromOrigin(prin.origin).equals(prin));
@ -68,34 +67,29 @@ function run_test() {
// Just app.
var exampleOrg_app = ssm.createCodebasePrincipal(makeURI('http://example.org'), {appId: 42});
var nullPrin_app = ssm.createNullPrincipal({appId: 42});
checkOriginAttributes(exampleOrg_app, {appId: 42}, '!appId=42');
checkOriginAttributes(nullPrin_app, {appId: 42}, '!appId=42');
checkOriginAttributes(exampleOrg_app, 42, false, '!appId=42');
checkOriginAttributes(nullPrin_app, 42, false, '!appId=42');
do_check_eq(exampleOrg_app.origin, 'http://example.org!appId=42');
// Just browser.
var exampleOrg_browser = ssm.createCodebasePrincipal(makeURI('http://example.org'), {inBrowser: true});
var nullPrin_browser = ssm.createNullPrincipal({inBrowser: true});
checkOriginAttributes(exampleOrg_browser, {inBrowser: true}, '!inBrowser=1');
checkOriginAttributes(nullPrin_browser, {inBrowser: true}, '!inBrowser=1');
checkOriginAttributes(exampleOrg_browser, 0, true, '!inBrowser=1');
checkOriginAttributes(nullPrin_browser, 0, true, '!inBrowser=1');
do_check_eq(exampleOrg_browser.origin, 'http://example.org!inBrowser=1');
// App and browser.
var exampleOrg_appBrowser = ssm.createCodebasePrincipal(makeURI('http://example.org'), {inBrowser: true, appId: 42});
var nullPrin_appBrowser = ssm.createNullPrincipal({inBrowser: true, appId: 42});
checkOriginAttributes(exampleOrg_appBrowser, {appId: 42, inBrowser: true}, '!appId=42&inBrowser=1');
checkOriginAttributes(nullPrin_appBrowser, {appId: 42, inBrowser: true}, '!appId=42&inBrowser=1');
checkOriginAttributes(exampleOrg_appBrowser, 42, true, '!appId=42&inBrowser=1');
checkOriginAttributes(nullPrin_appBrowser, 42, true, '!appId=42&inBrowser=1');
do_check_eq(exampleOrg_appBrowser.origin, 'http://example.org!appId=42&inBrowser=1');
// App and browser, different domain.
var exampleCom_appBrowser = ssm.createCodebasePrincipal(makeURI('https://www.example.com:123'), {appId: 42, inBrowser: true});
checkOriginAttributes(exampleCom_appBrowser, {appId: 42, inBrowser: true}, '!appId=42&inBrowser=1');
checkOriginAttributes(exampleCom_appBrowser, 42, true, '!appId=42&inBrowser=1');
do_check_eq(exampleCom_appBrowser.origin, 'https://www.example.com:123!appId=42&inBrowser=1');
// Addon.
var exampleOrg_addon = ssm.createCodebasePrincipal(makeURI('http://example.org'), {addonId: 'dummy'});
checkOriginAttributes(exampleOrg_addon, { addonId: "dummy" }, '!addonId=dummy');
do_check_eq(exampleOrg_addon.origin, 'http://example.org!addonId=dummy');
// Check that all of the above are cross-origin.
checkCrossOrigin(exampleOrg_app, exampleOrg);
checkCrossOrigin(exampleOrg_app, nullPrin_app);
@ -104,5 +98,4 @@ function run_test() {
checkCrossOrigin(exampleOrg_appBrowser, exampleOrg_app);
checkCrossOrigin(exampleOrg_appBrowser, nullPrin_appBrowser);
checkCrossOrigin(exampleOrg_appBrowser, exampleCom_appBrowser);
checkCrossOrigin(exampleOrg_addon, exampleOrg);
}

Просмотреть файл

@ -119,11 +119,6 @@ public:
mImpl.emplace(aValue);
}
bool operator==(const Optional_base<T, InternalType>& aOther) const
{
return mImpl == aOther.mImpl;
}
template<typename T1, typename T2>
explicit Optional_base(const T1& aValue1, const T2& aValue2)
{

Просмотреть файл

@ -40,5 +40,4 @@ interface ChromeUtils : ThreadSafeChromeUtils {
dictionary OriginAttributesDictionary {
unsigned long appId = 0;
boolean inBrowser = false;
DOMString addonId = "";
};

Просмотреть файл

@ -2,3 +2,5 @@ component {1363d5f0-d95e-11e3-9c1a-0800200c9a66} multiprocessShims.js
contract @mozilla.org/addons/multiprocess-shims;1 {1363d5f0-d95e-11e3-9c1a-0800200c9a66}
component {50bc93ce-602a-4bef-bf3a-61fc749c4caf} defaultShims.js
contract @mozilla.org/addons/default-addon-shims;1 {50bc93ce-602a-4bef-bf3a-61fc749c4caf}
component {dfd07380-6083-11e4-9803-0800200c9a66} remoteTagService.js
contract @mozilla.org/addons/remote-tag-service;1 {dfd07380-6083-11e4-9803-0800200c9a66}

Просмотреть файл

@ -10,6 +10,7 @@ EXTRA_COMPONENTS += [
'addoncompat.manifest',
'defaultShims.js',
'multiprocessShims.js',
'remoteTagService.js',
]
EXTRA_JS_MODULES += [

Просмотреть файл

@ -0,0 +1,39 @@
/* 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/. */
"use strict";
const Cu = Components.utils;
const Ci = Components.interfaces;
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
function RemoteTagServiceService()
{
}
RemoteTagServiceService.prototype = {
classID: Components.ID("{dfd07380-6083-11e4-9803-0800200c9a66}"),
QueryInterface: XPCOMUtils.generateQI([Ci.nsIRemoteTagService, Ci.nsISupportsWeakReference]),
/**
* CPOWs can have user data attached to them. This data originates
* in the local process from this function, getRemoteObjectTag. It's
* sent along with the CPOW to the remote process, where it can be
* fetched with Components.utils.getCrossProcessWrapperTag.
*/
getRemoteObjectTag: function(target) {
if (target instanceof Ci.nsIDocShellTreeItem) {
return "ContentDocShellTreeItem";
}
if (target instanceof Ci.nsIDOMDocument) {
return "ContentDocument";
}
return "generic";
}
};
this.NSGetFactory = XPCOMUtils.generateNSGetFactory([RemoteTagServiceService]);

Просмотреть файл

@ -50,7 +50,6 @@ DIRS += [
'thumbnails',
'timermanager',
'typeaheadfind',
'utils',
'urlformatter',
'viewconfig',
'workerloader',

Просмотреть файл

@ -1,10 +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/.
EXTRA_COMPONENTS += [
'simpleServices.js',
'utils.manifest',
]

Просмотреть файл

@ -1,79 +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/. */
/*
* Dumping ground for simple services for which the isolation of a full global
* is overkill. Be careful about namespace pollution, and be mindful about
* importing lots of JSMs in global scope, since this file will almost certainly
* be loaded from enough callsites that any such imports will always end up getting
* eagerly loaded at startup.
*/
"use strict";
const Cu = Components.utils;
const Ci = Components.interfaces;
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
function RemoteTagServiceService()
{
}
RemoteTagServiceService.prototype = {
classID: Components.ID("{dfd07380-6083-11e4-9803-0800200c9a66}"),
QueryInterface: XPCOMUtils.generateQI([Ci.nsIRemoteTagService, Ci.nsISupportsWeakReference]),
/**
* CPOWs can have user data attached to them. This data originates
* in the local process from this function, getRemoteObjectTag. It's
* sent along with the CPOW to the remote process, where it can be
* fetched with Components.utils.getCrossProcessWrapperTag.
*/
getRemoteObjectTag: function(target) {
if (target instanceof Ci.nsIDocShellTreeItem) {
return "ContentDocShellTreeItem";
}
if (target instanceof Ci.nsIDOMDocument) {
return "ContentDocument";
}
return "generic";
}
};
function AddonPolicyService()
{
this.wrappedJSObject = this;
this.mayLoadURICallbacks = new Map();
}
AddonPolicyService.prototype = {
classID: Components.ID("{89560ed3-72e3-498d-a0e8-ffe50334d7c5}"),
QueryInterface: XPCOMUtils.generateQI([Ci.nsIAddonPolicyService]),
/*
* Invokes a callback (if any) associated with the addon to determine whether
* unprivileged code running within the addon is allowed to perform loads from
* the given URI.
*
* @see nsIAddonPolicyService.addonMayLoadURI
*/
addonMayLoadURI(aAddonId, aURI) {
let cb = this.mayLoadURICallbacks[aAddonId];
return cb ? cb(aURI) : false;
},
/*
* Sets the callbacks used in addonMayLoadURI above. Not accessible over
* XPCOM - callers should use .wrappedJSObject on the service to call it
* directly.
*/
setAddonLoadURICallback(aAddonId, aCallback) {
this.mayLoadURICallbacks[aAddonId] = aCallback;
},
};
this.NSGetFactory = XPCOMUtils.generateNSGetFactory([RemoteTagServiceService, AddonPolicyService]);

Просмотреть файл

@ -1,4 +0,0 @@
component {dfd07380-6083-11e4-9803-0800200c9a66} simpleServices.js
contract @mozilla.org/addons/remote-tag-service;1 {dfd07380-6083-11e4-9803-0800200c9a66}
component {89560ed3-72e3-498d-a0e8-ffe50334d7c5} simpleServices.js
contract @mozilla.org/addons/policy-service;1 {89560ed3-72e3-498d-a0e8-ffe50334d7c5}