forked from mirrors/gecko-dev
Bug 1893319 - Allow preferences to be created which will create "fake" synced tabs for all devices. r=Gijs
Differential Revision: https://phabricator.services.mozilla.com/D208552
This commit is contained in:
parent
619edd4cf2
commit
7db0b50460
1 changed files with 38 additions and 1 deletions
|
|
@ -2,6 +2,8 @@
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
|
import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs";
|
||||||
|
|
||||||
const lazy = {};
|
const lazy = {};
|
||||||
|
|
||||||
ChromeUtils.defineESModuleGetters(lazy, {
|
ChromeUtils.defineESModuleGetters(lazy, {
|
||||||
|
|
@ -40,6 +42,21 @@ ChromeUtils.defineLazyGetter(lazy, "log", () => {
|
||||||
return log;
|
return log;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// We allow some test preferences to simulate many and inactive tabs.
|
||||||
|
XPCOMUtils.defineLazyPreferenceGetter(
|
||||||
|
lazy,
|
||||||
|
"NUM_FAKE_INACTIVE_TABS",
|
||||||
|
"services.sync.syncedTabs.numFakeInactiveTabs",
|
||||||
|
0
|
||||||
|
);
|
||||||
|
|
||||||
|
XPCOMUtils.defineLazyPreferenceGetter(
|
||||||
|
lazy,
|
||||||
|
"NUM_FAKE_ACTIVE_TABS",
|
||||||
|
"services.sync.syncedTabs.numFakeActiveTabs",
|
||||||
|
0
|
||||||
|
);
|
||||||
|
|
||||||
// A private singleton that does the work.
|
// A private singleton that does the work.
|
||||||
let SyncedTabsInternal = {
|
let SyncedTabsInternal = {
|
||||||
/* Make a "tab" record. Returns a promise */
|
/* Make a "tab" record. Returns a promise */
|
||||||
|
|
@ -143,7 +160,27 @@ let SyncedTabsInternal = {
|
||||||
let clientRepr = await this._makeClient(client);
|
let clientRepr = await this._makeClient(client);
|
||||||
lazy.log.debug("Processing client", clientRepr);
|
lazy.log.debug("Processing client", clientRepr);
|
||||||
|
|
||||||
for (let tab of client.tabs) {
|
let tabs = Array.from(client.tabs); // avoid modifying in-place.
|
||||||
|
// For QA, UX, etc, we allow "fake tabs" to be added to each device.
|
||||||
|
for (let i = 0; i < lazy.NUM_FAKE_INACTIVE_TABS; i++) {
|
||||||
|
tabs.push({
|
||||||
|
icon: null,
|
||||||
|
lastUsed: 1000,
|
||||||
|
title: `Fake inactive tab ${i}`,
|
||||||
|
urlHistory: [`https://example.com/inactive/${i}`],
|
||||||
|
inactive: true,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
for (let i = 0; i < lazy.NUM_FAKE_ACTIVE_TABS; i++) {
|
||||||
|
tabs.push({
|
||||||
|
icon: null,
|
||||||
|
lastUsed: Date.now() - 1000 + i,
|
||||||
|
title: `Fake tab ${i}`,
|
||||||
|
urlHistory: [`https://example.com/${i}`],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
for (let tab of tabs) {
|
||||||
let url = tab.urlHistory[0];
|
let url = tab.urlHistory[0];
|
||||||
lazy.log.trace("remote tab", url);
|
lazy.log.trace("remote tab", url);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue