forked from mirrors/gecko-dev
This patch was autogenerated by my decomponents.py
It covers almost every file with the extension js, jsm, html, py,
xhtml, or xul.
It removes blank lines after removed lines, when the removed lines are
preceded by either blank lines or the start of a new block. The "start
of a new block" is defined fairly hackily: either the line starts with
//, ends with */, ends with {, <![CDATA[, """ or '''. The first two
cover comments, the third one covers JS, the fourth covers JS embedded
in XUL, and the final two cover JS embedded in Python. This also
applies if the removed line was the first line of the file.
It covers the pattern matching cases like "var {classes: Cc,
interfaces: Ci, utils: Cu, results: Cr} = Components;". It'll remove
the entire thing if they are all either Ci, Cr, Cc or Cu, or it will
remove the appropriate ones and leave the residue behind. If there's
only one behind, then it will turn it into a normal, non-pattern
matching variable definition. (For instance, "const { classes: Cc,
Constructor: CC, interfaces: Ci, utils: Cu } = Components" becomes
"const CC = Components.Constructor".)
MozReview-Commit-ID: DeSHcClQ7cG
--HG--
extra : rebase_source : d9c41878036c1ef7766ef5e91a7005025bc1d72b
69 lines
2.8 KiB
HTML
69 lines
2.8 KiB
HTML
"use strict";
|
|
|
|
do_get_profile();
|
|
|
|
Cu.import("resource://gre/modules/ContextualIdentityService.jsm");
|
|
|
|
const TEST_STORE_FILE_NAME = "test-containers.json";
|
|
|
|
let cis;
|
|
|
|
// Basic tests
|
|
add_task(function() {
|
|
ok(!!ContextualIdentityService, "ContextualIdentityService exists");
|
|
|
|
cis = ContextualIdentityService.createNewInstanceForTesting(TEST_STORE_FILE_NAME);
|
|
ok(!!cis, "We have our instance of ContextualIdentityService");
|
|
|
|
equal(cis.getPublicIdentities().length, 4, "By default, 4 containers.");
|
|
equal(cis.getPublicIdentityFromId(0), null, "No identity with id 0");
|
|
|
|
ok(!!cis.getPublicIdentityFromId(1), "Identity 1 exists");
|
|
ok(!!cis.getPublicIdentityFromId(2), "Identity 2 exists");
|
|
ok(!!cis.getPublicIdentityFromId(3), "Identity 3 exists");
|
|
ok(!!cis.getPublicIdentityFromId(4), "Identity 4 exists");
|
|
});
|
|
|
|
// Create a new identity
|
|
add_task(function() {
|
|
equal(cis.getPublicIdentities().length, 4, "By default, 4 containers.");
|
|
|
|
let identity = cis.create("New Container", "Icon", "Color");
|
|
ok(!!identity, "New container created");
|
|
equal(identity.name, "New Container", "Name matches");
|
|
equal(identity.icon, "Icon", "Icon matches");
|
|
equal(identity.color, "Color", "Color matches");
|
|
|
|
equal(cis.getPublicIdentities().length, 5, "Expected 5 containers.");
|
|
|
|
ok(!!cis.getPublicIdentityFromId(identity.userContextId), "Identity exists");
|
|
equal(cis.getPublicIdentityFromId(identity.userContextId).name, "New Container", "Identity name is OK");
|
|
equal(cis.getPublicIdentityFromId(identity.userContextId).icon, "Icon", "Identity icon is OK");
|
|
equal(cis.getPublicIdentityFromId(identity.userContextId).color, "Color", "Identity color is OK");
|
|
equal(cis.getUserContextLabel(identity.userContextId), "New Container", "Identity label is OK");
|
|
});
|
|
|
|
// Remove an identity
|
|
add_task(function() {
|
|
equal(cis.getPublicIdentities().length, 5, "Expected 5 containers.");
|
|
|
|
equal(cis.remove(-1), false, "cis.remove() returns false if identity doesn't exist.");
|
|
equal(cis.remove(1), true, "cis.remove() returns true if identity exists.");
|
|
|
|
equal(cis.getPublicIdentities().length, 4, "Expected 4 containers.");
|
|
});
|
|
|
|
// Update an identity
|
|
add_task(function() {
|
|
ok(!!cis.getPublicIdentityFromId(2), "Identity 2 exists");
|
|
|
|
equal(cis.update(-1, "Container", "Icon", "Color"), false, "Update returns true if everything is OK");
|
|
|
|
equal(cis.update(2, "Container", "Icon", "Color"), true, "Update returns true if everything is OK");
|
|
|
|
ok(!!cis.getPublicIdentityFromId(2), "Identity exists");
|
|
equal(cis.getPublicIdentityFromId(2).name, "Container", "Identity name is OK");
|
|
equal(cis.getPublicIdentityFromId(2).icon, "Icon", "Identity icon is OK");
|
|
equal(cis.getPublicIdentityFromId(2).color, "Color", "Identity color is OK");
|
|
equal(cis.getUserContextLabel(2), "Container", "Identity label is OK");
|
|
});
|