Backed out changeset 0519406b6e57 (bug 1238177) for eslint test failures

This commit is contained in:
Carsten "Tomcat" Book 2016-04-03 09:30:03 +02:00
Родитель 9b79809916
Коммит 394034a83e
5 изменённых файлов: 28 добавлений и 12 удалений

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

@ -203,7 +203,7 @@ function run_test() {
// check that we can create an empty origin attributes dict with default
// members and values.
emptyAttrs = ChromeUtils.fillNonDefaultOriginAttributes({});
emptyAttrs = ChromeUtils.createDefaultOriginAttributes();
checkValues(emptyAttrs);
var uri = "http://example.org";
@ -226,7 +226,7 @@ function run_test() {
// check that we can create an origin attributes from a dict properly
tests.forEach(function(t) {
let attrs = ChromeUtils.fillNonDefaultOriginAttributes(t[1]);
let attrs = ChromeUtils.createOriginAttributesFromDict(t[1]);
checkValues(attrs, t[1]);
do_check_eq(ChromeUtils.originAttributesToSuffix(attrs), t[0]);
});

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

@ -70,6 +70,13 @@ ChromeUtils::OriginAttributesMatchPattern(dom::GlobalObject& aGlobal,
return pattern.Matches(attrs);
}
/* static */ void
ChromeUtils::CreateDefaultOriginAttributes(dom::GlobalObject& aGlobal,
dom::OriginAttributesDictionary& aAttrs)
{
aAttrs = GenericOriginAttributes();
}
/* static */ void
ChromeUtils::CreateOriginAttributesFromOrigin(dom::GlobalObject& aGlobal,
const nsAString& aOrigin,
@ -86,7 +93,7 @@ ChromeUtils::CreateOriginAttributesFromOrigin(dom::GlobalObject& aGlobal,
}
/* static */ void
ChromeUtils::FillNonDefaultOriginAttributes(dom::GlobalObject& aGlobal,
ChromeUtils::CreateOriginAttributesFromDict(dom::GlobalObject& aGlobal,
const dom::OriginAttributesDictionary& aAttrs,
dom::OriginAttributesDictionary& aNewAttrs)
{

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

@ -58,6 +58,10 @@ public:
const dom::OriginAttributesDictionary& aAttrs,
const dom::OriginAttributesPatternDictionary& aPattern);
static void
CreateDefaultOriginAttributes(dom::GlobalObject& aGlobal,
dom::OriginAttributesDictionary& aAttrs);
static void
CreateOriginAttributesFromOrigin(dom::GlobalObject& aGlobal,
const nsAString& aOrigin,
@ -65,7 +69,7 @@ public:
ErrorResult& aRv);
static void
FillNonDefaultOriginAttributes(dom::GlobalObject& aGlobal,
CreateOriginAttributesFromDict(dom::GlobalObject& aGlobal,
const dom::OriginAttributesDictionary& aAttrs,
dom::OriginAttributesDictionary& aNewAttrs);

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

@ -29,6 +29,16 @@ interface ChromeUtils : ThreadSafeChromeUtils {
originAttributesMatchPattern(optional OriginAttributesDictionary originAttrs,
optional OriginAttributesPatternDictionary pattern);
/**
* Returns an OriginAttributesDictionary with all default attributes added
* and assigned default values.
*
* @returns An OriginAttributesDictionary populated with the
* default attributes added and assigned default values.
*/
static OriginAttributesDictionary
createDefaultOriginAttributes();
/**
* Returns an OriginAttributesDictionary with values from the |origin| suffix
* and unspecified attributes added and assigned default values.
@ -52,7 +62,7 @@ interface ChromeUtils : ThreadSafeChromeUtils {
* default values.
*/
static OriginAttributesDictionary
fillNonDefaultOriginAttributes(optional OriginAttributesDictionary originAttrs);
createOriginAttributesFromDict(optional OriginAttributesDictionary originAttrs);
/**
* Returns true if the 2 OriginAttributes are equal.

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

@ -296,18 +296,13 @@ class ExtensionContext extends BaseContext {
let contentPrincipal = contentWindow.document.nodePrincipal;
let ssm = Services.scriptSecurityManager;
// copy origin attributes from the content window origin attributes to
// preserve the user context id. overwrite the addonId.
let attrs = ChromeUtils.fillNonDefaultOriginAttributes(contentPrincipal.originAttributes);
attrs.addonId = extensionId;
let extensionPrincipal = ssm.createCodebasePrincipal(this.extension.baseURI, attrs);
let extensionPrincipal = ssm.createCodebasePrincipal(this.extension.baseURI, {addonId: extensionId});
Object.defineProperty(this, "principal",
{value: extensionPrincipal, enumerable: true, configurable: true});
if (ssm.isSystemPrincipal(contentPrincipal)) {
// Make sure we don't hand out the system principal by accident.
// also make sure that the null principal has the right origin attributes
prin = ssm.createNullPrincipal(attrs);
prin = Cc["@mozilla.org/nullprincipal;1"].createInstance(Ci.nsIPrincipal);
} else {
prin = [contentPrincipal, extensionPrincipal];
}