Recording - whitespace fixes
This commit is contained in:
parent
9dfdadbc63
commit
7a43e06767
4 changed files with 27 additions and 27 deletions
|
@ -116,7 +116,7 @@ const assignManager = {
|
||||||
this.storageArea.setExempted(pageUrl, m.tabId);
|
this.storageArea.setExempted(pageUrl, m.tabId);
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
|
|
||||||
_determineSetAssignmentDueToRecording(tabId, url, siteSettings) {
|
_determineSetAssignmentDueToRecording(tabId, url, siteSettings) {
|
||||||
if (siteSettings) { return false; } // Assignment already set
|
if (siteSettings) { return false; } // Assignment already set
|
||||||
if (!recordManager.isRecordingTabId(tabId)) { return false; }
|
if (!recordManager.isRecordingTabId(tabId)) { return false; }
|
||||||
|
@ -148,12 +148,12 @@ const assignManager = {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
const userContextId = this.getUserContextIdFromCookieStore(tab);
|
const userContextId = this.getUserContextIdFromCookieStore(tab);
|
||||||
|
|
||||||
// Recording
|
// Recording
|
||||||
if (this._determineSetAssignmentDueToRecording(tab.id, options.url, siteSettings)) {
|
if (this._determineSetAssignmentDueToRecording(tab.id, options.url, siteSettings)) {
|
||||||
await this._setOrRemoveAssignment(tab.id, options.url, userContextId, false);
|
await this._setOrRemoveAssignment(tab.id, options.url, userContextId, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!siteSettings
|
if (!siteSettings
|
||||||
|| userContextId === siteSettings.userContextId
|
|| userContextId === siteSettings.userContextId
|
||||||
|| this.storageArea.isExempted(options.url, tab.id)) {
|
|| 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
|
// Context menu has stored context IDs as strings, so we need to coerce
|
||||||
// the value to a string for accurate checking
|
// the value to a string for accurate checking
|
||||||
userContextId = String(userContextId);
|
userContextId = String(userContextId);
|
||||||
|
|
||||||
if (!remove) {
|
if (!remove) {
|
||||||
const tabs = await browser.tabs.query({});
|
const tabs = await browser.tabs.query({});
|
||||||
const assignmentStoreKey = this.storageArea.getSiteStoreKey(pageUrl);
|
const assignmentStoreKey = this.storageArea.getSiteStoreKey(pageUrl);
|
||||||
|
|
|
@ -99,14 +99,14 @@ const backgroundLogic = {
|
||||||
if (value instanceof Promise) { return value; }
|
if (value instanceof Promise) { return value; }
|
||||||
return Promise.resolve(value);
|
return Promise.resolve(value);
|
||||||
},
|
},
|
||||||
|
|
||||||
asTabId(tabId) {
|
asTabId(tabId) {
|
||||||
if (tabId === undefined || tabId === null) {
|
if (tabId === undefined || tabId === null) {
|
||||||
return browser.tabs.TAB_ID_NONE;
|
return browser.tabs.TAB_ID_NONE;
|
||||||
}
|
}
|
||||||
return tabId;
|
return tabId;
|
||||||
},
|
},
|
||||||
|
|
||||||
async getTabOrNull(tabId) {
|
async getTabOrNull(tabId) {
|
||||||
tabId = this.asTabId(tabId);
|
tabId = this.asTabId(tabId);
|
||||||
if (tabId !== browser.tabs.TAB_ID_NONE) {
|
if (tabId !== browser.tabs.TAB_ID_NONE) {
|
||||||
|
@ -353,7 +353,7 @@ const backgroundLogic = {
|
||||||
cookieStoreId(userContextId) {
|
cookieStoreId(userContextId) {
|
||||||
return `firefox-container-${userContextId}`;
|
return `firefox-container-${userContextId}`;
|
||||||
},
|
},
|
||||||
|
|
||||||
async invokeBrowserMethod(name, args) {
|
async invokeBrowserMethod(name, args) {
|
||||||
let target = browser;
|
let target = browser;
|
||||||
let indexOfDot;
|
let indexOfDot;
|
||||||
|
|
|
@ -82,10 +82,10 @@ const messageHandler = {
|
||||||
}
|
}
|
||||||
return response;
|
return response;
|
||||||
});
|
});
|
||||||
|
|
||||||
// Monitor browserAction popup
|
// Monitor browserAction popup
|
||||||
this.browserAction.init();
|
this.browserAction.init();
|
||||||
|
|
||||||
// Handles external messages from webextensions
|
// Handles external messages from webextensions
|
||||||
const externalExtensionAllowed = {};
|
const externalExtensionAllowed = {};
|
||||||
browser.runtime.onMessageExternal.addListener(async (message, sender) => {
|
browser.runtime.onMessageExternal.addListener(async (message, sender) => {
|
||||||
|
@ -226,7 +226,7 @@ const messageHandler = {
|
||||||
throw e;
|
throw e;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Sends a message to a tab, with following benefits:
|
Sends a message to a tab, with following benefits:
|
||||||
1. Waits until sending AND animating is fully complete
|
1. Waits until sending AND animating is fully complete
|
||||||
|
@ -254,7 +254,7 @@ const messageHandler = {
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (this.tabRemoved) { break; }
|
if (this.tabRemoved) { break; }
|
||||||
if (attempts >= MAX_ATTEMPTS) { throw e; }
|
if (attempts >= MAX_ATTEMPTS) { throw e; }
|
||||||
|
|
||||||
attempts++;
|
attempts++;
|
||||||
await new Promise((resolve) => {
|
await new Promise((resolve) => {
|
||||||
setTimeout(resolve, 1000);
|
setTimeout(resolve, 1000);
|
||||||
|
@ -262,7 +262,7 @@ const messageHandler = {
|
||||||
}
|
}
|
||||||
} while (!succeeded);
|
} while (!succeeded);
|
||||||
}
|
}
|
||||||
|
|
||||||
handleTabStatusLoading() {
|
handleTabStatusLoading() {
|
||||||
if (!this.tabLoading) {
|
if (!this.tabLoading) {
|
||||||
this.tabLoading = {};
|
this.tabLoading = {};
|
||||||
|
@ -271,20 +271,20 @@ const messageHandler = {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
handleTabStatusComplete() {
|
handleTabStatusComplete() {
|
||||||
if (this.tabLoading) {
|
if (this.tabLoading) {
|
||||||
this.tabLoading.resolve();
|
this.tabLoading.resolve();
|
||||||
this.tabLoading = null;
|
this.tabLoading = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
handleTabRemoved() {
|
handleTabRemoved() {
|
||||||
this.tabRemoved = true;
|
this.tabRemoved = true;
|
||||||
this.removeTabListeners();
|
this.removeTabListeners();
|
||||||
this.handleTabStatusComplete();
|
this.handleTabStatusComplete();
|
||||||
}
|
}
|
||||||
|
|
||||||
addTabListeners() {
|
addTabListeners() {
|
||||||
this.onTabsUpdated = (eventTabId, info) => {
|
this.onTabsUpdated = (eventTabId, info) => {
|
||||||
if (this.tabId === eventTabId) {
|
if (this.tabId === eventTabId) {
|
||||||
|
@ -295,27 +295,27 @@ const messageHandler = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
this.onTabsRemoved = (eventTabId) => {
|
this.onTabsRemoved = (eventTabId) => {
|
||||||
if (this.tabId === eventTabId) {
|
if (this.tabId === eventTabId) {
|
||||||
this.handleTabRemoved();
|
this.handleTabRemoved();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
browser.tabs.onUpdated.addListener(this.onTabsUpdated, { tabId: this.tabId, properties:["status"] });
|
browser.tabs.onUpdated.addListener(this.onTabsUpdated, { tabId: this.tabId, properties:["status"] });
|
||||||
browser.tabs.onRemoved.addListener(this.onTabsRemoved);
|
browser.tabs.onRemoved.addListener(this.onTabsRemoved);
|
||||||
}
|
}
|
||||||
|
|
||||||
removeTabListeners() {
|
removeTabListeners() {
|
||||||
browser.tabs.onUpdated.removeListener(this.onTabsUpdated);
|
browser.tabs.onUpdated.removeListener(this.onTabsUpdated);
|
||||||
browser.tabs.onRemoved.removeListener(this.onTabsRemoved);
|
browser.tabs.onRemoved.removeListener(this.onTabsRemoved);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
async sendTabMessage(tabId, message) {
|
async sendTabMessage(tabId, message) {
|
||||||
const tab = await backgroundLogic.getTabOrNull(tabId);
|
const tab = await backgroundLogic.getTabOrNull(tabId);
|
||||||
if (!tab || tab.id === browser.tabs.TAB_ID_NONE) { throw new Error(`Cannot send message to tab ${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);
|
const sendMessage = new this.SendTabMessage(tabId, message);
|
||||||
sendMessage.addTabListeners();
|
sendMessage.addTabListeners();
|
||||||
try {
|
try {
|
||||||
|
@ -327,7 +327,7 @@ const messageHandler = {
|
||||||
sendMessage.removeTabListeners();
|
sendMessage.removeTabListeners();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
// Holds current browserAction popup state, dispatches events
|
// Holds current browserAction popup state, dispatches events
|
||||||
browserAction: {
|
browserAction: {
|
||||||
init() {
|
init() {
|
||||||
|
@ -336,7 +336,7 @@ const messageHandler = {
|
||||||
this.onLoad(port);
|
this.onLoad(port);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
browser.windows.onFocusChanged.addListener((windowId) => {
|
browser.windows.onFocusChanged.addListener((windowId) => {
|
||||||
this.currentWindowId = windowId;
|
this.currentWindowId = windowId;
|
||||||
});
|
});
|
||||||
|
@ -345,9 +345,9 @@ const messageHandler = {
|
||||||
// Note a new connection can arrive before existing connection is disconnected.
|
// Note a new connection can arrive before existing connection is disconnected.
|
||||||
// Happens when you click on the browserAction button on two different windows
|
// Happens when you click on the browserAction button on two different windows
|
||||||
if (this.popup) { this.onUnload(); }
|
if (this.popup) { this.onUnload(); }
|
||||||
|
|
||||||
const popup = this.popup = { windowId: this.currentWindowId };
|
const popup = this.popup = { windowId: this.currentWindowId };
|
||||||
|
|
||||||
port.onDisconnect.addListener(() => {
|
port.onDisconnect.addListener(() => {
|
||||||
if (this.popup === popup) {
|
if (this.popup === popup) {
|
||||||
this.onUnload();
|
this.onUnload();
|
||||||
|
@ -359,7 +359,7 @@ const messageHandler = {
|
||||||
this.onUpdate(popup, msg.update);
|
this.onUpdate(popup, msg.update);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
window.dispatchEvent(new Event("BrowserActionPopupLoad"));
|
window.dispatchEvent(new Event("BrowserActionPopupLoad"));
|
||||||
},
|
},
|
||||||
onUnload() {
|
onUnload() {
|
||||||
|
|
|
@ -21,7 +21,7 @@ module.exports = {
|
||||||
window.browser.storage.local.set.resetHistory();
|
window.browser.storage.local.set.resetHistory();
|
||||||
window.browser.runtime.connect.returns({
|
window.browser.runtime.connect.returns({
|
||||||
postMessage: sinon.stub()
|
postMessage: sinon.stub()
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,7 @@ module.exports = {
|
||||||
async openNewTab(tab, options = {}) {
|
async openNewTab(tab, options = {}) {
|
||||||
return background.browser.tabs._create(tab, options);
|
return background.browser.tabs._create(tab, options);
|
||||||
},
|
},
|
||||||
|
|
||||||
async browseToURL(tabId, url) {
|
async browseToURL(tabId, url) {
|
||||||
const [promise] = background.browser.webRequest.onBeforeRequest.addListener.yield({
|
const [promise] = background.browser.webRequest.onBeforeRequest.addListener.yield({
|
||||||
frameId: 0,
|
frameId: 0,
|
||||||
|
|
Loading…
Add table
Reference in a new issue