Backed out changeset 736daf4b4a56 (bug 1229222) for bc6 test failures in browser_339445.js

This commit is contained in:
Carsten "Tomcat" Book 2016-02-19 15:56:27 +01:00
parent 6b54f0d05b
commit 9164177faa

View File

@ -33,28 +33,9 @@ function checkOriginAttributes(prin, attrs, suffix) {
} else {
checkThrows(() => ssm.createCodebasePrincipalFromOrigin(prin.origin));
}
}
// utility function useful for debugging
function printAttrs(name, attrs) {
do_print(name + " {\n" +
"\tappId: " + attrs.appId + ",\n" +
"\tuserContextId: " + attrs.userContextId + ",\n" +
"\tinBrowser: " + attrs.inBrowser + ",\n" +
"\taddonId: '" + attrs.addonId + "',\n" +
"\tsignedPkg: '" + attrs.signedPkg + "'\n}");
}
function checkValues(attrs, values) {
values = values || {};
//printAttrs("attrs", attrs);
//printAttrs("values", values);
do_check_eq(attrs.appId, values.appId || 0);
do_check_eq(attrs.userContextId, values.userContextId || 0);
do_check_eq(attrs.inBrowser, values.inBrowser || false);
do_check_eq(attrs.addonId, values.addonId || '');
do_check_eq(attrs.signedPkg, values.signedPkg || '');
do_check_eq(ChromeUtils.createOriginAttributesWithUserContextId("http://example.org", 2).userContextId, 2);
do_check_eq(ChromeUtils.createOriginAttributesWithUserContextId("https://www.example.com:123^userContextId=4", 2).userContextId, 2);
}
function run_test() {
@ -196,83 +177,4 @@ function run_test() {
checkKind(ssm.createCodebasePrincipal(makeURI('http://www.example.com'), {}), 'codebasePrincipal');
checkKind(ssm.createExpandedPrincipal([ssm.createCodebasePrincipal(makeURI('http://www.example.com'), {})]), 'expandedPrincipal');
checkKind(ssm.getSystemPrincipal(), 'systemPrincipal');
//
// Test Origin Attribute Manipulation
//
// check that we can create an empty origin attributes dict with default
// members and values.
emptyAttrs = ChromeUtils.createDefaultOriginAttributes();
checkValues(emptyAttrs);
var uri = "http://example.org";
var tests = [
[ "", {} ],
[ "^appId=5", {appId: 5} ],
[ "^userContextId=3", {userContextId: 3} ],
[ "^addonId=fooBar", {addonId: "fooBar"} ],
[ "^inBrowser=1", {inBrowser: true} ],
[ "^signedPkg=bazQux", {signedPkg: "bazQux"} ],
[ "^appId=3&inBrowser=1&userContextId=6",
{appId: 3, userContextId: 6, inBrowser: true} ] ];
// check that we can create an origin attributes from an origin properly
tests.forEach(function(t) {
let attrs = ChromeUtils.createOriginAttributesFromOrigin(uri + t[0]);
checkValues(attrs, t[1]);
do_check_eq(ChromeUtils.originAttributesToSuffix(attrs), t[0]);
});
// check that we can create an origin attributes from a dict properly
tests.forEach(function(t) {
let attrs = ChromeUtils.createOriginAttributesFromDict(t[1]);
checkValues(attrs, t[1]);
do_check_eq(ChromeUtils.originAttributesToSuffix(attrs), t[0]);
});
// each row in the set_tests array has these values:
// [0] - the suffix used to create an origin attribute from
// [1] - the expected result of creating an origin attribute from [0]
// [2] - the pattern to set on the origin attributes
// [3] - the expected result of setting [2] values on [1]
// [4] - the expected result of creating a suffix from [3]
var set_tests = [
[ "", {}, {appId: 5}, {appId: 5}, "^appId=5" ],
[ "^appId=5", {appId: 5}, {appId: 3}, {appId: 3}, "^appId=3" ],
[ "^appId=5", {appId: 5}, {userContextId: 3}, {appId: 5, userContextId: 3}, "^appId=5&userContextId=3" ],
[ "^appId=5", {appId: 5}, {appId: 3, userContextId: 7}, {appId: 3, userContextId: 7}, "^appId=3&userContextId=7" ] ];
// check that we can set origin attributes values properly
set_tests.forEach(function(t) {
let orig = ChromeUtils.createOriginAttributesFromOrigin(uri + t[0]);
checkValues(orig, t[1]);
let mod = orig;
for (var key in t[2]) {
mod[key] = t[2][key];
}
checkValues(mod, t[3]);
do_check_eq(ChromeUtils.originAttributesToSuffix(mod), t[4]);
});
// each row in the dflt_tests array has these values:
// [0] - the suffix used to create an origin attribute from
// [1] - the expected result of creating an origin attributes from [0]
// [2] - the expected result after setting userContextId to the default
// [3] - the expected result of creating a suffix from [2]
var dflt_tests = [
[ "", {}, {}, "" ],
[ "^userContextId=3", {userContextId: 3}, {}, "" ],
[ "^appId=5", {appId: 5}, {appId: 5}, "^appId=5" ],
[ "^appId=5&userContextId=3", {appId: 5, userContextId: 3}, {appId: 5}, "^appId=5" ] ];
// check that we can set the userContextId to default properly
dflt_tests.forEach(function(t) {
let orig = ChromeUtils.createOriginAttributesFromOrigin(uri + t[0]);
checkValues(orig, t[1]);
let mod = orig;
mod['userContextId'] = 0;
checkValues(mod, t[2]);
do_check_eq(ChromeUtils.originAttributesToSuffix(mod), t[3]);
});
}