mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-26 14:22:01 +00:00
Bug 1180921 - Add the addonId OriginAttribute. r=bholley
This commit is contained in:
parent
01a5c316e5
commit
24ce1d8fe4
@ -41,6 +41,10 @@ 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);
|
||||
@ -88,6 +92,12 @@ 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;
|
||||
}
|
||||
|
@ -34,7 +34,8 @@ public:
|
||||
bool operator==(const OriginAttributes& aOther) const
|
||||
{
|
||||
return mAppId == aOther.mAppId &&
|
||||
mInBrowser == aOther.mInBrowser;
|
||||
mInBrowser == aOther.mInBrowser &&
|
||||
mAddonId == aOther.mAddonId;
|
||||
}
|
||||
bool operator!=(const OriginAttributes& aOther) const
|
||||
{
|
||||
|
@ -23,8 +23,8 @@
|
||||
class nsIURI;
|
||||
|
||||
#define NS_NULLPRINCIPAL_CID \
|
||||
{ 0xe502ffb8, 0x5d95, 0x48e8, \
|
||||
{ 0x82, 0x3c, 0x0d, 0x29, 0xd8, 0x3a, 0x59, 0x33 } }
|
||||
{ 0x34a19ab6, 0xca47, 0x4098, \
|
||||
{ 0xa7, 0xb8, 0x4a, 0xfc, 0xdd, 0xcd, 0x8f, 0x88 } }
|
||||
#define NS_NULLPRINCIPAL_CONTRACTID "@mozilla.org/nullprincipal;1"
|
||||
|
||||
#define NS_NULLPRINCIPAL_SCHEME "moz-nullprincipal"
|
||||
|
@ -112,12 +112,12 @@ private:
|
||||
|
||||
#define NS_PRINCIPAL_CONTRACTID "@mozilla.org/principal;1"
|
||||
#define NS_PRINCIPAL_CID \
|
||||
{ 0xb7c8505e, 0xc56d, 0x4191, \
|
||||
{ 0xa1, 0x5e, 0x5d, 0xcb, 0x88, 0x9b, 0xa0, 0x94 }}
|
||||
{ 0xb02c3023, 0x5b37, 0x472a, \
|
||||
{ 0xa2, 0xcd, 0x35, 0xaa, 0x5e, 0xe2, 0xa8, 0x19 } }
|
||||
|
||||
#define NS_EXPANDEDPRINCIPAL_CONTRACTID "@mozilla.org/expandedprincipal;1"
|
||||
#define NS_EXPANDEDPRINCIPAL_CID \
|
||||
{ 0x38539471, 0x68cc, 0x4a6f, \
|
||||
{ 0x81, 0x20, 0xdb, 0xd5, 0x4a, 0x22, 0x0a, 0x13 }}
|
||||
{ 0xe8ee88b0, 0x5571, 0x4086, \
|
||||
{ 0xa4, 0x5b, 0x39, 0xa7, 0x16, 0x90, 0x6b, 0xdb } }
|
||||
|
||||
#endif // nsPrincipal_h__
|
||||
|
@ -91,6 +91,11 @@ function run_test() {
|
||||
checkOriginAttributes(exampleCom_appBrowser, {appId: 42, inBrowser: 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);
|
||||
@ -99,4 +104,5 @@ function run_test() {
|
||||
checkCrossOrigin(exampleOrg_appBrowser, exampleOrg_app);
|
||||
checkCrossOrigin(exampleOrg_appBrowser, nullPrin_appBrowser);
|
||||
checkCrossOrigin(exampleOrg_appBrowser, exampleCom_appBrowser);
|
||||
checkCrossOrigin(exampleOrg_addon, exampleOrg);
|
||||
}
|
||||
|
@ -40,4 +40,5 @@ interface ChromeUtils : ThreadSafeChromeUtils {
|
||||
dictionary OriginAttributesDictionary {
|
||||
unsigned long appId = 0;
|
||||
boolean inBrowser = false;
|
||||
DOMString addonId = "";
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user