Skip to content

Commit

Permalink
Backed out 12 changesets (bug 806127, bug 802366, bug 806168) for Win…
Browse files Browse the repository at this point in the history
…dows build bustage.

--HG--
rename : dom/indexedDB/test/webapp_clearBrowserData.js => dom/indexedDB/test/test_webapp_clearBrowserData.html
  • Loading branch information
rvandermeulen committed Nov 10, 2012
1 parent 76ee0cb commit 3eff16d
Show file tree
Hide file tree
Showing 52 changed files with 748 additions and 1,483 deletions.
98 changes: 55 additions & 43 deletions caps/idl/nsIPrincipal.idl
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ interface nsIContentSecurityPolicy;
[ptr] native JSPrincipals(JSPrincipals);
[ptr] native PrincipalArray(nsTArray<nsCOMPtr<nsIPrincipal> >);

[scriptable, builtinclass, uuid(011966C0-8564-438D-B37A-08D7E1195E5A)]
[scriptable, uuid(3a283dc9-f733-4618-a36f-e2b68c280ab7)]
interface nsIPrincipal : nsISerializable
{
/**
Expand Down Expand Up @@ -159,66 +159,78 @@ interface nsIPrincipal : nsISerializable
const short APP_STATUS_CERTIFIED = 3;

/**
* Gets the principal's app status, which indicates whether the principal
* corresponds to "app code", and if it does, how privileged that code is.
* This method returns one of the APP_STATUS constants above.
*
* Note that a principal may have
*
* appId != nsIScriptSecurityManager::NO_APP_ID &&
* appId != nsIScriptSecurityManager::UNKNOWN_APP_ID
*
* and still have appStatus == APP_STATUS_NOT_INSTALLED. That's because
* appId identifies the app that contains this principal, but a window
* might be contained in an app and not be running code that the app has
* vouched for. For example, the window might be inside an <iframe
* mozbrowser>, or the window's origin might not match the app's origin.
*
* If you're doing a check to determine "does this principal correspond to
* app code?", you must check appStatus; checking appId != NO_APP_ID is not
* sufficient.
* Shows the status of the app.
* Can be: APP_STATUS_NOT_INSTALLED, APP_STATUS_INSTALLED,
* APP_STATUS_PRIVILEGED or APP_STATUS_CERTIFIED.
*/
[infallible] readonly attribute unsigned short appStatus;
readonly attribute unsigned short appStatus;

%{C++
uint16_t GetAppStatus()
{
uint16_t appStatus;
nsresult rv = GetAppStatus(&appStatus);
if (NS_FAILED(rv)) {
return APP_STATUS_NOT_INSTALLED;
}
return appStatus;
}
%}

/**
* 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.
*
* If you're doing a security check based on appId, you must check
* appStatus as well.
* Returns the app id the principal is in, or returns
* nsIScriptSecurityManager::NO_APP_ID if this principal isn't part of an
* app.
*/
[infallible] readonly attribute unsigned long appId;
readonly attribute unsigned long appId;

%{C++
uint32_t GetAppId()
{
uint32_t appId;
mozilla::DebugOnly<nsresult> rv = GetAppId(&appId);
MOZ_ASSERT(NS_SUCCEEDED(rv));
return appId;
}
%}

/**
* Returns true iff the principal is inside a browser element. (<iframe
* mozbrowser mozapp> does not count as a browser element.)
* Returns true iif the principal is inside a browser element.
*/
[infallible] readonly attribute boolean isInBrowserElement;
readonly attribute boolean isInBrowserElement;

%{C++
bool GetIsInBrowserElement()
{
bool isInBrowserElement;
mozilla::DebugOnly<nsresult> rv = GetIsInBrowserElement(&isInBrowserElement);
MOZ_ASSERT(NS_SUCCEEDED(rv));
return isInBrowserElement;
}
%}

/**
* Returns true if this principal has an unknown appId. This shouldn't
* generally be used. We only expose it due to not providing the correct
* appId everywhere where we construct principals.
*/
[infallible] readonly attribute boolean unknownAppId;
readonly attribute boolean unknownAppId;

%{C++
bool GetUnknownAppId()
{
bool unkwnownAppId;
mozilla::DebugOnly<nsresult> rv = GetUnknownAppId(&unkwnownAppId);
MOZ_ASSERT(NS_SUCCEEDED(rv));
return unkwnownAppId;
}
%}

/**
* Returns true iff this principal is a null principal (corresponding to an
* unknown, hence assumed minimally privileged, security context).
*/
[infallible] readonly attribute boolean isNullPrincipal;
readonly attribute boolean isNullPrincipal;
};

