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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -15,7 +15,7 @@ var TEST_ICON_ARRAYBUFFER = Uint8Array.from(atob(TEST_ICON_DATA), byte =>
).buffer; ).buffer;
{ {
let chromeScript = SpecialPowers.loadChromeScript( const chromeScript = SpecialPowers.loadChromeScript(
SimpleTest.getTestFileURL("chrome_cleanup_script.js") 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"); chromeScript.sendAsyncMessage("check-cleanup");
let results = await chromeScript.promiseOneMessage("cleanup-results"); const results = await chromeScript.promiseOneMessage("cleanup-results");
chromeScript.destroy(); chromeScript.destroy();
if (results.extraWindows.length || results.extraTabs.length) { 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. // 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() { add_task(async function testDownload() {
let extension = ExtensionTestUtils.loadExtension({ const extension = ExtensionTestUtils.loadExtension({
manifest: {permissions: ["downloads"]}, manifest: {permissions: ["downloads"]},
background: async function() { background: async function() {

View File

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

View File

@ -13,15 +13,15 @@
"use strict"; "use strict";
add_task(async function() { 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: { manifest: {
"permissions": ["tabs"], "permissions": ["tabs"],
}, },
background: function() { background: function() {
let messages_received = []; const messages_received = [];
let tabId; let tabId;
@ -54,7 +54,7 @@ add_task(async function() {
files: { files: {
"tab.js": function() { "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.postMessage("tab to background port message");
port.onMessage.addListener((msg) => { port.onMessage.addListener((msg) => {
port.postMessage({tabReceived: msg}); port.postMessage({tabReceived: msg});

View File

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

View File

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

View File

@ -14,9 +14,9 @@
add_task(async function testTabEvents() { add_task(async function testTabEvents() {
async function background() { async function background() {
let events = []; const events = [];
let eventPromise; let eventPromise;
let checkEvents = () => { const checkEvents = () => {
if (eventPromise && events.length >= eventPromise.names.length) { if (eventPromise && events.length >= eventPromise.names.length) {
eventPromise.resolve(); eventPromise.resolve();
} }
@ -56,7 +56,7 @@ add_task(async function testTabEvents() {
}); });
browser.test.assertEq(names.length, events.length, "Got expected number of events"); 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, browser.test.assertEq(name, i in events && events[i].type,
`Got expected ${name} event`); `Got expected ${name} event`);
} }
@ -65,17 +65,17 @@ add_task(async function testTabEvents() {
try { try {
browser.test.log("Create tab"); browser.test.log("Create tab");
let tab = await browser.tabs.create({url: "about:blank"}); const tab = await browser.tabs.create({url: "about:blank"});
let oldIndex = tab.index; 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(tab.id, created.tab.id, "Got expected tab ID");
browser.test.assertEq(oldIndex, created.tab.index, "Got expected tab index"); browser.test.assertEq(oldIndex, created.tab.index, "Got expected tab index");
browser.test.log("Remove tab"); browser.test.log("Remove tab");
await browser.tabs.remove(tab.id); 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.id, removed.tabId, "Expected removed tab ID");
browser.test.assertEq(tab.windowId, removed.windowId, "Expected removed tab window 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: { manifest: {
"permissions": ["tabs"], "permissions": ["tabs"],
applications: { applications: {
@ -123,7 +123,7 @@ add_task(async function testTabRemovalEvent() {
chrome.tabs.onRemoved.addListener((tabId, info) => { chrome.tabs.onRemoved.addListener((tabId, info) => {
browser.test.log("Make sure the removed tab is not available in the tabs.query callback."); browser.test.log("Make sure the removed tab is not available in the tabs.query callback.");
chrome.tabs.query({}, tabs => { 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.assertTrue(tab.id != tabId, "Tab query should not include removed tabId");
} }
browser.test.notifyPass("tabs-events"); browser.test.notifyPass("tabs-events");
@ -131,8 +131,8 @@ add_task(async function testTabRemovalEvent() {
}); });
try { try {
let url = "http://example.com/mochitest/mobile/android/components/extensions/test/mochitest/context.html"; const url = "http://example.com/mochitest/mobile/android/components/extensions/test/mochitest/context.html";
let tab = await browser.tabs.create({url: url}); const tab = await browser.tabs.create({url: url});
await awaitLoad(tab.id); await awaitLoad(tab.id);
await browser.tabs.remove(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: { manifest: {
"permissions": ["tabs"], "permissions": ["tabs"],
applications: { applications: {
@ -232,7 +232,7 @@ add_task(async function testTabActivationEvent() {
} }
} }
let extension = ExtensionTestUtils.loadExtension({ const extension = ExtensionTestUtils.loadExtension({
manifest: { manifest: {
"permissions": ["tabs"], "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 BASE = "http://mochi.test:8888/tests/mobile/android/components/extensions/test/mochitest/";
const URL = BASE + "file_iframe_document.html"; 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})); await new Promise(resolve => win.addEventListener("load", resolve, {once: true}));
async function background() { async function background() {
try { try {
let [tab] = await browser.tabs.query({active: true, currentWindow: true}); const [tab] = await browser.tabs.query({active: true, currentWindow: true});
let frames = await browser.webNavigation.getAllFrames({tabId: tab.id}); const frames = await browser.webNavigation.getAllFrames({tabId: tab.id});
browser.test.log(`FRAMES: ${frames[1].frameId} ${JSON.stringify(frames)}\n`); browser.test.log(`FRAMES: ${frames[1].frameId} ${JSON.stringify(frames)}\n`);
await Promise.all([ await Promise.all([
@ -182,7 +182,7 @@ add_task(async function testExecuteScript() {
}), }),
browser.tabs.create({url: "http://example.com/"}).then(async tab => { 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"); 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: { manifest: {
"permissions": ["http://mochi.test/", "http://example.com/", "webNavigation"], "permissions": ["http://mochi.test/", "http://example.com/", "webNavigation"],
applications: { applications: {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -13,7 +13,7 @@
"use strict"; "use strict";
add_task(async function() { add_task(async function() {
let extension = ExtensionTestUtils.loadExtension({ const extension = ExtensionTestUtils.loadExtension({
manifest: { manifest: {
"permissions": ["tabs"], "permissions": ["tabs"],
}, },
@ -32,7 +32,7 @@ add_task(async function() {
async background() { async background() {
let tabLoadedCount = 0; 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 => { browser.runtime.onMessage.addListener(msg => {
if (msg == "tab-loaded") { if (msg == "tab-loaded") {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -260,7 +260,7 @@ GeckoViewStartup.prototype = {
if (aData.requestedLocales) { if (aData.requestedLocales) {
Services.locale.requestedLocales = 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 Ci.nsIPrefLocalizedString
); );
pls.data = aData.acceptLanguages; 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 * 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/. */
let manifest = document.querySelector("head > link[rel=manifest]"); const manifest = document.querySelector("head > link[rel=manifest]");
if (manifest) { if (manifest) {
fetch(manifest.href) fetch(manifest.href)
.then(response => response.json()) .then(response => response.json())
.then(json => { .then(json => {
let message = { type: "WPAManifest", manifest: json }; const message = { type: "WPAManifest", manifest: json };
browser.runtime.sendNativeMessage("browser", message); browser.runtime.sendNativeMessage("browser", message);
}); });
} }

View File

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

View File

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

View File

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