Bug 1632922 - use const instead of let - eslint --fix r=snorp

This commit was generated by running `./mach eslint --fix`.

Differential Revision: https://phabricator.services.mozilla.com/D72412
This commit is contained in:
Agi Sferro 2020-04-24 21:53:17 +00:00
parent cef279c2d6
commit dff7aa5d42
44 changed files with 328 additions and 323 deletions

View File

@ -20,13 +20,13 @@ var EXPORTED_SYMBOLS = ["GeckoViewContentChild"];
class GeckoViewContentChild extends GeckoViewActorChild {
collectSessionState() {
const { docShell, contentWindow } = this;
let history = SessionHistory.collect(docShell);
const history = SessionHistory.collect(docShell);
let formdata = SessionStoreUtils.collectFormData(contentWindow);
let scrolldata = SessionStoreUtils.collectScrollPosition(contentWindow);
// Save the current document resolution.
let zoom = 1;
let domWindowUtils = contentWindow.windowUtils;
const domWindowUtils = contentWindow.windowUtils;
zoom = domWindowUtils.getResolution();
scrolldata = scrolldata || {};
scrolldata.zoom = {};
@ -34,8 +34,8 @@ class GeckoViewContentChild extends GeckoViewActorChild {
// Save some data that'll help in adjusting the zoom level
// when restoring in a different screen orientation.
let displaySize = {};
let width = {},
const displaySize = {};
const width = {},
height = {};
domWindowUtils.getContentViewerSize(width, height);

View File

@ -67,7 +67,7 @@ class WebBrowserChromeChild extends GeckoViewActorChild {
// nsIWebBrowserChrome
shouldLoadURIInThisProcess(aURI) {
debug`shouldLoadURIInThisProcess ${aURI.displaySpec}`;
let remoteSubframes = this.docShell.nsILoadContext.useRemoteSubframes;
const remoteSubframes = this.docShell.nsILoadContext.useRemoteSubframes;
return E10SUtils.shouldLoadURIInThisProcess(aURI, remoteSubframes);
}

View File

@ -135,7 +135,7 @@ class GeckoViewContentChild extends GeckoViewChildModule {
}
this.triggerViewportFitChange = content.requestIdleCallback(() => {
this.triggerViewportFitChange = null;
let viewportFit = content.windowUtils.getViewportFitInfo();
const viewportFit = content.windowUtils.getViewportFitInfo();
if (this.lastViewportFit === viewportFit) {
return;
}
@ -163,9 +163,9 @@ class GeckoViewContentChild extends GeckoViewChildModule {
}
break;
case "GeckoView:ZoomToInput": {
let dwu = content.windowUtils;
const dwu = content.windowUtils;
let zoomToFocusedInput = function() {
const zoomToFocusedInput = function() {
if (!dwu.flushApzRepaints()) {
dwu.zoomToFocusedInput();
return;
@ -176,10 +176,10 @@ class GeckoViewContentChild extends GeckoViewChildModule {
}, "apz-repaints-flushed");
};
let { force } = aMsg.data;
const { force } = aMsg.data;
let gotResize = false;
let onResize = function() {
const onResize = function() {
gotResize = true;
if (dwu.isMozAfterPaintPending) {
addEventListener(
@ -217,7 +217,7 @@ class GeckoViewContentChild extends GeckoViewChildModule {
this._savedState = { history, formdata, scrolldata };
if (history) {
let restoredHistory = SessionHistory.restore(docShell, history);
const restoredHistory = SessionHistory.restore(docShell, history);
addEventListener(
"load",
@ -241,7 +241,7 @@ class GeckoViewContentChild extends GeckoViewChildModule {
{ capture: true, mozSystemGroup: true, once: true }
);
let scrollRestore = _ => {
const scrollRestore = _ => {
if (content.location != "about:blank") {
if (scrolldata) {
this.Utils.restoreFrameTreeData(
@ -275,7 +275,7 @@ class GeckoViewContentChild extends GeckoViewChildModule {
}
this.progressFilter.addProgressListener(this, this.flags);
let webProgress = docShell
const webProgress = docShell
.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIWebProgress);
webProgress.addProgressListener(this.progressFilter, this.flags);
@ -311,8 +311,8 @@ class GeckoViewContentChild extends GeckoViewChildModule {
);
break;
case "GeckoView:ScrollBy":
let x = {};
let y = {};
const x = {};
const y = {};
content.windowUtils.getVisualViewportOffset(x, y);
content.windowUtils.scrollToVisual(
x.value + this.toPixels(aMsg.data.widthValue, aMsg.data.widthType),
@ -499,7 +499,7 @@ class GeckoViewContentChild extends GeckoViewChildModule {
if (this._savedState) {
const scrolldata = this._savedState.scrolldata;
if (scrolldata && scrolldata.zoom && scrolldata.zoom.displaySize) {
let utils = content.windowUtils;
const utils = content.windowUtils;
// Restore zoom level.
utils.setRestoreResolution(
scrolldata.zoom.resolution,
@ -510,7 +510,7 @@ class GeckoViewContentChild extends GeckoViewChildModule {
}
this.progressFilter.removeProgressListener(this);
let webProgress = docShell
const webProgress = docShell
.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIWebProgress);
webProgress.removeProgressListener(this.progressFilter);

View File

@ -448,7 +448,7 @@ class GeckoViewMediaChild extends GeckoViewChildModule {
}
notifyMediaError(aElement) {
let code = aElement.error ? aElement.error.code : 0;
const code = aElement.error ? aElement.error.code : 0;
this.eventDispatcher.sendRequest({
type: "GeckoView:MediaError",
id: this.getState(aElement).id,

View File

@ -138,7 +138,7 @@ const ProgressTracker = {
this._tracking = true;
this.clear();
let data = this._data;
const data = this._data;
if (aUri === "about:blank") {
data.uri = null;
@ -155,7 +155,7 @@ const ProgressTracker = {
changeLocation(aUri) {
debug`ProgressTracker changeLocation ${aUri}`;
let data = this._data;
const data = this._data;
data.locationChange = true;
data.uri = aUri;
},
@ -163,7 +163,7 @@ const ProgressTracker = {
stop() {
debug`ProgressTracker stop`;
let data = this._data;
const data = this._data;
data.pageStop = true;
this.updateProgress();
this._tracking = false;
@ -197,7 +197,7 @@ const ProgressTracker = {
},
handleEvent(aEvent) {
let data = this._data;
const data = this._data;
const target = aEvent.originalTarget;
const uri = target && target.location.href;
@ -271,7 +271,7 @@ const ProgressTracker = {
updateProgress() {
debug`ProgressTracker updateProgress`;
let data = this._data;
const data = this._data;
if (!this._tracking || !data.uri) {
return;

View File

@ -27,7 +27,7 @@ class GeckoViewScrollChild extends GeckoViewChildModule {
switch (aEvent.type) {
case "mozvisualscroll":
let x = {},
const x = {},
y = {};
content.windowUtils.getVisualViewportOffset(x, y);
this.eventDispatcher.sendRequest({

View File

@ -131,7 +131,7 @@ class GeckoViewSelectionActionChild extends GeckoViewChildModule {
offset.left += currentRect.left;
offset.top += currentRect.top;
let targetDocShell = currentWindow.docShell;
const targetDocShell = currentWindow.docShell;
if (targetDocShell.isMozBrowser) {
break;
}
@ -256,7 +256,7 @@ class GeckoViewSelectionActionChild extends GeckoViewChildModule {
warn`Stale response ${response.id}`;
return;
}
let action = actions.find(action => action.id === response.id);
const action = actions.find(action => action.id === response.id);
if (action) {
debug`Performing ${response.id}`;
action.perform.call(this, aEvent, response);

View File

@ -86,7 +86,7 @@ class StateChangeNotifier extends Handler {
* @param method (string)
*/
notifyObservers(method) {
for (let obs of this._observers) {
for (const obs of this._observers) {
if (typeof obs[method] == "function") {
obs[method]();
}
@ -199,7 +199,7 @@ class SessionHistoryListener extends Handler {
return null;
}
let history = SessionHistory.collect(this.mm.docShell, this._fromIdx);
const history = SessionHistory.collect(this.mm.docShell, this._fromIdx);
this._fromIdx = NO_INDEX;
return history;
});
@ -567,9 +567,9 @@ class MessageQueue extends Handler {
this.cleanupTimers();
let data = {};
for (let [key, func] of this._data) {
let value = func();
const data = {};
for (const [key, func] of this._data) {
const value = func();
if (value || (key != "storagechange" && key != "historychange")) {
data[key] = value;
@ -633,7 +633,7 @@ class SessionStateAggregator extends GeckoViewChildModule {
// the parent and flush all data currently held in the child.
this.messageQueue.send({ isFinal: true });
for (let handler of this.handlers) {
for (const handler of this.handlers) {
if (handler.uninit) {
handler.uninit();
}

View File

@ -91,7 +91,7 @@ var NewPrefDialog = {
}
// If item already in list, it's being changed, else added
let item = AboutConfig._list.filter(i => {
const item = AboutConfig._list.filter(i => {
return i.name == aPrefName;
});
if (item.length) {
@ -221,13 +221,13 @@ var AboutConfig = {
this._prefsContainer = document.getElementById("prefs-container");
this._loadingContainer = document.getElementById("loading-container");
let list = Services.prefs.getChildList("");
const list = Services.prefs.getChildList("");
this._list = list.sort().map(function AC_getMapPref(aPref) {
return new Pref(aPref);
}, this);
// Support filtering about:config via a ?filter=<string> param
let match = /[?&]filter=([^&]+)/i.exec(window.location.href);
const match = /[?&]filter=([^&]+)/i.exec(window.location.href);
if (match) {
this.filterInput.value = decodeURIComponent(match[1]);
}
@ -290,7 +290,7 @@ var AboutConfig = {
// Clear the displayed preferences list
_clearPrefsContainer: function AC_clearPrefsContainer() {
// Quick clear the prefsContainer list
let empty = this._prefsContainer.cloneNode(false);
const empty = this._prefsContainer.cloneNode(false);
this._prefsContainer.parentNode.replaceChild(empty, this._prefsContainer);
this._prefsContainer = empty;
@ -303,12 +303,12 @@ var AboutConfig = {
// Get a small manageable block of prefs items, and add them to the displayed list
_addMorePrefsToContainer: function AC_addMorePrefsToContainer() {
// Create filter regex
let filterExp = this.filterInput.value
const filterExp = this.filterInput.value
? new RegExp(this.filterInput.value, "i")
: null;
// Get a new block for the display list
let prefsBuffer = [];
const prefsBuffer = [];
for (
let i = 0;
i < this._list.length && prefsBuffer.length < PREFS_BUFFER_MAX;
@ -363,7 +363,7 @@ var AboutConfig = {
// Set list item node as selected
set selected(aSelection) {
let currentSelection = this.selected;
const currentSelection = this.selected;
if (aSelection == currentSelection) {
return;
}
@ -400,14 +400,14 @@ var AboutConfig = {
// Return a pref of a list item node
_getPrefForNode: function AC_getPrefForNode(aNode) {
let pref = aNode.getAttribute("name");
const pref = aNode.getAttribute("name");
return new Pref(pref);
},
// When list item name or value are tapped
selectOrToggleBoolPref: function AC_selectOrToggleBoolPref(aEvent) {
let node = this.getLINodeForEvent(aEvent);
const node = this.getLINodeForEvent(aEvent);
// If not already selected, just do so
if (this.selected != node) {
@ -416,7 +416,7 @@ var AboutConfig = {
}
// If already selected, and value is boolean, toggle it
let pref = this._getPrefForNode(node);
const pref = this._getPrefForNode(node);
if (pref.type != Services.prefs.PREF_BOOL) {
return;
}
@ -426,10 +426,10 @@ var AboutConfig = {
// When finalizing list input values due to blur
setIntOrStringPref: function AC_setIntOrStringPref(aEvent) {
let node = this.getLINodeForEvent(aEvent);
const node = this.getLINodeForEvent(aEvent);
// Skip if locked
let pref = this._getPrefForNode(node);
const pref = this._getPrefForNode(node);
if (pref.locked) {
return;
}
@ -445,7 +445,7 @@ var AboutConfig = {
// When we reset a pref to it's default value (note resetting a user created pref will delete it)
resetDefaultPref: function AC_resetDefaultPref(aEvent) {
let node = this.getLINodeForEvent(aEvent);
const node = this.getLINodeForEvent(aEvent);
// If not already selected, do so
if (this.selected != node) {
@ -453,7 +453,7 @@ var AboutConfig = {
}
// Reset will handle any locked condition
let pref = this._getPrefForNode(node);
const pref = this._getPrefForNode(node);
pref.reset();
// Ensure pref reset flushed to disk immediately
@ -462,10 +462,10 @@ var AboutConfig = {
// When we want to toggle a bool pref
toggleBoolPref: function AC_toggleBoolPref(aEvent) {
let node = this.getLINodeForEvent(aEvent);
const node = this.getLINodeForEvent(aEvent);
// Skip if locked, or not boolean
let pref = this._getPrefForNode(node);
const pref = this._getPrefForNode(node);
if (pref.locked) {
return;
}
@ -477,10 +477,10 @@ var AboutConfig = {
// When Int inputs have their Up or Down arrows toggled
incrOrDecrIntPref: function AC_incrOrDecrIntPref(aEvent, aInt) {
let node = this.getLINodeForEvent(aEvent);
const node = this.getLINodeForEvent(aEvent);
// Skip if locked
let pref = this._getPrefForNode(node);
const pref = this._getPrefForNode(node);
if (pref.locked) {
return;
}
@ -490,7 +490,7 @@ var AboutConfig = {
// Observe preference changes
observe: function AC_observe(aSubject, aTopic, aPrefName) {
let pref = new Pref(aPrefName);
const pref = new Pref(aPrefName);
// Ignore uninteresting changes, and avoid "private" preferences
if (aTopic != "nsPref:changed") {
@ -504,12 +504,12 @@ var AboutConfig = {
}
// If pref onscreen, update in place.
let item = document.querySelector(
const item = document.querySelector(
'.pref-item[name="' + CSS.escape(pref.name) + '"]'
);
if (item) {
item.setAttribute("value", pref.value);
let input = item.querySelector("input");
const input = item.querySelector("input");
input.setAttribute("value", pref.value);
input.value = pref.value;
@ -520,7 +520,7 @@ var AboutConfig = {
}
// If pref not already in list, refresh display as it's being added
let anyWhere = this._list.filter(i => {
const anyWhere = this._list.filter(i => {
return i.name == pref.name;
});
if (!anyWhere.length) {
@ -530,7 +530,7 @@ var AboutConfig = {
// Quick context menu helpers for about:config
clipboardCopy: function AC_clipboardCopy(aField) {
let pref = this._getPrefForNode(this.contextMenuLINode);
const pref = this._getPrefForNode(this.contextMenuLINode);
if (aField == "name") {
gClipboardHelper.copyString(pref.name);
} else {
@ -620,7 +620,7 @@ Pref.prototype = {
this.li.setAttribute("contextmenu", "prefs-context-menu");
let prefName = document.createElement("div");
const prefName = document.createElement("div");
prefName.className = "pref-name";
prefName.addEventListener("click", function(event) {
AboutConfig.selectOrToggleBoolPref(event);
@ -629,10 +629,10 @@ Pref.prototype = {
this.li.appendChild(prefName);
let prefItemLine = document.createElement("div");
const prefItemLine = document.createElement("div");
prefItemLine.className = "pref-item-line";
let prefValue = document.createElement("input");
const prefValue = document.createElement("input");
prefValue.className = "pref-value";
prefValue.addEventListener("blur", function(event) {
AboutConfig.setIntOrStringPref(event);
@ -643,7 +643,7 @@ Pref.prototype = {
prefValue.value = "";
prefItemLine.appendChild(prefValue);
let resetButton = document.createElement("div");
const resetButton = document.createElement("div");
resetButton.className = "pref-button reset";
resetButton.addEventListener("click", function(event) {
AboutConfig.resetDefaultPref(event);
@ -653,7 +653,7 @@ Pref.prototype = {
);
prefItemLine.appendChild(resetButton);
let toggleButton = document.createElement("div");
const toggleButton = document.createElement("div");
toggleButton.className = "pref-button toggle";
toggleButton.addEventListener("click", function(event) {
AboutConfig.toggleBoolPref(event);
@ -663,14 +663,14 @@ Pref.prototype = {
);
prefItemLine.appendChild(toggleButton);
let upButton = document.createElement("div");
const upButton = document.createElement("div");
upButton.className = "pref-button up";
upButton.addEventListener("click", function(event) {
AboutConfig.incrOrDecrIntPref(event, 1);
});
prefItemLine.appendChild(upButton);
let downButton = document.createElement("div");
const downButton = document.createElement("div");
downButton.className = "pref-button down";
downButton.addEventListener("click", function(event) {
AboutConfig.incrOrDecrIntPref(event, -1);
@ -691,7 +691,7 @@ Pref.prototype = {
this.li.setAttribute("type", this.type);
this.li.setAttribute("value", this.value);
let valDiv = this.li.querySelector(".pref-value");
const valDiv = this.li.querySelector(".pref-value");
valDiv.value = this.value;
switch (this.type) {

View File

@ -186,7 +186,7 @@ var ModuleManager = {
}
// Now we're switching the remoteness (value of "remote" attr).
let disabledModules = [];
const disabledModules = [];
this.forEach(module => {
if (module.enabled) {
module.enabled = false;

View File

@ -15,7 +15,7 @@ const getSender = (extension, target, sender) => {
}
if (tabId != null && tabId >= 0) {
let tab = extension.tabManager.get(tabId, null);
const tab = extension.tabManager.get(tabId, null);
if (tab) {
sender.tab = tab.convert();
}

View File

@ -7,12 +7,12 @@ this.tabs = class extends ExtensionAPI {
return {
tabs: {
connect(tabId, options) {
let { frameId = null, name = "" } = options || {};
const { frameId = null, name = "" } = options || {};
return context.messenger.nm.connect({ name, tabId, frameId });
},
sendMessage: function(tabId, message, options, responseCallback) {
let recipient = {
const recipient = {
extensionId: context.extension.id,
tabId: tabId,
};

View File

@ -24,7 +24,7 @@ const getBrowserWindow = window => {
return window.docShell.rootTreeItem.domWindow;
};
let tabListener = {
const tabListener = {
tabReadyInitialized: false,
tabReadyPromises: new WeakMap(),
initializingTabs: new WeakSet(),
@ -50,7 +50,7 @@ let tabListener = {
this.initializingTabs.delete(tab);
// browser.innerWindowID is now set, resolve the promises if any.
let deferred = this.tabReadyPromises.get(tab);
const deferred = this.tabReadyPromises.get(tab);
if (deferred) {
deferred.resolve(tab);
this.tabReadyPromises.delete(tab);
@ -88,9 +88,9 @@ let tabListener = {
this.tabs = class extends ExtensionAPI {
getAPI(context) {
let { extension } = context;
const { extension } = context;
let { tabManager } = extension;
const { tabManager } = extension;
function getTabOrActive(tabId) {
if (tabId !== null) {
@ -117,13 +117,13 @@ this.tabs = class extends ExtensionAPI {
return tab;
}
let self = {
const self = {
tabs: {
onActivated: new EventManager({
context,
name: "tabs.onActivated",
register: fire => {
let listener = (eventName, event) => {
const listener = (eventName, event) => {
const { windowId, tabId, isPrivate } = event;
if (isPrivate && !context.privateBrowsingAllowed) {
return;
@ -146,7 +146,7 @@ this.tabs = class extends ExtensionAPI {
context,
name: "tabs.onCreated",
register: fire => {
let listener = (eventName, event) => {
const listener = (eventName, event) => {
fire.async(tabManager.convert(event.nativeTab));
};
@ -168,7 +168,7 @@ this.tabs = class extends ExtensionAPI {
"tabs.onHighlighted",
"Tab:Selected",
(fire, data) => {
let tab = tabManager.get(data.id);
const tab = tabManager.get(data.id);
fire.async({ tabIds: [tab.id], windowId: tab.windowId });
}
@ -194,7 +194,7 @@ this.tabs = class extends ExtensionAPI {
context,
name: "tabs.onRemoved",
register: fire => {
let listener = (eventName, event) => {
const listener = (eventName, event) => {
fire.async(event.tabId, {
windowId: event.windowId,
isWindowClosing: event.isWindowClosing,
@ -231,9 +231,9 @@ this.tabs = class extends ExtensionAPI {
const restricted = ["url", "favIconUrl", "title"];
function sanitize(extension, changeInfo) {
let result = {};
const result = {};
let nonempty = false;
for (let prop in changeInfo) {
for (const prop in changeInfo) {
if (
extension.hasPermission("tabs") ||
!restricted.includes(prop)
@ -245,15 +245,15 @@ this.tabs = class extends ExtensionAPI {
return [nonempty, result];
}
let fireForTab = (tab, changed) => {
let [needed, changeInfo] = sanitize(extension, changed);
const fireForTab = (tab, changed) => {
const [needed, changeInfo] = sanitize(extension, changed);
if (needed) {
fire.async(tab.id, changeInfo, tab.convert());
}
};
let listener = event => {
let needed = [];
const listener = event => {
const needed = [];
let nativeTab;
switch (event.type) {
case "DOMTitleChanged": {
@ -277,19 +277,19 @@ this.tabs = class extends ExtensionAPI {
return;
}
let tab = tabManager.getWrapper(nativeTab);
let changeInfo = {};
for (let prop of needed) {
const tab = tabManager.getWrapper(nativeTab);
const changeInfo = {};
for (const prop of needed) {
changeInfo[prop] = tab[prop];
}
fireForTab(tab, changeInfo);
};
let statusListener = ({ browser, status, url }) => {
const statusListener = ({ browser, status, url }) => {
const { tab } = browser.ownerGlobal;
if (tab) {
let changed = { status };
const changed = { status };
if (url) {
changed.url = url;
}
@ -433,7 +433,7 @@ this.tabs = class extends ExtensionAPI {
},
async reload(tabId, reloadProperties) {
let nativeTab = getTabOrActive(tabId);
const nativeTab = getTabOrActive(tabId);
let flags = Ci.nsIWebNavigation.LOAD_FLAGS_NONE;
if (reloadProperties && reloadProperties.bypassCache) {
@ -479,31 +479,31 @@ this.tabs = class extends ExtensionAPI {
},
async captureVisibleTab(windowId, options) {
let window =
const window =
windowId == null
? windowTracker.topWindow
: windowTracker.getWindow(windowId, context);
let tab = tabManager.wrapTab(window.tab);
const tab = tabManager.wrapTab(window.tab);
await tabListener.awaitTabReady(tab.nativeTab);
return tab.capture(context, options);
},
async executeScript(tabId, details) {
let tab = await promiseTabWhenReady(tabId);
const tab = await promiseTabWhenReady(tabId);
return tab.executeScript(context, details);
},
async insertCSS(tabId, details) {
let tab = await promiseTabWhenReady(tabId);
const tab = await promiseTabWhenReady(tabId);
return tab.insertCSS(context, details);
},
async removeCSS(tabId, details) {
let tab = await promiseTabWhenReady(tabId);
const tab = await promiseTabWhenReady(tabId);
return tab.removeCSS(context, details);
},

View File

@ -142,21 +142,21 @@ class WindowTracker extends WindowTrackerBase {
}
isBrowserWindow(window) {
let { documentElement } = window.document;
const { documentElement } = window.document;
return documentElement.getAttribute("windowtype") === WINDOW_TYPE;
}
addProgressListener(window, listener) {
let listeners = this.progressListeners.get(window);
const listeners = this.progressListeners.get(window);
if (!listeners.has(listener)) {
let wrapper = new ProgressListenerWrapper(window, listener);
const wrapper = new ProgressListenerWrapper(window, listener);
listeners.set(listener, wrapper);
}
}
removeProgressListener(window, listener) {
let listeners = this.progressListeners.get(window);
let wrapper = listeners.get(listener);
const listeners = this.progressListeners.get(window);
const wrapper = listeners.get(listener);
if (wrapper) {
wrapper.destroy();
listeners.delete(listener);
@ -193,7 +193,7 @@ global.makeGlobalEvent = function makeGlobalEvent(
context,
name,
register: fire => {
let listener2 = {
const listener2 = {
onEvent(event, data, callback) {
listener(fire, data);
},
@ -438,7 +438,7 @@ class TabContext extends EventEmitter {
get(tabId) {
if (!this.tabData.has(tabId)) {
let data = Object.create(this.getDefaultPrototype(tabId));
const data = Object.create(this.getDefaultPrototype(tabId));
this.tabData.set(tabId, data);
}
@ -515,7 +515,7 @@ Object.assign(global, { Tab, TabContext, Window });
class TabManager extends TabManagerBase {
get(tabId, default_ = undefined) {
let nativeTab = tabTracker.getTab(tabId, default_);
const nativeTab = tabTracker.getTab(tabId, default_);
if (nativeTab) {
return this.getWrapper(nativeTab);
@ -545,17 +545,17 @@ class TabManager extends TabManagerBase {
class WindowManager extends WindowManagerBase {
get(windowId, context) {
let window = windowTracker.getWindow(windowId, context);
const window = windowTracker.getWindow(windowId, context);
return this.getWrapper(window);
}
*getAll(context) {
for (let window of windowTracker.browserWindows()) {
for (const window of windowTracker.browserWindows()) {
if (!this.canAccessWindow(window, context)) {
continue;
}
let wrapped = this.getWrapper(window);
const wrapped = this.getWrapper(window);
if (wrapped) {
yield wrapped;
}

View File

@ -15,7 +15,7 @@ var TEST_ICON_ARRAYBUFFER = Uint8Array.from(atob(TEST_ICON_DATA), byte =>
).buffer;
{
let chromeScript = SpecialPowers.loadChromeScript(
const chromeScript = SpecialPowers.loadChromeScript(
SimpleTest.getTestFileURL("chrome_cleanup_script.js")
);
@ -24,7 +24,7 @@ var TEST_ICON_ARRAYBUFFER = Uint8Array.from(atob(TEST_ICON_DATA), byte =>
chromeScript.sendAsyncMessage("check-cleanup");
let results = await chromeScript.promiseOneMessage("cleanup-results");
const results = await chromeScript.promiseOneMessage("cleanup-results");
chromeScript.destroy();
if (results.extraWindows.length || results.extraTabs.length) {

View File

@ -14,7 +14,7 @@
// saveAs is not implemented on Fennec but this tests that a call to download() that supplies that option passes anyway.
add_task(async function testDownload() {
let extension = ExtensionTestUtils.loadExtension({
const extension = ExtensionTestUtils.loadExtension({
manifest: {permissions: ["downloads"]},
background: async function() {

View File

@ -23,10 +23,10 @@ async function waitAboutAddonsRendered(addonId) {
async function navigateToAddonDetails(addonId) {
const item = content.document.querySelector(`div.addon-item[addonID="${addonId}"]`);
let rect = item.getBoundingClientRect();
const rect = item.getBoundingClientRect();
const x = rect.left + rect.width / 2;
const y = rect.top + rect.height / 2;
let domWinUtils = content.window.windowUtils;
const domWinUtils = content.window.windowUtils;
domWinUtils.sendMouseEventToWindow("mousedown", x, y, 0, 1, 0);
domWinUtils.sendMouseEventToWindow("mouseup", x, y, 0, 1, 0);
@ -65,7 +65,7 @@ function waitDOMContentLoaded(checkUrlCb) {
const {BrowserApp} = Services.wm.getMostRecentWindow("navigator:browser");
return new Promise(resolve => {
let listener = (event) => {
const listener = (event) => {
if (checkUrlCb(event.target.defaultView.location.href)) {
BrowserApp.deck.removeEventListener("DOMContentLoaded", listener);
resolve();
@ -89,9 +89,9 @@ function clickAddonEnable() {
}
add_task(async function test_options_ui_iframe_height() {
let addonID = "test-options-ui@mozilla.org";
const addonID = "test-options-ui@mozilla.org";
let extension = ExtensionTestUtils.loadExtension({
const extension = ExtensionTestUtils.loadExtension({
useAddonManager: "temporary",
manifest: {
applications: {
@ -142,7 +142,7 @@ add_task(async function test_options_ui_iframe_height() {
const {BrowserApp} = Services.wm.getMostRecentWindow("navigator:browser");
let onceAboutAddonsLoaded = waitAboutAddonsLoaded();
const onceAboutAddonsLoaded = waitAboutAddonsLoaded();
BrowserApp.addTab("about:addons", {
selected: true,
@ -204,7 +204,7 @@ add_task(async function test_options_ui_iframe_height() {
});
add_task(async function test_options_ui_open_aboutaddons_details() {
let addonID = "test-options-ui-open-addon-details@mozilla.org";
const addonID = "test-options-ui-open-addon-details@mozilla.org";
function background() {
browser.test.onMessage.addListener(msg => {
@ -221,7 +221,7 @@ add_task(async function test_options_ui_open_aboutaddons_details() {
browser.test.sendMessage("options-page-loaded", window.location.href);
}
let extension = ExtensionTestUtils.loadExtension({
const extension = ExtensionTestUtils.loadExtension({
useAddonManager: "temporary",
background,
manifest: {
@ -254,7 +254,7 @@ add_task(async function test_options_ui_open_aboutaddons_details() {
const {BrowserApp} = Services.wm.getMostRecentWindow("navigator:browser");
let onceAboutAddonsLoaded = waitAboutAddonsLoaded();
const onceAboutAddonsLoaded = waitAboutAddonsLoaded();
BrowserApp.addTab("about:addons", {
selected: true,
@ -279,7 +279,7 @@ add_task(async function test_options_ui_open_aboutaddons_details() {
});
add_task(async function test_options_ui_open_in_tab() {
let addonID = "test-options-ui@mozilla.org";
const addonID = "test-options-ui@mozilla.org";
function background() {
browser.test.onMessage.addListener(msg => {
@ -296,7 +296,7 @@ add_task(async function test_options_ui_open_in_tab() {
browser.test.sendMessage("options-page-loaded", window.location.href);
}
let extension = ExtensionTestUtils.loadExtension({
const extension = ExtensionTestUtils.loadExtension({
useAddonManager: "temporary",
background,
manifest: {
@ -330,7 +330,7 @@ add_task(async function test_options_ui_open_in_tab() {
const {BrowserApp} = Services.wm.getMostRecentWindow("navigator:browser");
let onceAboutAddonsLoaded = waitAboutAddonsLoaded();
const onceAboutAddonsLoaded = waitAboutAddonsLoaded();
BrowserApp.selectOrAddTab("about:addons", {
selected: true,
@ -347,7 +347,7 @@ add_task(async function test_options_ui_open_in_tab() {
await SpecialPowers.spawn(aboutAddonsTab.browser, [addonID], waitAboutAddonsRendered);
await SpecialPowers.spawn(aboutAddonsTab.browser, [addonID], navigateToAddonDetails);
let onceAddonOptionsLoaded = waitDOMContentLoaded(url => url.endsWith("options.html"));
const onceAddonOptionsLoaded = waitDOMContentLoaded(url => url.endsWith("options.html"));
info("Click the Options button in the addon details");
await SpecialPowers.spawn(aboutAddonsTab.browser, [], clickAddonOptionButton);
@ -367,11 +367,11 @@ add_task(async function test_options_ui_open_in_tab() {
const waitTabClosed = (nativeTab) => {
return new Promise(resolve => {
let {BrowserApp} = Services.wm.getMostRecentWindow("navigator:browser");
let expectedBrowser = nativeTab.browser;
const {BrowserApp} = Services.wm.getMostRecentWindow("navigator:browser");
const expectedBrowser = nativeTab.browser;
let tabCloseListener = (event) => {
let browser = event.target;
const tabCloseListener = (event) => {
const browser = event.target;
if (browser !== expectedBrowser) {
return;
}
@ -384,8 +384,8 @@ add_task(async function test_options_ui_open_in_tab() {
});
};
let onceOptionsTabClosed = waitTabClosed(addonOptionsTab);
let onceAboutAddonsClosed = waitTabClosed(aboutAddonsTab);
const onceOptionsTabClosed = waitTabClosed(addonOptionsTab);
const onceAboutAddonsClosed = waitTabClosed(aboutAddonsTab);
info("Close the opened about:addons and options tab");
BrowserApp.closeTab(addonOptionsTab);
@ -415,13 +415,13 @@ add_task(async function test_options_ui_on_disable_and_enable() {
/* eslint-disable no-unreachable */
return;
let addonID = "test-options-ui-disable-enable@mozilla.org";
const addonID = "test-options-ui-disable-enable@mozilla.org";
function optionsScript() {
browser.test.sendMessage("options-page-loaded", window.location.href);
}
let extension = ExtensionTestUtils.loadExtension({
const extension = ExtensionTestUtils.loadExtension({
useAddonManager: "temporary",
manifest: {
applications: {
@ -453,7 +453,7 @@ add_task(async function test_options_ui_on_disable_and_enable() {
const {BrowserApp} = Services.wm.getMostRecentWindow("navigator:browser");
let onceAboutAddonsLoaded = waitAboutAddonsLoaded();
const onceAboutAddonsLoaded = waitAboutAddonsLoaded();
BrowserApp.addTab("about:addons", {
selected: true,

View File

@ -13,15 +13,15 @@
"use strict";
add_task(async function() {
let win = window.open("http://mochi.test:8888/");
const win = window.open("http://mochi.test:8888/");
let extension = ExtensionTestUtils.loadExtension({
const extension = ExtensionTestUtils.loadExtension({
manifest: {
"permissions": ["tabs"],
},
background: function() {
let messages_received = [];
const messages_received = [];
let tabId;
@ -54,7 +54,7 @@ add_task(async function() {
files: {
"tab.js": function() {
let port = browser.runtime.connect({name: "tab-connection-name"});
const port = browser.runtime.connect({name: "tab-connection-name"});
port.postMessage("tab to background port message");
port.onMessage.addListener((msg) => {
port.postMessage({tabReceived: msg});

View File

@ -15,7 +15,7 @@
function* runTest(options) {
options.neutral = [0xaa, 0xaa, 0xaa];
let html = `
const html = `
<!DOCTYPE html>
<html lang="en">
<head><meta charset="UTF-8"></head>
@ -31,14 +31,14 @@ function* runTest(options) {
</html>
`;
let url = `data:text/html,${encodeURIComponent(html)}`;
let win = window.open(url);
const url = `data:text/html,${encodeURIComponent(html)}`;
const win = window.open(url);
async function background(options) {
browser.test.log(`Test color ${options.color} at fullZoom=${options.fullZoom}`);
try {
let [tab] = await browser.tabs.query({currentWindow: true, active: true});
const [tab] = await browser.tabs.query({currentWindow: true, active: true});
let [jpeg, png, ...pngs] = await Promise.all([
browser.tabs.captureVisibleTab(tab.windowId, {format: "jpeg", quality: 95}),
@ -52,33 +52,33 @@ function* runTest(options) {
browser.test.assertTrue(jpeg.startsWith("data:image/jpeg;base64,"), "jpeg is JPEG");
browser.test.assertTrue(png.startsWith("data:image/png;base64,"), "png is PNG");
let promises = [jpeg, png].map(url => new Promise(resolve => {
let img = new Image();
const promises = [jpeg, png].map(url => new Promise(resolve => {
const img = new Image();
img.src = url;
img.onload = () => resolve(img);
}));
[jpeg, png] = await Promise.all(promises);
let tabDims = `${tab.width}\u00d7${tab.height}`;
const tabDims = `${tab.width}\u00d7${tab.height}`;
let images = {jpeg, png};
for (let format of Object.keys(images)) {
let img = images[format];
const images = {jpeg, png};
for (const format of Object.keys(images)) {
const img = images[format];
let dims = `${img.width}\u00d7${img.height}`;
const dims = `${img.width}\u00d7${img.height}`;
browser.test.assertEq(tabDims, dims, `${format} dimensions are correct`);
let canvas = document.createElement("canvas");
const canvas = document.createElement("canvas");
canvas.width = img.width;
canvas.height = img.height;
canvas.mozOpaque = true;
let ctx = canvas.getContext("2d");
const ctx = canvas.getContext("2d");
ctx.drawImage(img, 0, 0);
// Check the colors of the first and last pixels of the image, to make
// sure we capture the entire frame, and scale it correctly.
let coords = [
const coords = [
{x: 0, y: 0,
color: options.color},
{x: img.width - 1,
@ -89,8 +89,8 @@ function* runTest(options) {
color: options.neutral},
];
for (let {x, y, color} of coords) {
let imageData = ctx.getImageData(x, y, 1, 1).data;
for (const {x, y, color} of coords) {
const imageData = ctx.getImageData(x, y, 1, 1).data;
if (format == "png") {
browser.test.assertEq(`rgba(${color},255)`, `rgba(${[...imageData]})`, `${format} image color is correct at (${x}, ${y})`);
@ -115,7 +115,7 @@ function* runTest(options) {
}
}
let extension = ExtensionTestUtils.loadExtension({
const extension = ExtensionTestUtils.loadExtension({
manifest: {
"permissions": ["<all_urls>"],
},
@ -143,7 +143,7 @@ add_task(async function testCaptureVisibleTab() {
});
add_task(async function testCaptureVisibleTabPermissions() {
let extension = ExtensionTestUtils.loadExtension({
const extension = ExtensionTestUtils.loadExtension({
manifest: {
"permissions": ["tabs"],
},

View File

@ -13,7 +13,7 @@
"use strict";
add_task(async function() {
let extension = ExtensionTestUtils.loadExtension({
const extension = ExtensionTestUtils.loadExtension({
useAddonManager: "permanent",
manifest: {
"applications": { "gecko": { "id": "tabs-create@tests.mozilla.org" } },
@ -39,7 +39,7 @@ add_task(async function() {
url: "about:blank",
};
let tests = [
const tests = [
{
create: {url: "http://example.com/"},
result: {url: "http://example.com/"},
@ -67,13 +67,13 @@ add_task(async function() {
return;
}
let test = tests.shift();
let expected = Object.assign({}, DEFAULTS, test.result);
const test = tests.shift();
const expected = Object.assign({}, DEFAULTS, test.result);
browser.test.log(`Testing tabs.create(${JSON.stringify(test.create)}), expecting ${JSON.stringify(test.result)}`);
let updatedPromise = new Promise(resolve => {
let onUpdated = (changedTabId, changed) => {
const updatedPromise = new Promise(resolve => {
const onUpdated = (changedTabId, changed) => {
// Loading an extension page causes two `about:blank` messages
// because of the process switch
if (changed.url && (expected.url == "about:blank" || changed.url != "about:blank")) {
@ -84,21 +84,21 @@ add_task(async function() {
browser.tabs.onUpdated.addListener(onUpdated);
});
let createdPromise = new Promise(resolve => {
let onCreated = tab => {
const createdPromise = new Promise(resolve => {
const onCreated = tab => {
browser.test.assertTrue("id" in tab, `Expected tabs.onCreated callback to receive tab object`);
resolve();
};
browser.tabs.onCreated.addListener(onCreated);
});
let [tab] = await Promise.all([
const [tab] = await Promise.all([
browser.tabs.create(test.create),
createdPromise,
]);
let tabId = tab.id;
const tabId = tab.id;
for (let key of Object.keys(expected)) {
for (const key of Object.keys(expected)) {
if (key === "url") {
// FIXME: This doesn't get updated until later in the load cycle.
continue;
@ -107,7 +107,7 @@ add_task(async function() {
browser.test.assertEq(expected[key], tab[key], `Expected value for tab.${key}`);
}
let updated = await updatedPromise;
const updated = await updatedPromise;
browser.test.assertEq(tabId, updated.tabId, `Expected value for tab.id`);
browser.test.assertEq(expected.url, updated.url, `Expected value for tab.url`);

View File

@ -14,9 +14,9 @@
add_task(async function testTabEvents() {
async function background() {
let events = [];
const events = [];
let eventPromise;
let checkEvents = () => {
const checkEvents = () => {
if (eventPromise && events.length >= eventPromise.names.length) {
eventPromise.resolve();
}
@ -56,7 +56,7 @@ add_task(async function testTabEvents() {
});
browser.test.assertEq(names.length, events.length, "Got expected number of events");
for (let [i, name] of names.entries()) {
for (const [i, name] of names.entries()) {
browser.test.assertEq(name, i in events && events[i].type,
`Got expected ${name} event`);
}
@ -65,17 +65,17 @@ add_task(async function testTabEvents() {
try {
browser.test.log("Create tab");
let tab = await browser.tabs.create({url: "about:blank"});
let oldIndex = tab.index;
const tab = await browser.tabs.create({url: "about:blank"});
const oldIndex = tab.index;
let [created] = await expectEvents(["onCreated"]);
const [created] = await expectEvents(["onCreated"]);
browser.test.assertEq(tab.id, created.tab.id, "Got expected tab ID");
browser.test.assertEq(oldIndex, created.tab.index, "Got expected tab index");
browser.test.log("Remove tab");
await browser.tabs.remove(tab.id);
let [removed] = await expectEvents(["onRemoved"]);
const [removed] = await expectEvents(["onRemoved"]);
browser.test.assertEq(tab.id, removed.tabId, "Expected removed tab ID");
browser.test.assertEq(tab.windowId, removed.windowId, "Expected removed tab window ID");
@ -89,7 +89,7 @@ add_task(async function testTabEvents() {
}
}
let extension = ExtensionTestUtils.loadExtension({
const extension = ExtensionTestUtils.loadExtension({
manifest: {
"permissions": ["tabs"],
applications: {
@ -123,7 +123,7 @@ add_task(async function testTabRemovalEvent() {
chrome.tabs.onRemoved.addListener((tabId, info) => {
browser.test.log("Make sure the removed tab is not available in the tabs.query callback.");
chrome.tabs.query({}, tabs => {
for (let tab of tabs) {
for (const tab of tabs) {
browser.test.assertTrue(tab.id != tabId, "Tab query should not include removed tabId");
}
browser.test.notifyPass("tabs-events");
@ -131,8 +131,8 @@ add_task(async function testTabRemovalEvent() {
});
try {
let url = "http://example.com/mochitest/mobile/android/components/extensions/test/mochitest/context.html";
let tab = await browser.tabs.create({url: url});
const url = "http://example.com/mochitest/mobile/android/components/extensions/test/mochitest/context.html";
const tab = await browser.tabs.create({url: url});
await awaitLoad(tab.id);
await browser.tabs.remove(tab.id);
@ -142,7 +142,7 @@ add_task(async function testTabRemovalEvent() {
}
}
let extension = ExtensionTestUtils.loadExtension({
const extension = ExtensionTestUtils.loadExtension({
manifest: {
"permissions": ["tabs"],
applications: {
@ -232,7 +232,7 @@ add_task(async function testTabActivationEvent() {
}
}
let extension = ExtensionTestUtils.loadExtension({
const extension = ExtensionTestUtils.loadExtension({
manifest: {
"permissions": ["tabs"],
},

View File

@ -16,13 +16,13 @@ add_task(async function testExecuteScript() {
const BASE = "http://mochi.test:8888/tests/mobile/android/components/extensions/test/mochitest/";
const URL = BASE + "file_iframe_document.html";
let win = window.open(URL);
const win = window.open(URL);
await new Promise(resolve => win.addEventListener("load", resolve, {once: true}));
async function background() {
try {
let [tab] = await browser.tabs.query({active: true, currentWindow: true});
let frames = await browser.webNavigation.getAllFrames({tabId: tab.id});
const [tab] = await browser.tabs.query({active: true, currentWindow: true});
const frames = await browser.webNavigation.getAllFrames({tabId: tab.id});
browser.test.log(`FRAMES: ${frames[1].frameId} ${JSON.stringify(frames)}\n`);
await Promise.all([
@ -182,7 +182,7 @@ add_task(async function testExecuteScript() {
}),
browser.tabs.create({url: "http://example.com/"}).then(async tab => {
let result = await browser.tabs.executeScript(tab.id, {code: "location.href"});
const result = await browser.tabs.executeScript(tab.id, {code: "location.href"});
browser.test.assertEq("http://example.com/", result[0], "Script executed correctly in new tab");
@ -213,7 +213,7 @@ add_task(async function testExecuteScript() {
}
}
let extension = ExtensionTestUtils.loadExtension({
const extension = ExtensionTestUtils.loadExtension({
manifest: {
"permissions": ["http://mochi.test/", "http://example.com/", "webNavigation"],
applications: {

View File

@ -13,7 +13,7 @@
"use strict";
function* testHasNoPermission(params) {
let contentSetup = params.contentSetup || (() => Promise.resolve());
const contentSetup = params.contentSetup || (() => Promise.resolve());
async function background(contentSetup) {
browser.test.onMessage.addListener(async msg => {
@ -31,7 +31,7 @@ function* testHasNoPermission(params) {
browser.test.sendMessage("ready");
}
let extension = ExtensionTestUtils.loadExtension({
const extension = ExtensionTestUtils.loadExtension({
manifest: params.manifest,
background: `(${background})(${contentSetup})`,
@ -57,7 +57,7 @@ function* testHasNoPermission(params) {
}
add_task(async function testBadPermissions() {
let win = window.open("http://mochi.test:8888/");
const win = window.open("http://mochi.test:8888/");
await new Promise(resolve => setTimeout(resolve, 0));
@ -76,7 +76,7 @@ add_task(async function testBadPermissions() {
add_task(async function testBadURL() {
async function background() {
let promises = [
const promises = [
new Promise(resolve => {
browser.tabs.executeScript({
file: "http://example.com/script.js",
@ -126,7 +126,7 @@ add_task(async function testBadURL() {
browser.test.notifyPass("executeScript-lastError");
}
let extension = ExtensionTestUtils.loadExtension({
const extension = ExtensionTestUtils.loadExtension({
manifest: {
"permissions": ["<all_urls>"],
},

View File

@ -13,7 +13,7 @@
"use strict";
async function testHasPermission(params) {
let contentSetup = params.contentSetup || (() => Promise.resolve());
const contentSetup = params.contentSetup || (() => Promise.resolve());
async function background(contentSetup) {
browser.runtime.onMessage.addListener((msg, sender) => {
@ -34,7 +34,7 @@ async function testHasPermission(params) {
browser.test.sendMessage("ready");
}
let extension = ExtensionTestUtils.loadExtension({
const extension = ExtensionTestUtils.loadExtension({
manifest: params.manifest,
background: `(${background})(${contentSetup})`,
@ -65,7 +65,7 @@ async function testHasPermission(params) {
}
add_task(async function testGoodPermissions() {
let win = window.open("http://mochi.test:8888/");
const win = window.open("http://mochi.test:8888/");
info("Test explicit host permission");
await testHasPermission({

View File

@ -57,7 +57,7 @@ add_task(async function testExecuteScriptAtOnUpdated() {
});
}
let extension = ExtensionTestUtils.loadExtension({
const extension = ExtensionTestUtils.loadExtension({
manifest: {
"permissions": ["http://mochi.test/", "tabs"],
},
@ -69,7 +69,7 @@ add_task(async function testExecuteScriptAtOnUpdated() {
extension.sendMessage(URL);
await extension.awaitMessage("open-test-tab");
let tab = window.open(URL);
const tab = window.open(URL);
await extension.awaitFinish("executeScript-at-onUpdated");
await extension.unload();

View File

@ -25,7 +25,7 @@
*/
add_task(async function testExecuteScript() {
let win = window.open("about:blank");
const win = window.open("about:blank");
async function background(DEBUG) {
let tab;
@ -35,7 +35,7 @@ add_task(async function testExecuteScript() {
const MAX_TRIES = 30;
let onUpdatedPromise = (tabId, url, status) => {
const onUpdatedPromise = (tabId, url, status) => {
return new Promise(resolve => {
browser.tabs.onUpdated.addListener(function listener(_, changed, tab) {
if (tabId == tab.id && changed.status == status && tab.url == url) {
@ -51,17 +51,17 @@ add_task(async function testExecuteScript() {
let success = false;
for (let tries = 0; !success && tries < MAX_TRIES; tries++) {
let url = `${URL}?with-iframe&r=${Math.random()}`;
const url = `${URL}?with-iframe&r=${Math.random()}`;
let loadingPromise = onUpdatedPromise(tab.id, url, "loading");
let completePromise = onUpdatedPromise(tab.id, url, "complete");
const loadingPromise = onUpdatedPromise(tab.id, url, "loading");
const completePromise = onUpdatedPromise(tab.id, url, "complete");
// TODO: Test allFrames and frameId.
await browser.tabs.update({url});
await loadingPromise;
let states = await Promise.all([
const states = await Promise.all([
// Send the executeScript requests in the reverse order that we expect
// them to execute in, to avoid them passing only because of timing
// races.
@ -106,7 +106,7 @@ add_task(async function testExecuteScript() {
}
}
let extension = ExtensionTestUtils.loadExtension({
const extension = ExtensionTestUtils.loadExtension({
useAddonManager: "permanent",
manifest: {
"applications": {

View File

@ -13,7 +13,7 @@
"use strict";
add_task(async function() {
let extension = ExtensionTestUtils.loadExtension({
const extension = ExtensionTestUtils.loadExtension({
manifest: {
permissions: ["tabs"],
applications: {

View File

@ -13,7 +13,7 @@
"use strict";
add_task(async function() {
let extension = ExtensionTestUtils.loadExtension({
const extension = ExtensionTestUtils.loadExtension({
useAddonManager: "permanent",
manifest: {
"applications": { "gecko": { "id": "get-current@tests.mozilla.org" } },
@ -22,7 +22,7 @@ add_task(async function() {
files: {
"tab.js": function() {
let url = document.location.href;
const url = document.location.href;
browser.tabs.getCurrent().then(currentTab => {
browser.test.assertEq(currentTab.url, url, "getCurrent in non-active background tab");

View File

@ -13,10 +13,10 @@
"use strict";
add_task(async function testExecuteScript() {
let win = window.open("http://mochi.test:8888/");
const win = window.open("http://mochi.test:8888/");
async function background() {
let tasks = [
const tasks = [
{
background: "rgba(0, 0, 0, 0)",
foreground: "rgb(0, 113, 4)",
@ -65,12 +65,12 @@ add_task(async function testExecuteScript() {
];
function checkCSS() {
let computedStyle = window.getComputedStyle(document.body);
const computedStyle = window.getComputedStyle(document.body);
return [computedStyle.backgroundColor, computedStyle.color];
}
try {
for (let {promise, background, foreground} of tasks) {
for (const {promise, background, foreground} of tasks) {
let result = await promise();
browser.test.assertEq(undefined, result, "Expected callback result");
@ -90,7 +90,7 @@ add_task(async function testExecuteScript() {
}
}
let extension = ExtensionTestUtils.loadExtension({
const extension = ExtensionTestUtils.loadExtension({
manifest: {
"permissions": ["http://mochi.test/"],
},

View File

@ -13,12 +13,12 @@
"use strict";
add_task(async function testLastAccessed() {
let past = Date.now();
const past = Date.now();
window.open("https://example.com/?1");
window.open("https://example.com/?2");
let extension = ExtensionTestUtils.loadExtension({
const extension = ExtensionTestUtils.loadExtension({
manifest: {
permissions: ["tabs"],
},
@ -28,12 +28,12 @@ add_task(async function testLastAccessed() {
return;
}
let [tab1] = await browser.tabs.query({url: "https://example.com/?1"});
let [tab2] = await browser.tabs.query({url: "https://example.com/?2"});
const [tab1] = await browser.tabs.query({url: "https://example.com/?1"});
const [tab2] = await browser.tabs.query({url: "https://example.com/?2"});
browser.test.assertTrue(tab1 && tab2, "Expected tabs were found");
let now = Date.now();
const now = Date.now();
browser.test.assertTrue(typeof tab1.lastAccessed == "number",
"tab1 lastAccessed should be a number");

View File

@ -13,7 +13,7 @@
"use strict";
add_task(async function test_onUpdated() {
let extension = ExtensionTestUtils.loadExtension({
const extension = ExtensionTestUtils.loadExtension({
manifest: {
"applications": {
"gecko": {
@ -30,15 +30,15 @@ add_task(async function test_onUpdated() {
useAddonManager: "permanent",
background: function() {
let pageURL = "http://mochi.test:8888/tests/mobile/android/components/extensions/test/mochitest/context_tabs_onUpdated_page.html";
const pageURL = "http://mochi.test:8888/tests/mobile/android/components/extensions/test/mochitest/context_tabs_onUpdated_page.html";
let expectedSequence = [
const expectedSequence = [
{status: "loading"},
{status: "loading", url: pageURL},
{status: "complete"},
];
let collectedSequence = [];
const collectedSequence = [];
let tabId;
browser.tabs.onUpdated.addListener(function(tabId, updatedInfo) {
@ -101,7 +101,7 @@ add_task(async function test_onUpdated() {
});
function* do_test_update(name, background, withPermissions = true) {
let manifest = {
const manifest = {
applications: {
gecko: {
id: "test_update_" + name + "@tests.mozilla.org",
@ -111,7 +111,7 @@ function* do_test_update(name, background, withPermissions = true) {
if (withPermissions) {
manifest.permissions = ["tabs", "http://mochi.test/"];
}
let extension = ExtensionTestUtils.loadExtension({
const extension = ExtensionTestUtils.loadExtension({
manifest,
background,
useAddonManager: "permanent",

View File

@ -13,7 +13,7 @@
"use strict";
add_task(async function test_query_index() {
let extension = ExtensionTestUtils.loadExtension({
const extension = ExtensionTestUtils.loadExtension({
manifest: {
"permissions": ["tabs"],
},

View File

@ -13,7 +13,7 @@
"use strict";
add_task(async function() {
let extension = ExtensionTestUtils.loadExtension({
const extension = ExtensionTestUtils.loadExtension({
manifest: {
"permissions": ["tabs"],
},
@ -32,7 +32,7 @@ add_task(async function() {
async background() {
let tabLoadedCount = 0;
let tab = await browser.tabs.create({url: "tab.html", active: true});
const tab = await browser.tabs.create({url: "tab.html", active: true});
browser.runtime.onMessage.addListener(msg => {
if (msg == "tab-loaded") {

View File

@ -13,7 +13,7 @@
"use strict";
add_task(async function() {
let extension = ExtensionTestUtils.loadExtension({
const extension = ExtensionTestUtils.loadExtension({
manifest: {
"permissions": ["tabs", "<all_urls>"],
},
@ -34,7 +34,7 @@ add_task(async function() {
}
try {
let tab = await browser.tabs.create({url: URL});
const tab = await browser.tabs.create({url: URL});
await awaitLoad(tab.id);
await browser.tabs.reload(tab.id, {bypassCache: false});
@ -48,7 +48,7 @@ add_task(async function() {
[textContent] = await browser.tabs.executeScript(tab.id, {code: "document.body.textContent"});
let [pragma, cacheControl] = textContent.split(":");
const [pragma, cacheControl] = textContent.split(":");
browser.test.assertEq("no-cache", pragma, "`pragma` should be set to `no-cache` when bypassCache is true");
browser.test.assertEq("no-cache", cacheControl, "`cacheControl` should be set to `no-cache` when bypassCache is true");

View File

@ -13,7 +13,7 @@
"use strict";
add_task(async function tabsSendMessageReply() {
let extension = ExtensionTestUtils.loadExtension({
const extension = ExtensionTestUtils.loadExtension({
manifest: {
"permissions": ["tabs"],
"applications": {
@ -32,10 +32,10 @@ add_task(async function tabsSendMessageReply() {
background: async function() {
let firstTab;
let promiseResponse = new Promise(resolve => {
const promiseResponse = new Promise(resolve => {
browser.runtime.onMessage.addListener((msg, sender, respond) => {
if (msg == "content-script-ready") {
let tabId = sender.tab.id;
const tabId = sender.tab.id;
Promise.all([
promiseResponse,
@ -82,7 +82,7 @@ add_task(async function tabsSendMessageReply() {
});
});
let tabs = await browser.tabs.query({currentWindow: true, active: true});
const tabs = await browser.tabs.query({currentWindow: true, active: true});
firstTab = tabs[0].id;
browser.tabs.create({url: "http://example.com/"});
},
@ -114,7 +114,7 @@ add_task(async function tabsSendMessageReply() {
}
});
let response = await browser.runtime.sendMessage("content-script-ready");
const response = await browser.runtime.sendMessage("content-script-ready");
browser.runtime.sendMessage(["got-response", response]);
},
},
@ -129,7 +129,7 @@ add_task(async function tabsSendMessageReply() {
add_task(async function tabsSendHidden() {
let extension = ExtensionTestUtils.loadExtension({
const extension = ExtensionTestUtils.loadExtension({
manifest: {
"permissions": ["tabs"],
"applications": {
@ -154,7 +154,7 @@ add_task(async function tabsSendHidden() {
}
});
let awaitContent = url => {
const awaitContent = url => {
return new Promise(resolve => {
resolveContent = resolve;
}).then(result => {
@ -166,7 +166,7 @@ add_task(async function tabsSendHidden() {
const URL1 = "http://example.com/content1.html";
const URL2 = "http://example.com/content2.html";
let tab = await browser.tabs.create({url: URL1});
const tab = await browser.tabs.create({url: URL1});
await awaitContent(URL1);
let url = await browser.tabs.sendMessage(tab.id, URL1);
@ -196,7 +196,7 @@ add_task(async function tabsSendHidden() {
"content-script.js": function() {
// Store this in a local variable to make sure we don't touch any
// properties of the possibly-hidden content window.
let href = window.location.href;
const href = window.location.href;
browser.runtime.onMessage.addListener((msg, sender) => {
browser.test.assertEq(href, msg, "Should be in the expected content window");
@ -218,7 +218,7 @@ add_task(async function tabsSendHidden() {
add_task(async function tabsSendMessageNoExceptionOnNonExistentTab() {
let extension = ExtensionTestUtils.loadExtension({
const extension = ExtensionTestUtils.loadExtension({
manifest: {
"permissions": ["tabs"],
"applications": {
@ -231,8 +231,8 @@ add_task(async function tabsSendMessageNoExceptionOnNonExistentTab() {
useAddonManager: "permanent",
async background() {
let url = "http://example.com/mochitest/tests/mobile/android/components/extensions/test/mochitest/file_dummy.html";
let tab = await browser.tabs.create({url});
const url = "http://example.com/mochitest/tests/mobile/android/components/extensions/test/mochitest/file_dummy.html";
const tab = await browser.tabs.create({url});
try {
browser.tabs.sendMessage(tab.id, "message");

View File

@ -13,7 +13,7 @@
"use strict";
async function testTabsUpdateURL(existentTabURL, tabsUpdateURL, isErrorExpected) {
let extension = ExtensionTestUtils.loadExtension({
const extension = ExtensionTestUtils.loadExtension({
useAddonManager: "permanent",
manifest: {
"applications": { "gecko": { "id": "tabs-update-url@tests.mozilla.org" } },
@ -37,10 +37,10 @@ async function testTabsUpdateURL(existentTabURL, tabsUpdateURL, isErrorExpected)
browser.test.sendMessage("ready", browser.runtime.getURL("tab.html"));
browser.test.onMessage.addListener(async (msg, tabsUpdateURL, isErrorExpected) => {
let tabs = await browser.tabs.query({lastFocusedWindow: true});
const tabs = await browser.tabs.query({lastFocusedWindow: true});
try {
let tab = await browser.tabs.update(tabs[0].id, {url: tabsUpdateURL});
const tab = await browser.tabs.update(tabs[0].id, {url: tabsUpdateURL});
browser.test.assertFalse(isErrorExpected, `tabs.update with URL ${tabsUpdateURL} should be rejected`);
browser.test.assertTrue(tab, "on success the tab should be defined");
@ -57,7 +57,7 @@ async function testTabsUpdateURL(existentTabURL, tabsUpdateURL, isErrorExpected)
await extension.startup();
let mozExtTabURL = await extension.awaitMessage("ready");
const mozExtTabURL = await extension.awaitMessage("ready");
if (tabsUpdateURL == "self") {
tabsUpdateURL = mozExtTabURL;
@ -65,7 +65,7 @@ async function testTabsUpdateURL(existentTabURL, tabsUpdateURL, isErrorExpected)
info(`tab.update URL "${tabsUpdateURL}" on tab with URL "${existentTabURL}"`);
let tab1 = window.open(existentTabURL);
const tab1 = window.open(existentTabURL);
extension.sendMessage("start", tabsUpdateURL, isErrorExpected);
await extension.awaitMessage("done");
@ -77,7 +77,7 @@ async function testTabsUpdateURL(existentTabURL, tabsUpdateURL, isErrorExpected)
add_task(async function() {
info("Start testing tabs.update on javascript URLs");
let dataURLPage = `data:text/html,
const dataURLPage = `data:text/html,
<!DOCTYPE html>
<html>
<head>
@ -88,7 +88,7 @@ add_task(async function() {
</body>
</html>`;
let checkList = [
const checkList = [
{
tabsUpdateURL: "http://example.net",
isErrorExpected: false,
@ -111,10 +111,10 @@ add_task(async function() {
},
];
let testCases = checkList
const testCases = checkList
.map((check) => Object.assign({}, check, {existentTabURL: "about:blank"}));
for (let {existentTabURL, tabsUpdateURL, isErrorExpected} of testCases) {
for (const {existentTabURL, tabsUpdateURL, isErrorExpected} of testCases) {
await testTabsUpdateURL(existentTabURL, tabsUpdateURL, isErrorExpected);
}

View File

@ -13,7 +13,7 @@
"use strict";
add_task(async function() {
let extension = ExtensionTestUtils.loadExtension({
const extension = ExtensionTestUtils.loadExtension({
manifest: {
permissions: ["webNavigation", "tabs"],
applications: {

View File

@ -53,7 +53,7 @@ GeckoViewPermission.prototype = {
receiveMessage(aMsg) {
switch (aMsg.name) {
case "GeckoView:AddCameraPermission": {
let principal = Services.scriptSecurityManager.createContentPrincipalFromOrigin(
const principal = Services.scriptSecurityManager.createContentPrincipalFromOrigin(
aMsg.data.origin
);
@ -71,7 +71,7 @@ GeckoViewPermission.prototype = {
},
handleMediaAskDevicePermission(aType, aCallback) {
let perms = [];
const perms = [];
if (aType === "video" || aType === "all") {
perms.push(PERM_CAMERA);
}
@ -79,8 +79,8 @@ GeckoViewPermission.prototype = {
perms.push(PERM_RECORD_AUDIO);
}
let [dispatcher] = GeckoViewUtils.getActiveDispatcherAndWindow();
let callback = _ => {
const [dispatcher] = GeckoViewUtils.getActiveDispatcherAndWindow();
const callback = _ => {
Services.obs.notifyObservers(
aCallback,
"getUserMedia:got-device-permission"
@ -96,13 +96,13 @@ GeckoViewPermission.prototype = {
},
handleMediaRequest(aRequest) {
let constraints = aRequest.getConstraints();
let callId = aRequest.callID;
let denyRequest = _ => {
const constraints = aRequest.getConstraints();
const callId = aRequest.callID;
const denyRequest = _ => {
Services.obs.notifyObservers(null, "getUserMedia:response:deny", callId);
};
let win = Services.wm.getOuterWindowWithId(aRequest.windowID);
const win = Services.wm.getOuterWindowWithId(aRequest.windowID);
new Promise((resolve, reject) => {
win.navigator.mozGetUserMediaDevices(
constraints,
@ -119,7 +119,7 @@ GeckoViewPermission.prototype = {
return Promise.resolve();
}
let sources = devices.map(device => {
const sources = devices.map(device => {
device = device.QueryInterface(Ci.nsIMediaDevice);
return {
type: device.type,
@ -142,8 +142,8 @@ GeckoViewPermission.prototype = {
throw new Error("no audio source");
}
let dispatcher = GeckoViewUtils.getDispatcherForWindow(win);
let uri = win.document.documentURIObject;
const dispatcher = GeckoViewUtils.getDispatcherForWindow(win);
const uri = win.document.documentURIObject;
return dispatcher
.sendRequestForResult({
type: "GeckoView:MediaPermission",
@ -161,11 +161,13 @@ GeckoViewPermission.prototype = {
denyRequest();
return;
}
let allowedDevices = Cc["@mozilla.org/array;1"].createInstance(
const allowedDevices = Cc["@mozilla.org/array;1"].createInstance(
Ci.nsIMutableArray
);
if (constraints.video) {
let video = devices.find(device => response.video === device.id);
const video = devices.find(
device => response.video === device.id
);
if (!video) {
throw new Error("invalid video id");
}
@ -176,7 +178,9 @@ GeckoViewPermission.prototype = {
allowedDevices.appendElement(video);
}
if (constraints.audio) {
let audio = devices.find(device => response.audio === device.id);
const audio = devices.find(
device => response.audio === device.id
);
if (!audio) {
throw new Error("invalid audio id");
}
@ -208,7 +212,7 @@ GeckoViewPermission.prototype = {
},
getAppPermissions(aDispatcher, aPerms) {
let perms = aPerms.filter(perm => !this._appPermissions[perm]);
const perms = aPerms.filter(perm => !this._appPermissions[perm]);
if (!perms.length) {
return Promise.resolve(/* granted */ true);
}
@ -219,7 +223,7 @@ GeckoViewPermission.prototype = {
})
.then(granted => {
if (granted) {
for (let perm of perms) {
for (const perm of perms) {
this._appPermissions[perm] = true;
}
}
@ -229,13 +233,13 @@ GeckoViewPermission.prototype = {
prompt(aRequest) {
// Only allow exactly one permission request here.
let types = aRequest.types.QueryInterface(Ci.nsIArray);
const types = aRequest.types.QueryInterface(Ci.nsIArray);
if (types.length !== 1) {
aRequest.cancel();
return;
}
let perm = types.queryElementAt(0, Ci.nsIContentPermissionType);
const perm = types.queryElementAt(0, Ci.nsIContentPermissionType);
if (
perm.type === "desktop-notification" &&
!aRequest.isHandlingUserInput &&
@ -249,7 +253,7 @@ GeckoViewPermission.prototype = {
return;
}
let dispatcher = GeckoViewUtils.getDispatcherForWindow(
const dispatcher = GeckoViewUtils.getDispatcherForWindow(
aRequest.window ? aRequest.window : aRequest.element.ownerGlobal
);
dispatcher

View File

@ -55,7 +55,7 @@ PromptFactory.prototype = {
},
_handleClick(aEvent) {
let target = aEvent.composedTarget;
const target = aEvent.composedTarget;
if (
target.isContentEditable ||
target.disabled ||
@ -67,12 +67,12 @@ PromptFactory.prototype = {
return;
}
let win = target.ownerGlobal;
const win = target.ownerGlobal;
if (target instanceof win.HTMLSelectElement) {
this._handleSelect(target);
aEvent.preventDefault();
} else if (target instanceof win.HTMLInputElement) {
let type = target.type;
const type = target.type;
if (
type === "date" ||
type === "month" ||
@ -87,19 +87,19 @@ PromptFactory.prototype = {
},
_handleSelect(aElement) {
let win = aElement.ownerGlobal;
const win = aElement.ownerGlobal;
let id = 0;
let map = {};
const map = {};
let items = (function enumList(elem, disabled) {
let items = [];
let children = elem.children;
const items = (function enumList(elem, disabled) {
const items = [];
const children = elem.children;
for (let i = 0; i < children.length; i++) {
let child = children[i];
const child = children[i];
if (win.getComputedStyle(child).display === "none") {
continue;
}
let item = {
const item = {
id: String(id),
disabled: disabled || child.disabled,
};
@ -118,7 +118,7 @@ PromptFactory.prototype = {
return items;
})(aElement);
let prompt = new PromptDelegate(win);
const prompt = new PromptDelegate(win);
prompt.asyncShowPrompt(
{
type: "choice",
@ -134,7 +134,7 @@ PromptFactory.prototype = {
let dispatchEvents = false;
if (!aElement.multiple) {
let elem = map[result.choices[0]];
const elem = map[result.choices[0]];
if (elem && elem instanceof win.HTMLOptionElement) {
dispatchEvents = !elem.selected;
elem.selected = true;
@ -145,8 +145,8 @@ PromptFactory.prototype = {
}
} else {
for (let i = 0; i < id; i++) {
let elem = map[i];
let index = result.choices.indexOf(String(i));
const elem = map[i];
const index = result.choices.indexOf(String(i));
if (
elem instanceof win.HTMLOptionElement &&
elem.selected !== index >= 0
@ -175,7 +175,7 @@ PromptFactory.prototype = {
},
_handleDateTime(aElement, aType) {
let prompt = new PromptDelegate(aElement.ownerGlobal);
const prompt = new PromptDelegate(aElement.ownerGlobal);
prompt.asyncShowPrompt(
{
type: "datetime",
@ -212,7 +212,7 @@ PromptFactory.prototype = {
},
_handleContextMenu(aEvent) {
let target = aEvent.composedTarget;
const target = aEvent.composedTarget;
if (aEvent.defaultPrevented || target.isContentEditable) {
return;
}
@ -228,7 +228,7 @@ PromptFactory.prototype = {
return;
}
let builder = {
const builder = {
_cursor: undefined,
_id: 0,
_map: {},
@ -242,7 +242,7 @@ PromptFactory.prototype = {
this._cursor = this;
return;
}
let newCursor = {
const newCursor = {
id: String(this._id++),
items: [],
label: aLabel,
@ -275,14 +275,15 @@ PromptFactory.prototype = {
},
undoAddSeparator() {
let sep = this._cursor.items[this._cursor.items.length - 1];
const sep = this._cursor.items[this._cursor.items.length - 1];
if (sep && sep.separator) {
this._cursor.items.pop();
}
},
closeContainer() {
let childItems = this._cursor.label === "" ? this._cursor.items : null;
const childItems =
this._cursor.label === "" ? this._cursor.items : null;
this._cursor = this._stack.pop();
if (
@ -301,7 +302,7 @@ PromptFactory.prototype = {
},
click(aId) {
let item = this._map[aId];
const item = this._map[aId];
if (item) {
item.click();
}
@ -312,7 +313,7 @@ PromptFactory.prototype = {
menu.sendShowEvent();
menu.build(builder);
let prompt = new PromptDelegate(target.ownerGlobal);
const prompt = new PromptDelegate(target.ownerGlobal);
prompt.asyncShowPrompt(
{
type: "choice",
@ -337,7 +338,7 @@ PromptFactory.prototype = {
? aEvent.popupWindowURI.displaySpec
: "about:blank";
let prompt = new PromptDelegate(aEvent.requestingWindow);
const prompt = new PromptDelegate(aEvent.requestingWindow);
prompt.asyncShowPrompt(
{
type: "popup",
@ -360,7 +361,7 @@ PromptFactory.prototype = {
// Delegated to login manager here, which in turn calls back into us via nsIPromptService.
if (aIID.equals(Ci.nsIAuthPrompt2) || aIID.equals(Ci.nsIAuthPrompt)) {
try {
let pwmgr = Cc[
const pwmgr = Cc[
"@mozilla.org/passwordmanager/authpromptfactory;1"
].getService(Ci.nsIPromptFactory);
return pwmgr.getPrompt(aDOMWin, aIID);
@ -369,7 +370,7 @@ PromptFactory.prototype = {
}
}
let p = new PromptDelegate(aDOMWin);
const p = new PromptDelegate(aDOMWin);
p.QueryInterface(aIID);
return p;
},
@ -378,7 +379,7 @@ PromptFactory.prototype = {
// nsIPromptService methods proxy to our Prompt class
callProxy(aMethod, aArguments) {
let prompt = new PromptDelegate(aArguments[0]);
const prompt = new PromptDelegate(aArguments[0]);
let promptArgs;
if (aArguments[0] instanceof BrowsingContext) {
// Called by BrowsingContext prompt method, strip modalType.
@ -500,12 +501,12 @@ PromptDelegate.prototype = {
}
// Accessing the document object can throw if this window no longer exists. See bug 789888.
try {
let winUtils = this._domWin.windowUtils;
const winUtils = this._domWin.windowUtils;
if (!aEntering) {
winUtils.leaveModalState();
}
let event = this._domWin.document.createEvent("Events");
const event = this._domWin.document.createEvent("Events");
event.initEvent(
aEntering ? "DOMWillOpenModalDialog" : "DOMModalDialogClosed",
true,
@ -547,7 +548,7 @@ PromptDelegate.prototype = {
asyncShowPrompt(aMsg, aCallback) {
let handled = false;
let onResponse = response => {
const onResponse = response => {
if (handled) {
return;
}
@ -598,7 +599,7 @@ PromptDelegate.prototype = {
},
alertCheck(aTitle, aText, aCheckMsg, aCheckState) {
let result = this._showPrompt(
const result = this._showPrompt(
this._addText(
aTitle,
aText,
@ -643,12 +644,12 @@ PromptDelegate.prototype = {
aCheckMsg,
aCheckState
) {
let btnMap = Array(3).fill(null);
let btnTitle = Array(3).fill(null);
let btnCustomTitle = Array(3).fill(null);
let savedButtonId = [];
const btnMap = Array(3).fill(null);
const btnTitle = Array(3).fill(null);
const btnCustomTitle = Array(3).fill(null);
const savedButtonId = [];
for (let i = 0; i < 3; i++) {
let btnFlags = aButtonFlags >> (i * 8);
const btnFlags = aButtonFlags >> (i * 8);
switch (btnFlags & 0xff) {
case Ci.nsIPrompt.BUTTON_TITLE_OK:
btnMap[this.BUTTON_TYPE_POSITIVE] = i;
@ -688,7 +689,7 @@ PromptDelegate.prototype = {
}
}
let result = this._showPrompt(
const result = this._showPrompt(
this._addText(
aTitle,
aText,
@ -706,7 +707,7 @@ PromptDelegate.prototype = {
},
prompt(aTitle, aText, aValue, aCheckMsg, aCheckState) {
let result = this._showPrompt(
const result = this._showPrompt(
this._addText(
aTitle,
aText,
@ -748,7 +749,7 @@ PromptDelegate.prototype = {
aCheckMsg,
aCheckState
) {
let msg = {
const msg = {
type: "auth",
mode: aUsername ? "auth" : "password",
options: {
@ -757,7 +758,7 @@ PromptDelegate.prototype = {
password: aPassword.value,
},
};
let result = this._showPrompt(
const result = this._showPrompt(
this._addText(aTitle, aText, this._addCheck(aCheckMsg, aCheckState, msg))
);
// OK: result && result.password !== undefined
@ -777,13 +778,13 @@ PromptDelegate.prototype = {
},
select(aTitle, aText, aSelectList, aOutSelection) {
let choices = Array.prototype.map.call(aSelectList, (item, index) => ({
const choices = Array.prototype.map.call(aSelectList, (item, index) => ({
id: String(index),
label: item,
disabled: false,
selected: false,
}));
let result = this._showPrompt(
const result = this._showPrompt(
this._addText(aTitle, aText, {
type: "choice",
mode: "single",
@ -842,7 +843,7 @@ PromptDelegate.prototype = {
return true;
}
let username = aResult.username || "";
const username = aResult.username || "";
if (aAuthInfo.flags & Ci.nsIAuthInformation.NEED_DOMAIN) {
// Domain is separated from username by a backslash
var idx = username.indexOf("\\");
@ -857,7 +858,7 @@ PromptDelegate.prototype = {
},
promptAuth(aChannel, aLevel, aAuthInfo, aCheckMsg, aCheckState) {
let result = this._showPrompt(
const result = this._showPrompt(
this._addCheck(
aCheckMsg,
aCheckState,
@ -880,7 +881,7 @@ PromptDelegate.prototype = {
aCheckState
) {
let responded = false;
let callback = result => {
const callback = result => {
// OK: result && result.password !== undefined
// Cancel: result && result.password === undefined
// Error: !result
@ -915,12 +916,12 @@ PromptDelegate.prototype = {
},
_getAuthText(aChannel, aAuthInfo) {
let isProxy = aAuthInfo.flags & Ci.nsIAuthInformation.AUTH_PROXY;
let isPassOnly = aAuthInfo.flags & Ci.nsIAuthInformation.ONLY_PASSWORD;
let isCrossOrig =
const isProxy = aAuthInfo.flags & Ci.nsIAuthInformation.AUTH_PROXY;
const isPassOnly = aAuthInfo.flags & Ci.nsIAuthInformation.ONLY_PASSWORD;
const isCrossOrig =
aAuthInfo.flags & Ci.nsIAuthInformation.CROSS_ORIGIN_SUB_RESOURCE;
let username = aAuthInfo.username;
const username = aAuthInfo.username;
let [displayHost, realm] = this._getAuthTarget(aChannel, aAuthInfo);
// Suppress "the site says: $realm" when we synthesized a missing realm.
@ -933,7 +934,7 @@ PromptDelegate.prototype = {
realm = realm.substring(0, 50) + "\u2026";
}
let bundle = Services.strings.createBundle(
const bundle = Services.strings.createBundle(
"chrome://global/locale/commonDialogs.properties"
);
let text;
@ -972,16 +973,16 @@ PromptDelegate.prototype = {
if (!(aChannel instanceof Ci.nsIProxiedChannel)) {
throw new Error("proxy auth needs nsIProxiedChannel");
}
let info = aChannel.proxyInfo;
const info = aChannel.proxyInfo;
if (!info) {
throw new Error("proxy auth needs nsIProxyInfo");
}
// Proxies don't have a scheme, but we'll use "moz-proxy://"
// so that it's more obvious what the login is for.
let idnService = Cc["@mozilla.org/network/idn-service;1"].getService(
const idnService = Cc["@mozilla.org/network/idn-service;1"].getService(
Ci.nsIIDNService
);
let hostname =
const hostname =
"moz-proxy://" +
idnService.convertUTF8toACE(info.host) +
":" +
@ -993,7 +994,7 @@ PromptDelegate.prototype = {
return [hostname, realm];
}
let hostname = aChannel.URI.scheme + "://" + aChannel.URI.displayHostPort;
const hostname = aChannel.URI.scheme + "://" + aChannel.URI.displayHostPort;
// If a HTTP WWW-Authenticate header specified a realm, that value
// will be available here. If it wasn't set or wasn't HTTP, we'll use
// the formatted hostname instead.

View File

@ -260,7 +260,7 @@ GeckoViewStartup.prototype = {
if (aData.requestedLocales) {
Services.locale.requestedLocales = aData.requestedLocales;
}
let pls = Cc["@mozilla.org/pref-localizedstring;1"].createInstance(
const pls = Cc["@mozilla.org/pref-localizedstring;1"].createInstance(
Ci.nsIPrefLocalizedString
);
pls.data = aData.acceptLanguages;

View File

@ -2,12 +2,12 @@
* 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/. */
let manifest = document.querySelector("head > link[rel=manifest]");
const manifest = document.querySelector("head > link[rel=manifest]");
if (manifest) {
fetch(manifest.href)
.then(response => response.json())
.then(json => {
let message = { type: "WPAManifest", manifest: json };
const message = { type: "WPAManifest", manifest: json };
browser.runtime.sendNativeMessage("browser", message);
});
}

View File

@ -3,7 +3,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
// Establish connection with app
let port = browser.runtime.connectNative("browser");
const port = browser.runtime.connectNative("browser");
port.onMessage.addListener(response => {
// Let's just echo the message back
port.postMessage(`Received: ${JSON.stringify(response)}`);

View File

@ -65,7 +65,7 @@ this.test = class extends ExtensionAPI {
/* Restore prefs to old value. */
async restorePrefs(oldPrefs) {
for (let [name, value] of Object.entries(oldPrefs)) {
for (const [name, value] of Object.entries(oldPrefs)) {
if (value === null) {
Preferences.reset(name);
} else {

View File

@ -40,7 +40,7 @@ const { ProcessActorList } = require("devtools/server/actors/process");
* The conection to the client.
*/
exports.createRootActor = function createRootActor(aConnection) {
let parameters = {
const parameters = {
tabList: new MobileTabList(aConnection),
addonList: new BrowserAddonList(aConnection),
workerList: new WorkerTargetActorList(aConnection, {}),