Recording - minor fix to popup.js ('0' is a valid tabId), plus whitespace fixes
This commit is contained in:
parent
30a2601d35
commit
46fe530f62
4 changed files with 40 additions and 36 deletions
|
@ -420,7 +420,7 @@ const assignManager = {
|
||||||
const tab = await browser.tabs.get(tabId);
|
const tab = await browser.tabs.get(tabId);
|
||||||
this.calculateContextMenu(tab);
|
this.calculateContextMenu(tab);
|
||||||
},
|
},
|
||||||
|
|
||||||
async _getAssignment(tab) {
|
async _getAssignment(tab) {
|
||||||
const cookieStore = this.getUserContextIdFromCookieStore(tab);
|
const cookieStore = this.getUserContextIdFromCookieStore(tab);
|
||||||
// Ensure we have a cookieStore to assign to
|
// Ensure we have a cookieStore to assign to
|
||||||
|
@ -430,11 +430,11 @@ const assignManager = {
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
|
|
||||||
_getByContainer(userContextId) {
|
_getByContainer(userContextId) {
|
||||||
return this.storageArea.getByContainer(userContextId);
|
return this.storageArea.getByContainer(userContextId);
|
||||||
},
|
},
|
||||||
|
|
||||||
removeContextMenu() {
|
removeContextMenu() {
|
||||||
// There is a focus issue in this menu where if you change window with a context menu click
|
// There is a focus issue in this menu where if you change window with a context menu click
|
||||||
// you get the wrong menu display because of async
|
// you get the wrong menu display because of async
|
||||||
|
|
|
@ -7,7 +7,7 @@ const backgroundLogic = {
|
||||||
"about:blank"
|
"about:blank"
|
||||||
]),
|
]),
|
||||||
unhideQueue: [],
|
unhideQueue: [],
|
||||||
|
|
||||||
async getExtensionInfo() {
|
async getExtensionInfo() {
|
||||||
const manifestPath = browser.extension.getURL("manifest.json");
|
const manifestPath = browser.extension.getURL("manifest.json");
|
||||||
const response = await fetch(manifestPath);
|
const response = await fetch(manifestPath);
|
||||||
|
@ -93,7 +93,7 @@ const backgroundLogic = {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
asPromise(value) {
|
asPromise(value) {
|
||||||
if (value === undefined) { return value; }
|
if (value === undefined) { return value; }
|
||||||
if (value instanceof Promise) { return value; }
|
if (value instanceof Promise) { return value; }
|
||||||
|
@ -115,7 +115,7 @@ const backgroundLogic = {
|
||||||
} catch(e) { /* Assume tabId is invalid */ }
|
} catch(e) { /* Assume tabId is invalid */ }
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
},
|
},
|
||||||
|
|
||||||
async getTabs(options) {
|
async getTabs(options) {
|
||||||
const requiredArguments = ["cookieStoreId", "windowId"];
|
const requiredArguments = ["cookieStoreId", "windowId"];
|
||||||
|
@ -371,4 +371,4 @@ const backgroundLogic = {
|
||||||
}
|
}
|
||||||
return returnValue;
|
return returnValue;
|
||||||
}
|
}
|
||||||
};
|
};
|
|
@ -3,7 +3,7 @@ const messageHandler = {
|
||||||
// We use this to catch redirected tabs that have just opened
|
// We use this to catch redirected tabs that have just opened
|
||||||
// If this were in platform we would change how the tab opens based on "new tab" link navigations such as ctrl+click
|
// If this were in platform we would change how the tab opens based on "new tab" link navigations such as ctrl+click
|
||||||
LAST_CREATED_TAB_TIMER: 2000,
|
LAST_CREATED_TAB_TIMER: 2000,
|
||||||
|
|
||||||
init() {
|
init() {
|
||||||
// Handles messages from webextension code
|
// Handles messages from webextension code
|
||||||
browser.runtime.onMessage.addListener((m) => {
|
browser.runtime.onMessage.addListener((m) => {
|
||||||
|
@ -80,7 +80,6 @@ const messageHandler = {
|
||||||
response = backgroundLogic.asPromise(backgroundLogic.invokeBrowserMethod(m.name, m.args));
|
response = backgroundLogic.asPromise(backgroundLogic.invokeBrowserMethod(m.name, m.args));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return response;
|
return response;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -264,32 +263,36 @@ const messageHandler = {
|
||||||
} while (!succeeded);
|
} while (!succeeded);
|
||||||
}
|
}
|
||||||
|
|
||||||
handleTabChangedStatus(status) {
|
handleTabStatusLoading() {
|
||||||
if (status === "loading") {
|
if (!this.tabLoading) {
|
||||||
if (!this.tabLoading) {
|
this.tabLoading = {};
|
||||||
this.tabLoading = {};
|
this.tabLoading.promise = new Promise((resolve) => {
|
||||||
this.tabLoading.promise = new Promise((resolve) => {
|
this.tabLoading.resolve = resolve;
|
||||||
this.tabLoading.resolve = resolve;
|
});
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
if (this.tabLoading) {
|
handleTabStatusComplete() {
|
||||||
this.tabLoading.resolve();
|
if (this.tabLoading) {
|
||||||
this.tabLoading = null;
|
this.tabLoading.resolve();
|
||||||
}
|
this.tabLoading = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
handleTabRemoved() {
|
handleTabRemoved() {
|
||||||
this.tabRemoved = true;
|
this.tabRemoved = true;
|
||||||
this.removeTabListeners();
|
this.removeTabListeners();
|
||||||
this.handleTabChangedStatus("complete");
|
this.handleTabStatusComplete();
|
||||||
}
|
}
|
||||||
|
|
||||||
addTabListeners() {
|
addTabListeners() {
|
||||||
this.onTabsUpdated = (eventTabId, info) => {
|
this.onTabsUpdated = (eventTabId, info) => {
|
||||||
if (this.tabId === eventTabId) {
|
if (this.tabId === eventTabId) {
|
||||||
this.handleTabChangedStatus(info.status);
|
if (info.status === "loading") {
|
||||||
|
this.handleTabStatusLoading();
|
||||||
|
} else {
|
||||||
|
this.handleTabStatusComplete();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -81,7 +81,7 @@ const Env = {
|
||||||
this.tabId = parseInt(tabId, 10);
|
this.tabId = parseInt(tabId, 10);
|
||||||
this.isBrowserActionPopup = false;
|
this.isBrowserActionPopup = false;
|
||||||
} else {
|
} else {
|
||||||
this.tabId = null;
|
this.tabId = -1;
|
||||||
this.isBrowserActionPopup = this.hasFullBrowserAPI;
|
this.isBrowserActionPopup = this.hasFullBrowserAPI;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -106,15 +106,16 @@ const Logic = {
|
||||||
|
|
||||||
// API methods are ready, can continue with init
|
// API methods are ready, can continue with init
|
||||||
const initializingPanels = this.initializePanels();
|
const initializingPanels = this.initializePanels();
|
||||||
|
|
||||||
// Retrieve the list of identities.
|
// Retrieve the list of identities.
|
||||||
const identitiesPromise = this.refreshIdentities();
|
const identitiesPromise = this.refreshIdentities();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await identitiesPromise;
|
await identitiesPromise;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
throw new Error("Failed to retrieve the identities or variation. We cannot continue. ", e.message);
|
throw new Error("Failed to retrieve the identities or variation. We cannot continue. ", e.message);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove browserAction "upgraded" badge when opening panel
|
// Remove browserAction "upgraded" badge when opening panel
|
||||||
const clearingBadge = this.clearBrowserActionBadge();
|
const clearingBadge = this.clearBrowserActionBadge();
|
||||||
|
|
||||||
|
@ -175,7 +176,7 @@ const Logic = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
// Used when popup is running within iframe on a webpage, so lacks privileged API
|
// Used when popup is running within iframe on a webpage, so lacks privileged API
|
||||||
async injectAPI() {
|
async injectAPI() {
|
||||||
const script = document.createElement("script");
|
const script = document.createElement("script");
|
||||||
|
@ -257,7 +258,7 @@ const Logic = {
|
||||||
},
|
},
|
||||||
|
|
||||||
async currentTab() {
|
async currentTab() {
|
||||||
if (Env.tabId) {
|
if (Env.tabId >= 0) {
|
||||||
return await browser.tabs.get(Env.tabId);
|
return await browser.tabs.get(Env.tabId);
|
||||||
} else {
|
} else {
|
||||||
const activeTabs = await browser.tabs.query({ active: true, windowId: browser.windows.WINDOW_ID_CURRENT });
|
const activeTabs = await browser.tabs.query({ active: true, windowId: browser.windows.WINDOW_ID_CURRENT });
|
||||||
|
@ -267,7 +268,7 @@ const Logic = {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
async numTabs() {
|
async numTabs() {
|
||||||
const activeTabs = await browser.tabs.query({ windowId: browser.windows.WINDOW_ID_CURRENT });
|
const activeTabs = await browser.tabs.query({ windowId: browser.windows.WINDOW_ID_CURRENT });
|
||||||
return activeTabs.length;
|
return activeTabs.length;
|
||||||
|
@ -732,19 +733,19 @@ Logic.registerPanel(P_CONTAINERS_LIST, {
|
||||||
|
|
||||||
if (!isEnabled) {
|
if (!isEnabled) {
|
||||||
recordIconElement.src = CONTAINER_RECORD_DISABLED_SRC;
|
recordIconElement.src = CONTAINER_RECORD_DISABLED_SRC;
|
||||||
recordLinkElement.classList.remove("active");
|
recordLinkElement.classList.remove("active");
|
||||||
recordLinkElement.classList.add("disabled");
|
recordLinkElement.classList.add("disabled");
|
||||||
} else {
|
} else {
|
||||||
recordIconElement.src = CONTAINER_RECORD_ENABLED_SRC;
|
recordIconElement.src = CONTAINER_RECORD_ENABLED_SRC;
|
||||||
recordLinkElement.classList.remove("disabled");
|
recordLinkElement.classList.remove("disabled");
|
||||||
if (isActive) {
|
if (isActive) {
|
||||||
recordLinkElement.classList.add("active");
|
recordLinkElement.classList.add("active");
|
||||||
} else {
|
} else {
|
||||||
recordLinkElement.classList.remove("active");
|
recordLinkElement.classList.remove("active");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
async prepareCurrentTabHeader() {
|
async prepareCurrentTabHeader() {
|
||||||
const currentTab = await Logic.currentTab();
|
const currentTab = await Logic.currentTab();
|
||||||
const currentTabElement = document.getElementById("current-tab");
|
const currentTabElement = document.getElementById("current-tab");
|
||||||
|
@ -774,7 +775,7 @@ Logic.registerPanel(P_CONTAINERS_LIST, {
|
||||||
try { await showingPanel; } catch (e) { /* Ignore show error, as we're immediately going to change panel */ }
|
try { await showingPanel; } catch (e) { /* Ignore show error, as we're immediately going to change panel */ }
|
||||||
Logic.showPanel(P_CONTAINERS_LIST);
|
Logic.showPanel(P_CONTAINERS_LIST);
|
||||||
throw new Error("Failed to " + (newRecordingTab ? "start" : "stop") + " recording: " + e.message);
|
throw new Error("Failed to " + (newRecordingTab ? "start" : "stop") + " recording: " + e.message);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
currentTabElement.hidden = !currentTab;
|
currentTabElement.hidden = !currentTab;
|
||||||
this.setupAssignmentCheckbox(false, currentTabUserContextId);
|
this.setupAssignmentCheckbox(false, currentTabUserContextId);
|
||||||
|
@ -1339,7 +1340,7 @@ Logic.registerPanel(P_CONTAINER_RECORD, {
|
||||||
const editPanel = Logic.getPanel(P_CONTAINER_EDIT);
|
const editPanel = Logic.getPanel(P_CONTAINER_EDIT);
|
||||||
editPanel.showAssignedContainers(assignments, { elementId: "record-sites-assigned", sticky: true });
|
editPanel.showAssignedContainers(assignments, { elementId: "record-sites-assigned", sticky: true });
|
||||||
|
|
||||||
return Promise.resolve(null);
|
return Promise.resolve(null);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue