Skip to content

Commit

Permalink
Bug 1830809 - Convert JS modules in browser/components/syncedtabs to …
Browse files Browse the repository at this point in the history
…ES module r=webdriver-reviewers,Standard8,whimboo

Differential Revision: https://phabricator.services.mozilla.com/D178368
  • Loading branch information
kpatenio committed May 23, 2023
1 parent de10bf9 commit 75bab3b
Show file tree
Hide file tree
Showing 17 changed files with 50 additions and 124 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,8 @@
* 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/. */

"use strict";

var EXPORTED_SYMBOLS = ["EventEmitter"];

// Simple event emitter abstraction for storage objects to use.
function EventEmitter() {
export function EventEmitter() {
this._events = new Map();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,47 +2,21 @@
* 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/. */

"use strict";

const { XPCOMUtils } = ChromeUtils.importESModule(
"resource://gre/modules/XPCOMUtils.sys.mjs"
);

const { SyncedTabsDeckStore } = ChromeUtils.import(
"resource:///modules/syncedtabs/SyncedTabsDeckStore.js"
);
const { SyncedTabsDeckView } = ChromeUtils.import(
"resource:///modules/syncedtabs/SyncedTabsDeckView.js"
);
const { SyncedTabsListStore } = ChromeUtils.import(
"resource:///modules/syncedtabs/SyncedTabsListStore.js"
);
const { TabListComponent } = ChromeUtils.import(
"resource:///modules/syncedtabs/TabListComponent.js"
);
const { TabListView } = ChromeUtils.import(
"resource:///modules/syncedtabs/TabListView.js"
);
let { getChromeWindow } = ChromeUtils.import(
"resource:///modules/syncedtabs/util.js"
);
const { UIState } = ChromeUtils.importESModule(
"resource://services-sync/UIState.sys.mjs"
);

let log = ChromeUtils.importESModule(
"resource://gre/modules/Log.sys.mjs"
).Log.repository.getLogger("Sync.RemoteTabs");

var EXPORTED_SYMBOLS = ["SyncedTabsDeckComponent"];
import { SyncedTabsDeckStore } from "resource:///modules/syncedtabs/SyncedTabsDeckStore.sys.mjs";
import { SyncedTabsDeckView } from "resource:///modules/syncedtabs/SyncedTabsDeckView.sys.mjs";
import { SyncedTabsListStore } from "resource:///modules/syncedtabs/SyncedTabsListStore.sys.mjs";
import { TabListComponent } from "resource:///modules/syncedtabs/TabListComponent.sys.mjs";
import { TabListView } from "resource:///modules/syncedtabs/TabListView.sys.mjs";
import { getChromeWindow } from "resource:///modules/syncedtabs/util.sys.mjs";
import { UIState } from "resource://services-sync/UIState.sys.mjs";

/* SyncedTabsDeckComponent
* This component instantiates views and storage objects as well as defines
* behaviors that will be passed down to the views. This helps keep the views
* isolated and easier to test.
*/

function SyncedTabsDeckComponent({
export function SyncedTabsDeckComponent({
window,
SyncedTabs,
deckStore,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,7 @@
* 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/. */

"use strict";

let { EventEmitter } = ChromeUtils.import(
"resource:///modules/syncedtabs/EventEmitter.jsm"
);

var EXPORTED_SYMBOLS = ["SyncedTabsDeckStore"];
import { EventEmitter } from "resource:///modules/syncedtabs/EventEmitter.sys.mjs";

/**
* SyncedTabsDeckStore
Expand All @@ -19,7 +13,7 @@ var EXPORTED_SYMBOLS = ["SyncedTabsDeckStore"];
* will have `isUpdatable` set to true so the view can skip rerendering the whole
* DOM.
*/
function SyncedTabsDeckStore() {
export function SyncedTabsDeckStore() {
EventEmitter.call(this);
this._panels = [];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,6 @@
* 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/. */

"use strict";

let log = ChromeUtils.importESModule(
"resource://gre/modules/Log.sys.mjs"
).Log.repository.getLogger("Sync.RemoteTabs");

var EXPORTED_SYMBOLS = ["SyncedTabsDeckView"];

/**
* SyncedTabsDeckView
*
Expand All @@ -18,7 +10,7 @@ var EXPORTED_SYMBOLS = ["SyncedTabsDeckView"];
* rerender unless the state flags `isUpdatable`, which helps
* make small changes without the overhead of a full rerender.
*/
const SyncedTabsDeckView = function (window, tabListComponent, props) {
export const SyncedTabsDeckView = function (window, tabListComponent, props) {
this.props = props;

this._window = window;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,7 @@
* 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/. */

"use strict";

let { EventEmitter } = ChromeUtils.import(
"resource:///modules/syncedtabs/EventEmitter.jsm"
);

var EXPORTED_SYMBOLS = ["SyncedTabsListStore"];
import { EventEmitter } from "resource:///modules/syncedtabs/EventEmitter.sys.mjs";

/**
* SyncedTabsListStore
Expand All @@ -17,7 +11,7 @@ var EXPORTED_SYMBOLS = ["SyncedTabsListStore"];
* The state includes the clients, their tabs, the row that is currently selected,
* and the filtered query.
*/
function SyncedTabsListStore(SyncedTabs) {
export function SyncedTabsListStore(SyncedTabs) {
EventEmitter.call(this);
this._SyncedTabs = SyncedTabs;
this.data = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@
* 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/. */

"use strict";

const { XPCOMUtils } = ChromeUtils.importESModule(
"resource://gre/modules/XPCOMUtils.sys.mjs"
);
import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs";

let log = ChromeUtils.importESModule(
"resource://gre/modules/Log.sys.mjs"
Expand All @@ -18,8 +14,6 @@ XPCOMUtils.defineLazyModuleGetters(lazy, {
OpenInTabsUtils: "resource:///modules/OpenInTabsUtils.jsm",
});

var EXPORTED_SYMBOLS = ["TabListComponent"];

/**
* TabListComponent
*
Expand All @@ -29,7 +23,7 @@ var EXPORTED_SYMBOLS = ["TabListComponent"];
* to state changes so it can rerender.
*/

function TabListComponent({
export function TabListComponent({
window,
store,
View,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,13 @@
* 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/. */

"use strict";

const lazy = {};

ChromeUtils.defineESModuleGetters(lazy, {
PrivateBrowsingUtils: "resource://gre/modules/PrivateBrowsingUtils.sys.mjs",
});

let { getChromeWindow } = ChromeUtils.import(
"resource:///modules/syncedtabs/util.js"
);

let log = ChromeUtils.importESModule(
"resource://gre/modules/Log.sys.mjs"
).Log.repository.getLogger("Sync.RemoteTabs");

var EXPORTED_SYMBOLS = ["TabListView"];
import { getChromeWindow } from "resource:///modules/syncedtabs/util.sys.mjs";

function getContextMenu(window) {
return getChromeWindow(window).document.getElementById(
Expand All @@ -40,7 +30,7 @@ function getTabsFilterContextMenu(window) {
* and triggers actions that may cause the state to change and
* ultimately the view to rerender.
*/
function TabListView(window, props) {
export function TabListView(window, props) {
this.props = props;

this._window = window;
Expand Down
16 changes: 8 additions & 8 deletions browser/components/syncedtabs/moz.build
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ BROWSER_CHROME_MANIFESTS += ["test/browser/browser.ini"]
XPCSHELL_TESTS_MANIFESTS += ["test/xpcshell/xpcshell.ini"]

EXTRA_JS_MODULES.syncedtabs += [
"EventEmitter.jsm",
"SyncedTabsDeckComponent.js",
"SyncedTabsDeckStore.js",
"SyncedTabsDeckView.js",
"SyncedTabsListStore.js",
"TabListComponent.js",
"TabListView.js",
"util.js",
"EventEmitter.sys.mjs",
"SyncedTabsDeckComponent.sys.mjs",
"SyncedTabsDeckStore.sys.mjs",
"SyncedTabsDeckView.sys.mjs",
"SyncedTabsListStore.sys.mjs",
"TabListComponent.sys.mjs",
"TabListView.sys.mjs",
"util.sys.mjs",
]

with Files("**"):
Expand Down
4 changes: 2 additions & 2 deletions browser/components/syncedtabs/sidebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
const { SyncedTabs } = ChromeUtils.importESModule(
"resource://services-sync/SyncedTabs.sys.mjs"
);
const { SyncedTabsDeckComponent } = ChromeUtils.import(
"resource:///modules/syncedtabs/SyncedTabsDeckComponent.js"
const { SyncedTabsDeckComponent } = ChromeUtils.importESModule(
"resource:///modules/syncedtabs/SyncedTabsDeckComponent.sys.mjs"
);

var syncedTabsDeckComponent = new SyncedTabsDeckComponent({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"use strict";

let { EventEmitter } = ChromeUtils.import(
"resource:///modules/syncedtabs/EventEmitter.jsm"
let { EventEmitter } = ChromeUtils.importESModule(
"resource:///modules/syncedtabs/EventEmitter.sys.mjs"
);

add_task(async function testSingleListener() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
let { SyncedTabs } = ChromeUtils.importESModule(
"resource://services-sync/SyncedTabs.sys.mjs"
);
let { SyncedTabsDeckComponent } = ChromeUtils.import(
"resource:///modules/syncedtabs/SyncedTabsDeckComponent.js"
let { SyncedTabsDeckComponent } = ChromeUtils.importESModule(
"resource:///modules/syncedtabs/SyncedTabsDeckComponent.sys.mjs"
);
let { SyncedTabsListStore } = ChromeUtils.import(
"resource:///modules/syncedtabs/SyncedTabsListStore.js"
let { SyncedTabsListStore } = ChromeUtils.importESModule(
"resource:///modules/syncedtabs/SyncedTabsListStore.sys.mjs"
);
let { SyncedTabsDeckStore } = ChromeUtils.import(
"resource:///modules/syncedtabs/SyncedTabsDeckStore.js"
let { SyncedTabsDeckStore } = ChromeUtils.importESModule(
"resource:///modules/syncedtabs/SyncedTabsDeckStore.sys.mjs"
);
const { UIState } = ChromeUtils.importESModule(
"resource://services-sync/UIState.sys.mjs"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"use strict";

let { SyncedTabsDeckStore } = ChromeUtils.import(
"resource:///modules/syncedtabs/SyncedTabsDeckStore.js"
let { SyncedTabsDeckStore } = ChromeUtils.importESModule(
"resource:///modules/syncedtabs/SyncedTabsDeckStore.sys.mjs"
);

add_task(async function testSelectUnkownPanel() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
let { SyncedTabs } = ChromeUtils.importESModule(
"resource://services-sync/SyncedTabs.sys.mjs"
);
let { SyncedTabsListStore } = ChromeUtils.import(
"resource:///modules/syncedtabs/SyncedTabsListStore.js"
let { SyncedTabsListStore } = ChromeUtils.importESModule(
"resource:///modules/syncedtabs/SyncedTabsListStore.sys.mjs"
);

const FIXTURE = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
let { SyncedTabs } = ChromeUtils.importESModule(
"resource://services-sync/SyncedTabs.sys.mjs"
);
let { TabListComponent } = ChromeUtils.import(
"resource:///modules/syncedtabs/TabListComponent.js"
let { TabListComponent } = ChromeUtils.importESModule(
"resource:///modules/syncedtabs/TabListComponent.sys.mjs"
);
let { SyncedTabsListStore } = ChromeUtils.import(
"resource:///modules/syncedtabs/SyncedTabsListStore.js"
let { SyncedTabsListStore } = ChromeUtils.importESModule(
"resource:///modules/syncedtabs/SyncedTabsListStore.sys.mjs"
);

const ACTION_METHODS = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@
* 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/. */

"use strict";

var EXPORTED_SYMBOLS = ["getChromeWindow"];

// Get the chrome (ie, browser) window hosting this content.
function getChromeWindow(window) {
export function getChromeWindow(window) {
return window.browsingContext.topChromeWindow;
}
4 changes: 2 additions & 2 deletions browser/modules/webrtcUI.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ var EXPORTED_SYMBOLS = [
"MacOSWebRTCStatusbarIndicator",
];

const { EventEmitter } = ChromeUtils.import(
"resource:///modules/syncedtabs/EventEmitter.jsm"
const { EventEmitter } = ChromeUtils.importESModule(
"resource:///modules/syncedtabs/EventEmitter.sys.mjs"
);
const { XPCOMUtils } = ChromeUtils.importESModule(
"resource://gre/modules/XPCOMUtils.sys.mjs"
Expand Down
10 changes: 3 additions & 7 deletions remote/shared/listeners/NetworkListener.sys.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,15 @@
* 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/. */

import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs";

const lazy = {};

ChromeUtils.defineESModuleGetters(lazy, {
NetworkEventRecord:
"chrome://remote/content/shared/listeners/NetworkEventRecord.sys.mjs",
EventEmitter: "resource://gre/modules/EventEmitter.sys.mjs",
NetworkObserver:
"resource://devtools/shared/network-observer/NetworkObserver.sys.mjs",
});

XPCOMUtils.defineLazyModuleGetters(lazy, {
EventEmitter: "resource://gre/modules/EventEmitter.jsm",
NetworkEventRecord:
"chrome://remote/content/shared/listeners/NetworkEventRecord.sys.mjs",
});

/**
Expand Down

0 comments on commit 75bab3b

Please sign in to comment.