mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 13:21:05 +00:00
Bug 1302047 - Test if permission matches for different userContextId or firstPartyDomain. r=baku
--HG-- extra : rebase_source : ffe4fbd2472fb329c46c7e31dd0f1f3776c525bf
This commit is contained in:
parent
facc06fda2
commit
61bd32ab34
@ -77,6 +77,22 @@ function run_test() {
|
||||
let uri4_2000_y = secMan.createCodebasePrincipal(uri4, attrs);
|
||||
let uri5_2000_y = secMan.createCodebasePrincipal(uri5, attrs);
|
||||
|
||||
attrs = {userContextId: 1};
|
||||
let uri0_1 = secMan.createCodebasePrincipal(uri0, attrs);
|
||||
let uri1_1 = secMan.createCodebasePrincipal(uri1, attrs);
|
||||
let uri2_1 = secMan.createCodebasePrincipal(uri2, attrs);
|
||||
let uri3_1 = secMan.createCodebasePrincipal(uri3, attrs);
|
||||
let uri4_1 = secMan.createCodebasePrincipal(uri4, attrs);
|
||||
let uri5_1 = secMan.createCodebasePrincipal(uri5, attrs);
|
||||
|
||||
attrs = {firstPartyDomain: "cnn.com"};
|
||||
let uri0_cnn = secMan.createCodebasePrincipal(uri0, attrs);
|
||||
let uri1_cnn = secMan.createCodebasePrincipal(uri1, attrs);
|
||||
let uri2_cnn = secMan.createCodebasePrincipal(uri2, attrs);
|
||||
let uri3_cnn = secMan.createCodebasePrincipal(uri3, attrs);
|
||||
let uri4_cnn = secMan.createCodebasePrincipal(uri4, attrs);
|
||||
let uri5_cnn = secMan.createCodebasePrincipal(uri5, attrs);
|
||||
|
||||
pm.addFromPrincipal(uri0_n_n, "test/matches", pm.ALLOW_ACTION);
|
||||
let perm_n_n = pm.getPermissionObject(uri0_n_n, "test/matches", true);
|
||||
pm.addFromPrincipal(uri0_1000_n, "test/matches", pm.ALLOW_ACTION);
|
||||
@ -87,14 +103,20 @@ function run_test() {
|
||||
let perm_2000_n = pm.getPermissionObject(uri0_2000_n, "test/matches", true);
|
||||
pm.addFromPrincipal(uri0_2000_y, "test/matches", pm.ALLOW_ACTION);
|
||||
let perm_2000_y = pm.getPermissionObject(uri0_2000_y, "test/matches", true);
|
||||
pm.addFromPrincipal(uri0_1, "test/matches", pm.ALLOW_ACTION);
|
||||
let perm_1 = pm.getPermissionObject(uri0_n_n, "test/matches", true);
|
||||
pm.addFromPrincipal(uri0_cnn, "test/matches", pm.ALLOW_ACTION);
|
||||
let perm_cnn = pm.getPermissionObject(uri0_n_n, "test/matches", true);
|
||||
|
||||
matches_always(perm_n_n, [uri0_n_n]);
|
||||
matches_weak(perm_n_n, [uri1_n_n]);
|
||||
matches_always(perm_n_n, [uri0_n_n, uri0_1, uri0_cnn]);
|
||||
matches_weak(perm_n_n, [uri1_n_n, uri1_1, uri1_cnn]);
|
||||
matches_never(perm_n_n, [uri2_n_n, uri3_n_n, uri4_n_n, uri5_n_n,
|
||||
uri0_1000_n, uri1_1000_n, uri2_1000_n, uri3_1000_n, uri4_1000_n, uri5_1000_n,
|
||||
uri0_1000_y, uri1_1000_y, uri2_1000_y, uri3_1000_y, uri4_1000_y, uri5_1000_y,
|
||||
uri0_2000_n, uri1_2000_n, uri2_2000_n, uri3_2000_n, uri4_2000_n, uri5_2000_n,
|
||||
uri0_2000_y, uri1_2000_y, uri2_2000_y, uri3_2000_y, uri4_2000_y, uri5_2000_y]);
|
||||
uri0_2000_y, uri1_2000_y, uri2_2000_y, uri3_2000_y, uri4_2000_y, uri5_2000_y,
|
||||
uri2_1, uri3_1, uri4_1, uri5_1,
|
||||
uri2_cnn, uri3_cnn, uri4_cnn, uri5_cnn]);
|
||||
|
||||
matches_always(perm_1000_n, [uri0_1000_n]);
|
||||
matches_weak(perm_1000_n, [uri1_1000_n]);
|
||||
@ -102,7 +124,9 @@ function run_test() {
|
||||
uri0_n_n, uri1_n_n, uri2_n_n, uri3_n_n, uri4_n_n, uri5_n_n,
|
||||
uri0_1000_y, uri1_1000_y, uri2_1000_y, uri3_1000_y, uri4_1000_y, uri5_1000_y,
|
||||
uri0_2000_n, uri1_2000_n, uri2_2000_n, uri3_2000_n, uri4_2000_n, uri5_2000_n,
|
||||
uri0_2000_y, uri1_2000_y, uri2_2000_y, uri3_2000_y, uri4_2000_y, uri5_2000_y]);
|
||||
uri0_2000_y, uri1_2000_y, uri2_2000_y, uri3_2000_y, uri4_2000_y, uri5_2000_y,
|
||||
uri0_1, uri1_1, uri2_1, uri3_1, uri4_1, uri5_1,
|
||||
uri0_cnn, uri1_cnn, uri2_cnn, uri3_cnn, uri4_cnn, uri5_cnn]);
|
||||
|
||||
matches_always(perm_1000_y, [uri0_1000_y]);
|
||||
matches_weak(perm_1000_y, [uri1_1000_y]);
|
||||
@ -110,7 +134,9 @@ function run_test() {
|
||||
uri0_n_n, uri1_n_n, uri2_n_n, uri3_n_n, uri4_n_n, uri5_n_n,
|
||||
uri0_1000_n, uri1_1000_n, uri2_1000_n, uri3_1000_n, uri4_1000_n, uri5_1000_n,
|
||||
uri0_2000_n, uri1_2000_n, uri2_2000_n, uri3_2000_n, uri4_2000_n, uri5_2000_n,
|
||||
uri0_2000_y, uri1_2000_y, uri2_2000_y, uri3_2000_y, uri4_2000_y, uri5_2000_y]);
|
||||
uri0_2000_y, uri1_2000_y, uri2_2000_y, uri3_2000_y, uri4_2000_y, uri5_2000_y,
|
||||
uri0_1, uri1_1, uri2_1, uri3_1, uri4_1, uri5_1,
|
||||
uri0_cnn, uri1_cnn, uri2_cnn, uri3_cnn, uri4_cnn, uri5_cnn]);
|
||||
|
||||
matches_always(perm_2000_n, [uri0_2000_n]);
|
||||
matches_weak(perm_2000_n, [uri1_2000_n]);
|
||||
@ -118,7 +144,9 @@ function run_test() {
|
||||
uri0_n_n, uri1_n_n, uri2_n_n, uri3_n_n, uri4_n_n, uri5_n_n,
|
||||
uri0_2000_y, uri1_2000_y, uri2_2000_y, uri3_2000_y, uri4_2000_y, uri5_2000_y,
|
||||
uri0_1000_n, uri1_1000_n, uri2_1000_n, uri3_1000_n, uri4_1000_n, uri5_1000_n,
|
||||
uri0_1000_y, uri1_1000_y, uri2_1000_y, uri3_1000_y, uri4_1000_y, uri5_1000_y]);
|
||||
uri0_1000_y, uri1_1000_y, uri2_1000_y, uri3_1000_y, uri4_1000_y, uri5_1000_y,
|
||||
uri0_1, uri1_1, uri2_1, uri3_1, uri4_1, uri5_1,
|
||||
uri0_cnn, uri1_cnn, uri2_cnn, uri3_cnn, uri4_cnn, uri5_cnn]);
|
||||
|
||||
matches_always(perm_2000_y, [uri0_2000_y]);
|
||||
matches_weak(perm_2000_y, [uri1_2000_y]);
|
||||
@ -126,7 +154,29 @@ function run_test() {
|
||||
uri0_n_n, uri1_n_n, uri2_n_n, uri3_n_n, uri4_n_n, uri5_n_n,
|
||||
uri0_2000_n, uri1_2000_n, uri2_2000_n, uri3_2000_n, uri4_2000_n, uri5_2000_n,
|
||||
uri0_1000_n, uri1_1000_n, uri2_1000_n, uri3_1000_n, uri4_1000_n, uri5_1000_n,
|
||||
uri0_1000_y, uri1_1000_y, uri2_1000_y, uri3_1000_y, uri4_1000_y, uri5_1000_y]);
|
||||
uri0_1000_y, uri1_1000_y, uri2_1000_y, uri3_1000_y, uri4_1000_y, uri5_1000_y,
|
||||
uri0_1, uri1_1, uri2_1, uri3_1, uri4_1, uri5_1,
|
||||
uri0_cnn, uri1_cnn, uri2_cnn, uri3_cnn, uri4_cnn, uri5_cnn]);
|
||||
|
||||
matches_always(perm_1, [uri0_n_n, uri0_1, uri0_cnn]);
|
||||
matches_weak(perm_1, [uri1_n_n, uri1_1, uri1_cnn]);
|
||||
matches_never(perm_1, [uri2_n_n, uri3_n_n, uri4_n_n, uri5_n_n,
|
||||
uri0_1000_n, uri1_1000_n, uri2_1000_n, uri3_1000_n, uri4_1000_n, uri5_1000_n,
|
||||
uri0_1000_y, uri1_1000_y, uri2_1000_y, uri3_1000_y, uri4_1000_y, uri5_1000_y,
|
||||
uri0_2000_n, uri1_2000_n, uri2_2000_n, uri3_2000_n, uri4_2000_n, uri5_2000_n,
|
||||
uri0_2000_y, uri1_2000_y, uri2_2000_y, uri3_2000_y, uri4_2000_y, uri5_2000_y,
|
||||
uri2_1, uri3_1, uri4_1, uri5_1,
|
||||
uri2_cnn, uri3_cnn, uri4_cnn, uri5_cnn]);
|
||||
|
||||
matches_always(perm_cnn, [uri0_n_n, uri0_1, uri0_cnn]);
|
||||
matches_weak(perm_cnn, [uri1_n_n, uri1_1, uri1_cnn]);
|
||||
matches_never(perm_cnn, [uri2_n_n, uri3_n_n, uri4_n_n, uri5_n_n,
|
||||
uri0_1000_n, uri1_1000_n, uri2_1000_n, uri3_1000_n, uri4_1000_n, uri5_1000_n,
|
||||
uri0_1000_y, uri1_1000_y, uri2_1000_y, uri3_1000_y, uri4_1000_y, uri5_1000_y,
|
||||
uri0_2000_n, uri1_2000_n, uri2_2000_n, uri3_2000_n, uri4_2000_n, uri5_2000_n,
|
||||
uri0_2000_y, uri1_2000_y, uri2_2000_y, uri3_2000_y, uri4_2000_y, uri5_2000_y,
|
||||
uri2_1, uri3_1, uri4_1, uri5_1,
|
||||
uri2_cnn, uri3_cnn, uri4_cnn, uri5_cnn]);
|
||||
|
||||
// Clean up!
|
||||
pm.removeAll();
|
||||
|
Loading…
Reference in New Issue
Block a user