/**
Expand Down
21 changes: 15 additions & 6 deletions caps/src/nsScriptSecurityManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -335,15 +335,19 @@ nsScriptSecurityManager::GetChannelPrincipal(nsIChannel* aChannel,
nsresult rv = NS_GetFinalChannelURI(aChannel, getter_AddRefs(uri));
NS_ENSURE_SUCCESS(rv, rv);

uint32_t appId = UNKNOWN_APP_ID;
bool isInBrowserElement = false;

nsCOMPtr<nsIDocShell> docShell;
NS_QueryNotificationCallbacks(aChannel, docShell);

if (docShell) {
return GetDocShellCodebasePrincipal(uri, docShell, aPrincipal);
docShell->GetAppId(&appId);
docShell->GetIsInBrowserElement(&isInBrowserElement);
}

return GetCodebasePrincipalInternal(uri, UNKNOWN_APP_ID,
/* isInBrowserElement */ false, aPrincipal);
return GetCodebasePrincipalInternal(uri, appId, isInBrowserElement,
aPrincipal);
}

NS_IMETHODIMP
Expand Down Expand Up @@ -1899,9 +1903,14 @@ nsScriptSecurityManager::GetDocShellCodebasePrincipal(nsIURI* aURI,
nsIDocShell* aDocShell,
nsIPrincipal** aPrincipal)
{
return GetCodebasePrincipalInternal(aURI,
aDocShell->GetAppId(),
aDocShell->GetIsInBrowserElement(),
MOZ_ASSERT(aDocShell);

uint32_t appId;
bool isInBrowserElement;
aDocShell->GetAppId(&appId);
aDocShell->GetIsInBrowserElement(&isInBrowserElement);

return GetCodebasePrincipalInternal(aURI, appId, isInBrowserElement,
aPrincipal);
}

Expand Down
8 changes: 2 additions & 6 deletions content/base/src/ThirdPartyUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,7 @@ ThirdPartyUtil::IsThirdPartyWindow(nsIDOMWindow* aWindow,
nsCOMPtr<nsIDOMWindow> current = aWindow, parent;
nsCOMPtr<nsIURI> parentURI;
do {
// We use GetScriptableParent rather than GetParent because we consider
// <iframe mozbrowser/mozapp> to be a top-level frame.
rv = current->GetScriptableParent(getter_AddRefs(parent));
rv = current->GetParent(getter_AddRefs(parent));
NS_ENSURE_SUCCESS(rv, rv);

if (SameCOMIdentity(parent, current)) {
Expand Down Expand Up @@ -212,9 +210,7 @@ ThirdPartyUtil::IsThirdPartyChannel(nsIChannel* aChannel,
ctx->GetAssociatedWindow(getter_AddRefs(ourWin));
if (!ourWin) return NS_ERROR_INVALID_ARG;

// We use GetScriptableParent rather than GetParent because we consider
// <iframe mozbrowser/mozapp> to be a top-level frame.
ourWin->GetScriptableParent(getter_AddRefs(parentWin));
ourWin->GetParent(getter_AddRefs(parentWin));
NS_ENSURE_TRUE(parentWin, NS_ERROR_INVALID_ARG);

// Check whether this is the document channel for this window (representing a
Expand Down
2 changes: 1 addition & 1 deletion content/base/src/nsDocument.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8359,7 +8359,7 @@ HasCrossProcessParent(nsIDocument* aDocument)
if (!docShell) {
return false;
}
return docShell->GetIsBrowserOrApp();
return docShell->GetIsContentBoundary();
}

static bool
Expand Down
Loading

0 comments on commit 3eff16d

Please sign in to comment.