author | Mounir Lamouri <mounir.lamouri@gmail.com> |
Tue, 31 Jul 2012 17:47:20 +0200 | |
changeset 106990 | b69add485ebcfed29bdfe2e043050dd3c2c61f52 |
parent 106989 | 9ef6e48c13c1dc6132898adf765c6b6b693ae121 |
child 106991 | d6fc07492b92f7483bed9da7cb2e5050e8677767 |
push id | 214 |
push user | akeybl@mozilla.com |
push date | Wed, 14 Nov 2012 20:38:59 +0000 |
treeherder | mozilla-release@c8b08ec8e1aa [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | mrbkap, sicking |
bugs | 776824 |
milestone | 17.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/caps/idl/nsIPrincipal.idl +++ b/caps/idl/nsIPrincipal.idl @@ -16,17 +16,17 @@ struct JSPrincipals; interface nsIURI; interface nsIContentSecurityPolicy; [ptr] native JSContext(JSContext); [ptr] native JSPrincipals(JSPrincipals); [ptr] native PrincipalArray(nsTArray<nsCOMPtr<nsIPrincipal> >); -[scriptable, uuid(fbb93cc7-9a94-4743-8e89-9e6939cac083)] +[scriptable, uuid(8a74b011-667d-4cfa-b2a2-b27582ba5f38)] interface nsIPrincipal : nsISerializable { /** * Values of capabilities for each principal. Order is * significant: if an operation is performed on a set * of capabilities, the minimum is computed. */ const short ENABLE_DENIED = 1; @@ -240,16 +240,21 @@ interface nsIPrincipal : nsISerializable */ readonly attribute unsigned short appStatus; /** * Returns the app id the principal is in. * Returns nsIAppsService::NO_APP_ID if this principal isn't part of an app. */ readonly attribute unsigned long appId; + + /** + * Returns true iif the principal is inside a browser element. + */ + readonly attribute boolean isInBrowserElement; }; /** * If nsSystemPrincipal is too risky to use, but we want a principal to access * more than one origin, nsExpandedPrincipals letting us define an array of * principals it subsumes. So script with an nsExpandedPrincipals will gain * same origin access when at least one of its principals it contains gained * sameorigin acccess. An nsExpandedPrincipal will be subsumed by the system
--- a/caps/include/nsPrincipal.h +++ b/caps/include/nsPrincipal.h @@ -122,16 +122,17 @@ public: NS_IMETHOD SetDomain(nsIURI* aDomain); NS_IMETHOD GetOrigin(char** aOrigin); NS_IMETHOD Subsumes(nsIPrincipal* other, bool* _retval); NS_IMETHOD SubsumesIgnoringDomain(nsIPrincipal* other, bool* _retval); NS_IMETHOD CheckMayLoad(nsIURI* uri, bool report); NS_IMETHOD GetExtendedOrigin(nsACString& aExtendedOrigin); NS_IMETHOD GetAppStatus(PRUint16* aAppStatus); NS_IMETHOD GetAppId(PRUint32* aAppStatus); + NS_IMETHOD GetIsInBrowserElement(bool* aIsInBrowserElement); #ifdef DEBUG virtual void dumpImpl(); #endif nsPrincipal(); // Either Init() or InitFromPersistent() must be called before // the principal is in a usable state. @@ -200,16 +201,17 @@ public: NS_IMETHOD SetDomain(nsIURI* aDomain); NS_IMETHOD GetOrigin(char** aOrigin); NS_IMETHOD Subsumes(nsIPrincipal* other, bool* _retval); NS_IMETHOD SubsumesIgnoringDomain(nsIPrincipal* other, bool* _retval); NS_IMETHOD CheckMayLoad(nsIURI* uri, bool report); NS_IMETHOD GetExtendedOrigin(nsACString& aExtendedOrigin); NS_IMETHOD GetAppStatus(PRUint16* aAppStatus); NS_IMETHOD GetAppId(PRUint32* aAppStatus); + NS_IMETHOD GetIsInBrowserElement(bool* aIsInBrowserElement); #ifdef DEBUG virtual void dumpImpl(); #endif virtual void GetScriptLocation(nsACString &aStr) MOZ_OVERRIDE; private: nsTArray< nsCOMPtr<nsIPrincipal> > mPrincipals;
--- a/caps/src/nsNullPrincipal.cpp +++ b/caps/src/nsNullPrincipal.cpp @@ -330,16 +330,23 @@ nsNullPrincipal::GetAppStatus(PRUint16* NS_IMETHODIMP nsNullPrincipal::GetAppId(PRUint32* aAppId) { *aAppId = nsIScriptSecurityManager::NO_APP_ID; return NS_OK; } +NS_IMETHODIMP +nsNullPrincipal::GetIsInBrowserElement(bool* aIsInBrowserElement) +{ + *aIsInBrowserElement = false; + return NS_OK; +} + /** * nsISerializable implementation */ NS_IMETHODIMP nsNullPrincipal::Read(nsIObjectInputStream* aStream) { // no-op: CID is sufficient to create a useful nsNullPrincipal, since the URI // is not really relevant.
--- a/caps/src/nsPrincipal.cpp +++ b/caps/src/nsPrincipal.cpp @@ -1089,16 +1089,23 @@ nsPrincipal::GetAppId(PRUint32* aAppId) return NS_OK; } *aAppId = mAppId; return NS_OK; } NS_IMETHODIMP +nsPrincipal::GetIsInBrowserElement(bool* aIsInBrowserElement) +{ + *aIsInBrowserElement = mInMozBrowser; + return NS_OK; +} + +NS_IMETHODIMP nsPrincipal::Read(nsIObjectInputStream* aStream) { bool hasCapabilities; nsresult rv = aStream->ReadBoolean(&hasCapabilities); if (NS_SUCCEEDED(rv) && hasCapabilities) { mCapabilities = new nsHashtable(aStream, ReadAnnotationEntry, FreeAnnotationEntry, &rv); NS_ENSURE_TRUE(mCapabilities, NS_ERROR_OUT_OF_MEMORY); @@ -1471,16 +1478,22 @@ nsExpandedPrincipal::GetAppStatus(PRUint } NS_IMETHODIMP nsExpandedPrincipal::GetAppId(PRUint32* aAppId) { return NS_ERROR_NOT_AVAILABLE; } +NS_IMETHODIMP +nsExpandedPrincipal::GetIsInBrowserElement(bool* aIsInBrowserElement) +{ + return NS_ERROR_NOT_AVAILABLE; +} + void nsExpandedPrincipal::GetScriptLocation(nsACString& aStr) { if (mCert) { aStr.Assign(mCert->fingerprint); } else { // Is that a good idea to list it's principals? aStr.Assign(EXPANDED_PRINCIPAL_SPEC);
--- a/caps/src/nsSystemPrincipal.cpp +++ b/caps/src/nsSystemPrincipal.cpp @@ -253,16 +253,23 @@ nsSystemPrincipal::GetAppStatus(PRUint16 NS_IMETHODIMP nsSystemPrincipal::GetAppId(PRUint32* aAppId) { *aAppId = nsIScriptSecurityManager::NO_APP_ID; return NS_OK; } +NS_IMETHODIMP +nsSystemPrincipal::GetIsInBrowserElement(bool* aIsInBrowserElement) +{ + *aIsInBrowserElement = false; + return NS_OK; +} + ////////////////////////////////////////// // Methods implementing nsISerializable // ////////////////////////////////////////// NS_IMETHODIMP nsSystemPrincipal::Read(nsIObjectInputStream* aStream) { // no-op: CID is sufficient to identify the mSystemPrincipal singleton
--- a/caps/tests/mochitest/test_principal_extendedorigin_appid_appstatus.html +++ b/caps/tests/mochitest/test_principal_extendedorigin_appid_appstatus.html @@ -246,16 +246,17 @@ var gData = [ // browser containing an iframe is part of the browser { src: "http://example.org/", isapp: false, browser: true, child: { src: "http://example.org/chrome/", isapp: false, + inBrowser: true, }, test: [ "child-has-same-eo" ], }, ]; // The list of all data ids generated by this test. var eoList = []; @@ -305,24 +306,30 @@ function checkIFrame(aFrame, data) { is(eoList.indexOf(principal.extendedOrigin), -1, "extendedOrigin should be unique"); } if (data.test.indexOf("eo-as-last") != -1) { is(principal.extendedOrigin, eoList[eoList.length-1], "extendedOrigin should be the same as the last inserted one"); } + is(principal.isInBrowserElement, !!data.browser, + "check principal.isInBrowserElement"); + if (data.child) { let childPrincipal = aFrame.contentWindow.frames[0].document.nodePrincipal; if (data.child.isapp) { is(childPrincipal.appStatus, Ci.nsIPrincipal.APP_STATUS_INSTALLED, "child should be an installed app"); } + is(childPrincipal.isInBrowserElement, !!data.child.browser || !!data.child.inBrowser, + "check childPrincipal.isInBrowserElement"); + if (data.test.indexOf("child-has-same-eo") != -1) { is(childPrincipal.extendedOrigin, principal.extendedOrigin, "child should have the same extendedOrigin as parent"); is(childPrincipal.appStatus, principal.appStatus, "child should have the same appStatus if it has the same extendedOrigin"); is(childPrincipal.appId, principal.appId, "child should have the same appId if it has the same extendedOrigin"); }