Skip to content

Commit

Permalink
Backed out 4 changesets (bug 1320404) for xperf failures on permissio…
Browse files Browse the repository at this point in the history
…ns.sqlite-journal.

Backed out changeset fbacf18b6532 (bug 1320404)
Backed out changeset fed7c475d75c (bug 1320404)
Backed out changeset 557b586f774a (bug 1320404)
Backed out changeset 5a20b5f43280 (bug 1320404)
  • Loading branch information
CosminSabou committed May 2, 2019
1 parent 6a6e672 commit a884fb9
Show file tree
Hide file tree
Showing 101 changed files with 944 additions and 538 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ add_task(async function test_realHistoryCheck() {
"output": {
"URI": false,
"originAttributes": {
"appId": 0,
"firstPartyDomain": "",
"inIsolatedMozBrowser": false,
"privateBrowsingId": 0,
Expand All @@ -127,6 +128,7 @@ add_task(async function test_realHistoryCheck() {
"cspJSON": "{\"csp-policies\":[{\"child-src\":[\"https://www.googletagmanager.com\",\"https://www.google-analytics.com\",\"https://www.youtube-nocookie.com\",\"https://trackertest.org\",\"https://www.surveygizmo.com\",\"https://accounts.firefox.com\",\"https://accounts.firefox.com.cn\",\"https://www.youtube.com\"],\"connect-src\":[\"'self'\",\"https://*.mozilla.net\",\"https://*.mozilla.org\",\"https://*.mozilla.com\",\"https://www.googletagmanager.com\",\"https://www.google-analytics.com\",\"https://accounts.firefox.com/\",\"https://accounts.firefox.com.cn/\"],\"default-src\":[\"'self'\",\"https://*.mozilla.net\",\"https://*.mozilla.org\",\"https://*.mozilla.com\"],\"frame-src\":[\"https://www.googletagmanager.com\",\"https://www.google-analytics.com\",\"https://www.youtube-nocookie.com\",\"https://trackertest.org\",\"https://www.surveygizmo.com\",\"https://accounts.firefox.com\",\"https://accounts.firefox.com.cn\",\"https://www.youtube.com\"],\"img-src\":[\"'self'\",\"https://*.mozilla.net\",\"https://*.mozilla.org\",\"https://*.mozilla.com\",\"data:\",\"https://mozilla.org\",\"https://www.googletagmanager.com\",\"https://www.google-analytics.com\",\"https://adservice.google.com\",\"https://adservice.google.de\",\"https://adservice.google.dk\",\"https://creativecommons.org\",\"https://ad.doubleclick.net\"],\"report-only\":false,\"script-src\":[\"'self'\",\"https://*.mozilla.net\",\"https://*.mozilla.org\",\"https://*.mozilla.com\",\"'unsafe-inline'\",\"'unsafe-eval'\",\"https://www.googletagmanager.com\",\"https://www.google-analytics.com\",\"https://tagmanager.google.com\",\"https://www.youtube.com\",\"https://s.ytimg.com\"],\"style-src\":[\"'self'\",\"https://*.mozilla.net\",\"https://*.mozilla.org\",\"https://*.mozilla.com\",\"'unsafe-inline'\"]}]}",
"URISpec": "https://www.mozilla.org/en-US/",
"originAttributes": {
"appId": 0,
"firstPartyDomain": "",
"inIsolatedMozBrowser": false,
"privateBrowsingId": 0,
Expand All @@ -139,6 +141,7 @@ add_task(async function test_realHistoryCheck() {
"output": {
"URISpec": "https://www.mozilla.org/en-US/firefox/accounts/",
"originAttributes": {
"appId": 0,
"firstPartyDomain": "",
"inIsolatedMozBrowser": false,
"privateBrowsingId": 0,
Expand All @@ -152,6 +155,7 @@ add_task(async function test_realHistoryCheck() {
"output": {
"URISpec": "https://developer.mozilla.org/en-US/?utm_source=www.mozilla.org&utm_medium=referral&utm_campaign=nav&utm_content=developers",
"originAttributes": {
"appId": 0,
"firstPartyDomain": "",
"inIsolatedMozBrowser": false,
"privateBrowsingId": 0,
Expand All @@ -165,6 +169,7 @@ add_task(async function test_realHistoryCheck() {
"output": {
"URI": false,
"originAttributes": {
"appId": 0,
"firstPartyDomain": "",
"inIsolatedMozBrowser": false,
"privateBrowsingId": 0,
Expand All @@ -178,6 +183,7 @@ add_task(async function test_realHistoryCheck() {
"output": {
"URISpec": "moz-nullprincipal:{045ca18d-436c-4744-bbb6-b1a15366df79}",
"originAttributes": {
"appId": 0,
"firstPartyDomain": "",
"inIsolatedMozBrowser": false,
"privateBrowsingId": 0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ const SESSION_DATA_OA = JSON.stringify(
name: "test1",
originAttributes: {
addonId: "",
appId: 0,
inIsolatedMozBrowser: false,
userContextId: 0,
},
Expand Down
12 changes: 12 additions & 0 deletions caps/BasePrincipal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,18 @@ BasePrincipal::GetOriginSuffix(nsACString& aOriginAttributes) {
return NS_OK;
}

NS_IMETHODIMP
BasePrincipal::GetAppId(uint32_t* aAppId) {
if (AppId() == nsIScriptSecurityManager::UNKNOWN_APP_ID) {
MOZ_ASSERT(false);
*aAppId = nsIScriptSecurityManager::NO_APP_ID;
return NS_OK;
}

*aAppId = AppId();
return NS_OK;
}

NS_IMETHODIMP
BasePrincipal::GetUserContextId(uint32_t* aUserContextId) {
*aUserContextId = UserContextId();
Expand Down
2 changes: 2 additions & 0 deletions caps/BasePrincipal.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ class BasePrincipal : public nsJSPrincipals {
NS_IMETHOD GetOriginAttributes(JSContext* aCx,
JS::MutableHandle<JS::Value> aVal) final;
NS_IMETHOD GetOriginSuffix(nsACString& aOriginSuffix) final;
NS_IMETHOD GetAppId(uint32_t* aAppId) final;
NS_IMETHOD GetIsInIsolatedMozBrowserElement(
bool* aIsInIsolatedMozBrowserElement) final;
NS_IMETHOD GetUserContextId(uint32_t* aUserContextId) final;
Expand Down Expand Up @@ -153,6 +154,7 @@ class BasePrincipal : public nsJSPrincipals {
const OriginAttributes& OriginAttributesRef() final {
return mOriginAttributes;
}
uint32_t AppId() const { return mOriginAttributes.mAppId; }
extensions::WebExtensionPolicy* AddonPolicy();
uint32_t UserContextId() const { return mOriginAttributes.mUserContextId; }
uint32_t PrivateBrowsingId() const {
Expand Down
17 changes: 16 additions & 1 deletion caps/OriginAttributes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,11 @@ void OriginAttributes::CreateSuffix(nsACString& aStr) const {
// naming.
//

if (mAppId != nsIScriptSecurityManager::NO_APP_ID) {
value.AppendInt(mAppId);
params.Set(NS_LITERAL_STRING("appId"), value);
}

if (mInIsolatedMozBrowser) {
params.Set(NS_LITERAL_STRING("inBrowser"), NS_LITERAL_STRING("1"));
}
Expand Down Expand Up @@ -202,6 +207,16 @@ class MOZ_STACK_CLASS PopulateFromSuffixIterator final

bool URLParamsIterator(const nsAString& aName,
const nsAString& aValue) override {
if (aName.EqualsLiteral("appId")) {
nsresult rv;
int64_t val = aValue.ToInteger64(&rv);
NS_ENSURE_SUCCESS(rv, false);
NS_ENSURE_TRUE(val <= UINT32_MAX, false);
mOriginAttributes->mAppId = static_cast<uint32_t>(val);

return true;
}

if (aName.EqualsLiteral("inBrowser")) {
if (!aValue.EqualsLiteral("1")) {
return false;
Expand All @@ -211,7 +226,7 @@ class MOZ_STACK_CLASS PopulateFromSuffixIterator final
return true;
}

if (aName.EqualsLiteral("addonId") || aName.EqualsLiteral("appId")) {
if (aName.EqualsLiteral("addonId")) {
// No longer supported. Silently ignore so that legacy origin strings
// don't cause failures.
return true;
Expand Down
18 changes: 15 additions & 3 deletions caps/OriginAttributes.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ class OriginAttributes : public dom::OriginAttributesDictionary {
public:
OriginAttributes() {}

explicit OriginAttributes(bool aInIsolatedMozBrowser) {
OriginAttributes(uint32_t aAppId, bool aInIsolatedMozBrowser) {
mAppId = aAppId;
mInIsolatedMozBrowser = aInIsolatedMozBrowser;
}

Expand Down Expand Up @@ -45,7 +46,8 @@ class OriginAttributes : public dom::OriginAttributesDictionary {
}

bool operator==(const OriginAttributes& aOther) const {
return mInIsolatedMozBrowser == aOther.mInIsolatedMozBrowser &&
return mAppId == aOther.mAppId &&
mInIsolatedMozBrowser == aOther.mInIsolatedMozBrowser &&
mUserContextId == aOther.mUserContextId &&
mPrivateBrowsingId == aOther.mPrivateBrowsingId &&
mFirstPartyDomain == aOther.mFirstPartyDomain;
Expand All @@ -56,7 +58,8 @@ class OriginAttributes : public dom::OriginAttributesDictionary {
}

MOZ_MUST_USE bool EqualsIgnoringFPD(const OriginAttributes& aOther) const {
return mInIsolatedMozBrowser == aOther.mInIsolatedMozBrowser &&
return mAppId == aOther.mAppId &&
mInIsolatedMozBrowser == aOther.mInIsolatedMozBrowser &&
mUserContextId == aOther.mUserContextId &&
mPrivateBrowsingId == aOther.mPrivateBrowsingId;
}
Expand Down Expand Up @@ -126,6 +129,10 @@ class OriginAttributesPattern : public dom::OriginAttributesPatternDictionary {

// Performs a match of |aAttrs| against this pattern.
bool Matches(const OriginAttributes& aAttrs) const {
if (mAppId.WasPassed() && mAppId.Value() != aAttrs.mAppId) {
return false;
}

if (mInIsolatedMozBrowser.WasPassed() &&
mInIsolatedMozBrowser.Value() != aAttrs.mInIsolatedMozBrowser) {
return false;
Expand All @@ -150,6 +157,11 @@ class OriginAttributesPattern : public dom::OriginAttributesPatternDictionary {
}

bool Overlaps(const OriginAttributesPattern& aOther) const {
if (mAppId.WasPassed() && aOther.mAppId.WasPassed() &&
mAppId.Value() != aOther.mAppId.Value()) {
return false;
}

if (mInIsolatedMozBrowser.WasPassed() &&
aOther.mInIsolatedMozBrowser.WasPassed() &&
mInIsolatedMozBrowser.Value() != aOther.mInIsolatedMozBrowser.Value()) {
Expand Down
18 changes: 18 additions & 0 deletions caps/nsIPrincipal.idl
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,24 @@ interface nsIPrincipal : nsISerializable
*/
readonly attribute ACString baseDomain;

/**
* Gets the id of the app this principal is inside. If this principal is
* not inside an app, returns nsIScriptSecurityManager::NO_APP_ID.
*
* Note that this principal does not necessarily have the permissions of
* the app identified by appId. For example, this principal might
* correspond to an iframe whose origin differs from that of the app frame
* containing it. In this case, the iframe will have the appId of its
* containing app frame, but the iframe must not run with the app's
* permissions.
*
* Similarly, this principal might correspond to an <iframe mozbrowser>
* inside an app frame; in this case, the content inside the iframe should
* not have any of the app's permissions, even if the iframe is at the same
* origin as the app.
*/
[infallible] readonly attribute unsigned long appId;

/**
* Gets the ID of the add-on this principal belongs to.
*/
Expand Down
3 changes: 3 additions & 0 deletions caps/nsIScriptSecurityManager.idl
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,9 @@ interface nsIScriptSecurityManager : nsISupports
*/
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;

/**
Expand Down
10 changes: 8 additions & 2 deletions caps/tests/gtest/TestOriginAttributes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,15 @@ TEST(OriginAttributes, Suffix_default)
TestSuffix(attrs);
}

TEST(OriginAttributes, Suffix_inIsolatedMozBrowser)
TEST(OriginAttributes, Suffix_appId_inIsolatedMozBrowser)
{
OriginAttributes attrs(true);
OriginAttributes attrs(1, true);
TestSuffix(attrs);
}

TEST(OriginAttributes, Suffix_maxAppId_inIsolatedMozBrowser)
{
OriginAttributes attrs(4294967295, true);
TestSuffix(attrs);
}

Expand Down
Loading

0 comments on commit a884fb9

Please sign in to comment.