Feature test container sync initialization
This commit is contained in:
parent
07af32af92
commit
4bcb908942
2 changed files with 70 additions and 0 deletions
66
test/features/sync.test.js
Normal file
66
test/features/sync.test.js
Normal file
|
@ -0,0 +1,66 @@
|
||||||
|
describe("Sync", () => {
|
||||||
|
let tab;
|
||||||
|
beforeEach(async () => {
|
||||||
|
tab = await helper.browser.initializeWithTab();
|
||||||
|
});
|
||||||
|
|
||||||
|
it.only("should init sync on startup", async () => {
|
||||||
|
const mozContainer = await background.browser.contextualIdentities.create({
|
||||||
|
name: "Mozilla",
|
||||||
|
color: "red",
|
||||||
|
icon: "briefcase",
|
||||||
|
});
|
||||||
|
|
||||||
|
await background.browser.contextualIdentities.update("firefox-container-2", {color:"purple"});
|
||||||
|
await background.browser.contextualIdentities.update("firefox-container-4", {icon:"pet"});
|
||||||
|
|
||||||
|
await Promise.all([
|
||||||
|
{
|
||||||
|
userContextId: "1",
|
||||||
|
url: "https://twitter.com",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
userContextId: "2",
|
||||||
|
url: "https://www.facebook.com",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
userContextId: "4",
|
||||||
|
url: "https://www.linkedin.com",
|
||||||
|
neverAsk: true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
userContextId: mozContainer.cookieStoreId.replace("firefox-container-", ""),
|
||||||
|
url: "https://developer.mozilla.org",
|
||||||
|
neverAsk: true,
|
||||||
|
}
|
||||||
|
].map(async (assign) => {
|
||||||
|
await background.browser.tabs.update(tab.id, {
|
||||||
|
cookieStoreId: `firefox-container-${assign.userContextId}`
|
||||||
|
});
|
||||||
|
|
||||||
|
await background.browser.runtime.onMessage.addListener.yield({
|
||||||
|
method: "setOrRemoveAssignment",
|
||||||
|
tabId: tab.id,
|
||||||
|
url: assign.url,
|
||||||
|
userContextId: assign.userContextId,
|
||||||
|
value: !true
|
||||||
|
});
|
||||||
|
|
||||||
|
if (assign.neverAsk) {
|
||||||
|
await nextTick();
|
||||||
|
await background.browser.runtime.onMessage.addListener.yield({
|
||||||
|
method: "neverAsk",
|
||||||
|
neverAsk: true,
|
||||||
|
pageUrl: assign.url,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
|
||||||
|
await background.browser.runtime.onStartup.addListener.yield();
|
||||||
|
await nextTick();
|
||||||
|
|
||||||
|
const sync = await background.browser.storage.sync.get();
|
||||||
|
|
||||||
|
expect(sync.identities.length).to.equal(5);
|
||||||
|
});
|
||||||
|
});
|
|
@ -5,6 +5,7 @@ if (!process.listenerCount("unhandledRejection")) {
|
||||||
const path = require("path");
|
const path = require("path");
|
||||||
const chai = require("chai");
|
const chai = require("chai");
|
||||||
const sinonChai = require("sinon-chai");
|
const sinonChai = require("sinon-chai");
|
||||||
|
const crypto = require("crypto");
|
||||||
global.sinon = require("sinon");
|
global.sinon = require("sinon");
|
||||||
global.expect = chai.expect;
|
global.expect = chai.expect;
|
||||||
chai.should();
|
chai.should();
|
||||||
|
@ -29,6 +30,9 @@ global.buildDom = async ({background = {}, popup = {}}) => {
|
||||||
...background.jsom,
|
...background.jsom,
|
||||||
beforeParse(window) {
|
beforeParse(window) {
|
||||||
window.browser.permissions.getAll.resolves({permissions: ["bookmarks"]});
|
window.browser.permissions.getAll.resolves({permissions: ["bookmarks"]});
|
||||||
|
window.crypto = {
|
||||||
|
getRandomValues: arr => crypto.randomBytes(arr.length),
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Reference in a new issue