diff --git a/src/panel.js b/src/panel.js index abb186ff..159b35b3 100644 --- a/src/panel.js +++ b/src/panel.js @@ -141,7 +141,7 @@ const isSiteInContainer = async(panelId) => { const activeRootDomain = await getActiveRootDomainFromBackground(); - if (addedSitesList.includes(activeRootDomain)) { + if (addedSitesList && addedSitesList.includes(activeRootDomain)) { return true; } }; @@ -345,7 +345,7 @@ document.addEventListener("DOMContentLoaded", async () => { const storage = await browser.storage.local.get(); const currentPanel = storage.CURRENT_PANEL; - const onboarding = (currentPanel.includes("onboarding")); + const onboarding = (currentPanel && currentPanel.includes("onboarding")); if (!onboarding) { return buildPanel(currentPanel); } diff --git a/test/features/add-domain-to-fbc.test.js b/test/features/add-domain-to-fbc.test.js index e8d59de1..4dd2fd97 100644 --- a/test/features/add-domain-to-fbc.test.js +++ b/test/features/add-domain-to-fbc.test.js @@ -31,6 +31,8 @@ describe("Add domain to Facebook Container", () => { removeDomain: "example.com" }); + await sleep(); + const [promise] = await background.browser.runtime.onMessage.addListener.yield({message: "what-sites-are-added"}); const sites = await promise; expect(sites.includes("example.com")).to.be.false; @@ -39,3 +41,7 @@ describe("Add domain to Facebook Container", () => { }); }); + +async function sleep(ms = 100) { + return new Promise((resolve) => setTimeout(resolve, ms)); +}