fixed linting
This commit is contained in:
parent
76e884aee2
commit
c575d00aad
7 changed files with 40 additions and 37 deletions
|
@ -7,6 +7,7 @@ module.exports = {
|
|||
"badge": true,
|
||||
"backgroundLogic": true,
|
||||
"identityState": true,
|
||||
"messageHandler": true
|
||||
"messageHandler": true,
|
||||
"sync": true
|
||||
}
|
||||
};
|
||||
|
|
|
@ -66,6 +66,7 @@ const assignManager = {
|
|||
this.setExempted(pageUrlorUrlKey, tabId);
|
||||
});
|
||||
}
|
||||
// eslint-disable-next-line require-atomic-updates
|
||||
data.identityMacAddonUUID =
|
||||
await identityState.lookupMACaddonUUID(data.userContextId);
|
||||
await this.area.set({
|
||||
|
@ -124,7 +125,7 @@ const assignManager = {
|
|||
for(const configKey of Object.keys(macConfigs)) {
|
||||
if (configKey.includes("siteContainerMap@@_")) {
|
||||
const cookieStoreId =
|
||||
"firefox-container-" + macConfigs[configKey].userContextId;
|
||||
"firefox-container-" + macConfigs[configKey].userContextId;
|
||||
const match = identitiesList.find(
|
||||
localIdentity => localIdentity.cookieStoreId === cookieStoreId
|
||||
);
|
||||
|
|
|
@ -14,11 +14,11 @@
|
|||
]
|
||||
-->
|
||||
<script type="text/javascript" src="backgroundLogic.js"></script>
|
||||
<script type="text/javascript" src="sync.js"></script>
|
||||
<script type="text/javascript" src="assignManager.js"></script>
|
||||
<script type="text/javascript" src="badge.js"></script>
|
||||
<script type="text/javascript" src="identityState.js"></script>
|
||||
<script type="text/javascript" src="messageHandler.js"></script>
|
||||
<script type="text/javascript" src="sync.js"></script>
|
||||
<script type="text/javascript" src="test.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -160,10 +160,10 @@ const sync = {
|
|||
sync.storageArea.onChangedListener
|
||||
);
|
||||
|
||||
const hasCIListener = await hasContextualIdentityListeners();
|
||||
const hasCIListener = await sync.hasContextualIdentityListeners();
|
||||
|
||||
if (!hasCIListener) {
|
||||
await addContextualIdentityListeners();
|
||||
await sync.addContextualIdentityListeners();
|
||||
}
|
||||
|
||||
if (!hasStorageListener) {
|
||||
|
@ -178,10 +178,10 @@ const sync = {
|
|||
sync.storageArea.onChangedListener
|
||||
);
|
||||
|
||||
const hasCIListener = await hasContextualIdentityListeners();
|
||||
const hasCIListener = await sync.hasContextualIdentityListeners();
|
||||
|
||||
if (hasCIListener) {
|
||||
await removeContextualIdentityListeners();
|
||||
await sync.removeContextualIdentityListeners();
|
||||
}
|
||||
|
||||
if (hasStorageListener) {
|
||||
|
@ -210,6 +210,30 @@ const sync = {
|
|||
await sync.storageArea.backup();
|
||||
return;
|
||||
},
|
||||
|
||||
async addContextualIdentityListeners(listenerList) {
|
||||
if(!listenerList) listenerList = syncCIListenerList;
|
||||
await browser.contextualIdentities.onCreated.addListener(listenerList[0]);
|
||||
await browser.contextualIdentities.onRemoved.addListener(listenerList[1]);
|
||||
await browser.contextualIdentities.onUpdated.addListener(listenerList[2]);
|
||||
},
|
||||
|
||||
async removeContextualIdentityListeners(listenerList) {
|
||||
if(!listenerList) listenerList = syncCIListenerList;
|
||||
await browser.contextualIdentities.onCreated.removeListener(listenerList[0]);
|
||||
await browser.contextualIdentities.onRemoved.removeListener(listenerList[1]);
|
||||
await browser.contextualIdentities.onUpdated.removeListener(listenerList[2]);
|
||||
},
|
||||
|
||||
async hasContextualIdentityListeners(listenerList) {
|
||||
if(!listenerList) listenerList = syncCIListenerList;
|
||||
return (
|
||||
await browser.contextualIdentities.onCreated.hasListener(listenerList[0]) &&
|
||||
await browser.contextualIdentities.onRemoved.hasListener(listenerList[1]) &&
|
||||
await browser.contextualIdentities.onUpdated.hasListener(listenerList[2])
|
||||
);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
sync.init();
|
||||
|
@ -381,7 +405,7 @@ async function reconcileSiteAssignments() {
|
|||
const deletedSiteList =
|
||||
await sync.storageArea.getDeletedSiteList();
|
||||
for(const siteStoreKey of deletedSiteList) {
|
||||
if (assignedSitesLocal.hasOwnProperty(siteStoreKey)) {
|
||||
if (Object.prototype.hasOwnProperty.call(assignedSitesLocal,siteStoreKey)) {
|
||||
assignManager
|
||||
.storageArea
|
||||
.remove(siteStoreKey.replace(/^siteContainerMap@@_/, "https://"));
|
||||
|
@ -416,6 +440,7 @@ async function setAssignmentWithUUID (assignedSite, urlKey) {
|
|||
const uuid = assignedSite.identityMacAddonUUID;
|
||||
const cookieStoreId = await identityState.lookupCookieStoreId(uuid);
|
||||
if (cookieStoreId) {
|
||||
// eslint-disable-next-line require-atomic-updates
|
||||
assignedSite.userContextId = cookieStoreId
|
||||
.replace(/^firefox-container-/, "");
|
||||
await assignManager.storageArea.set(
|
||||
|
@ -434,26 +459,3 @@ const syncCIListenerList = [
|
|||
sync.storageArea.addToDeletedList,
|
||||
sync.storageArea.backup
|
||||
];
|
||||
|
||||
async function addContextualIdentityListeners(listenerList) {
|
||||
if(!listenerList) listenerList = syncCIListenerList;
|
||||
await browser.contextualIdentities.onCreated.addListener(listenerList[0]);
|
||||
await browser.contextualIdentities.onRemoved.addListener(listenerList[1]);
|
||||
await browser.contextualIdentities.onUpdated.addListener(listenerList[2]);
|
||||
}
|
||||
|
||||
async function removeContextualIdentityListeners(listenerList) {
|
||||
if(!listenerList) listenerList = syncCIListenerList;
|
||||
await browser.contextualIdentities.onCreated.removeListener(listenerList[0]);
|
||||
await browser.contextualIdentities.onRemoved.removeListener(listenerList[1]);
|
||||
await browser.contextualIdentities.onUpdated.removeListener(listenerList[2]);
|
||||
}
|
||||
|
||||
async function hasContextualIdentityListeners(listenerList) {
|
||||
if(!listenerList) listenerList = syncCIListenerList;
|
||||
return (
|
||||
await browser.contextualIdentities.onCreated.hasListener(listenerList[0]) &&
|
||||
await browser.contextualIdentities.onRemoved.hasListener(listenerList[1]) &&
|
||||
await browser.contextualIdentities.onUpdated.hasListener(listenerList[2])
|
||||
);
|
||||
}
|
||||
|
|
|
@ -365,12 +365,12 @@ browser.tests = {
|
|||
|
||||
async stopSyncListeners() {
|
||||
await browser.storage.onChanged.removeListener(sync.storageArea.onChangedListener);
|
||||
await removeContextualIdentityListeners();
|
||||
await sync.removeContextualIdentityListeners();
|
||||
},
|
||||
|
||||
async startListeners() {
|
||||
await browser.storage.onChanged.addListener(sync.storageArea.onChangedListener);
|
||||
await addContextualIdentityListeners();
|
||||
await sync.addContextualIdentityListeners();
|
||||
},
|
||||
|
||||
};
|
||||
|
|
|
@ -27,7 +27,9 @@ describe("External Webextensions", () => {
|
|||
const answer = await promise;
|
||||
expect(answer.userContextId === "1").to.be.true;
|
||||
expect(answer.neverAsk === false).to.be.true;
|
||||
expect(answer.hasOwnProperty("identityMacAddonUUID")).to.be.true;
|
||||
expect(
|
||||
Object.prototype.hasOwnProperty.call(
|
||||
answer, "identityMacAddonUUID")).to.be.true;
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
describe("Sync", () => {
|
||||
|
||||
it("should init sync on startup", async () => {
|
||||
console.log("!!!a")
|
||||
const tab = await helper.browser.initializeWithTab();
|
||||
console.log(await background.browser.storage.local.get());
|
||||
const mozContainer = await background.browser.contextualIdentities.create({
|
||||
|
@ -54,7 +53,6 @@ describe("Sync", () => {
|
|||
});
|
||||
}
|
||||
}));
|
||||
console.log("!!!c");
|
||||
await background.browser.runtime.onStartup.addListener.yield();
|
||||
await nextTick();
|
||||
|
||||
|
@ -62,7 +60,6 @@ describe("Sync", () => {
|
|||
console.log(await background.browser.storage.local.get());
|
||||
|
||||
expect(sync.identities.length).to.equal(5);
|
||||
console.log("!!!b");
|
||||
});
|
||||
|
||||
});
|
Loading…
Add table
Reference in a new issue