Recording - whitespace fixes

This commit is contained in:
Francis McKenzie 2021-02-15 17:33:14 +01:00
parent 9dfdadbc63
commit 7a43e06767
4 changed files with 27 additions and 27 deletions

View file

@ -116,7 +116,7 @@ const assignManager = {
this.storageArea.setExempted(pageUrl, m.tabId);
return true;
},
_determineSetAssignmentDueToRecording(tabId, url, siteSettings) {
if (siteSettings) { return false; } // Assignment already set
if (!recordManager.isRecordingTabId(tabId)) { return false; }
@ -148,12 +148,12 @@ const assignManager = {
return {};
}
const userContextId = this.getUserContextIdFromCookieStore(tab);
// Recording
if (this._determineSetAssignmentDueToRecording(tab.id, options.url, siteSettings)) {
await this._setOrRemoveAssignment(tab.id, options.url, userContextId, false);
}
if (!siteSettings
|| userContextId === siteSettings.userContextId
|| this.storageArea.isExempted(options.url, tab.id)) {
@ -387,7 +387,7 @@ const assignManager = {
// Context menu has stored context IDs as strings, so we need to coerce
// the value to a string for accurate checking
userContextId = String(userContextId);
if (!remove) {
const tabs = await browser.tabs.query({});
const assignmentStoreKey = this.storageArea.getSiteStoreKey(pageUrl);

View file

@ -99,14 +99,14 @@ const backgroundLogic = {
if (value instanceof Promise) { return value; }
return Promise.resolve(value);
},
asTabId(tabId) {
if (tabId === undefined || tabId === null) {
return browser.tabs.TAB_ID_NONE;
}
return tabId;
},
async getTabOrNull(tabId) {
tabId = this.asTabId(tabId);
if (tabId !== browser.tabs.TAB_ID_NONE) {
@ -353,7 +353,7 @@ const backgroundLogic = {
cookieStoreId(userContextId) {
return `firefox-container-${userContextId}`;
},
async invokeBrowserMethod(name, args) {
let target = browser;
let indexOfDot;

View file

@ -82,10 +82,10 @@ const messageHandler = {
}
return response;
});
// Monitor browserAction popup
this.browserAction.init();
// Handles external messages from webextensions
const externalExtensionAllowed = {};
browser.runtime.onMessageExternal.addListener(async (message, sender) => {
@ -226,7 +226,7 @@ const messageHandler = {
throw e;
});
},
/**
Sends a message to a tab, with following benefits:
1. Waits until sending AND animating is fully complete
@ -254,7 +254,7 @@ const messageHandler = {
} catch (e) {
if (this.tabRemoved) { break; }
if (attempts >= MAX_ATTEMPTS) { throw e; }
attempts++;
await new Promise((resolve) => {
setTimeout(resolve, 1000);
@ -262,7 +262,7 @@ const messageHandler = {
}
} while (!succeeded);
}
handleTabStatusLoading() {
if (!this.tabLoading) {
this.tabLoading = {};
@ -271,20 +271,20 @@ const messageHandler = {
});
}
}
handleTabStatusComplete() {
if (this.tabLoading) {
this.tabLoading.resolve();
this.tabLoading = null;
}
}
handleTabRemoved() {
this.tabRemoved = true;
this.removeTabListeners();
this.handleTabStatusComplete();
}
addTabListeners() {
this.onTabsUpdated = (eventTabId, info) => {
if (this.tabId === eventTabId) {
@ -295,27 +295,27 @@ const messageHandler = {
}
}
};
this.onTabsRemoved = (eventTabId) => {
if (this.tabId === eventTabId) {
this.handleTabRemoved();
}
};
browser.tabs.onUpdated.addListener(this.onTabsUpdated, { tabId: this.tabId, properties:["status"] });
browser.tabs.onRemoved.addListener(this.onTabsRemoved);
}
removeTabListeners() {
browser.tabs.onUpdated.removeListener(this.onTabsUpdated);
browser.tabs.onRemoved.removeListener(this.onTabsRemoved);
}
},
async sendTabMessage(tabId, message) {
const tab = await backgroundLogic.getTabOrNull(tabId);
if (!tab || tab.id === browser.tabs.TAB_ID_NONE) { throw new Error(`Cannot send message to tab ${tabId}`); }
const sendMessage = new this.SendTabMessage(tabId, message);
sendMessage.addTabListeners();
try {
@ -327,7 +327,7 @@ const messageHandler = {
sendMessage.removeTabListeners();
}
},
// Holds current browserAction popup state, dispatches events
browserAction: {
init() {
@ -336,7 +336,7 @@ const messageHandler = {
this.onLoad(port);
}
});
browser.windows.onFocusChanged.addListener((windowId) => {
this.currentWindowId = windowId;
});
@ -345,9 +345,9 @@ const messageHandler = {
// Note a new connection can arrive before existing connection is disconnected.
// Happens when you click on the browserAction button on two different windows
if (this.popup) { this.onUnload(); }
const popup = this.popup = { windowId: this.currentWindowId };
port.onDisconnect.addListener(() => {
if (this.popup === popup) {
this.onUnload();
@ -359,7 +359,7 @@ const messageHandler = {
this.onUpdate(popup, msg.update);
}
});
window.dispatchEvent(new Event("BrowserActionPopupLoad"));
},
onUnload() {

View file

@ -21,7 +21,7 @@ module.exports = {
window.browser.storage.local.set.resetHistory();
window.browser.runtime.connect.returns({
postMessage: sinon.stub()
});
});
}
}
}
@ -33,7 +33,7 @@ module.exports = {
async openNewTab(tab, options = {}) {
return background.browser.tabs._create(tab, options);
},
async browseToURL(tabId, url) {
const [promise] = background.browser.webRequest.onBeforeRequest.addListener.yield({
frameId: 0,