Bug 1498410 - Part 4 - Export comma-dangle refactoring as a separate commit to ease reviews; r=ianbicking

MozReview-Commit-ID: 455LZbfCGfy

Differential Revision: https://phabricator.services.mozilla.com/D8506

--HG--
extra : rebase_source : 698bd15f7d81b9815a9f176359c28f2cc97132e4
extra : source : 01fa6937f05fc51562205eac8e895c62324452f8
This commit is contained in:
Jared Hirsch 2018-10-15 20:10:29 +00:00
Родитель 34900f4fc3
Коммит 849a6e51da
16 изменённых файлов: 108 добавлений и 108 удалений

Просмотреть файл

@ -16,7 +16,7 @@ this.analytics = (function() {
method: "POST",
mode: "cors",
headers: { "content-type": "application/json" },
credentials: "include"
credentials: "include",
};
function flushEvents() {
@ -63,7 +63,7 @@ this.analytics = (function() {
timingCategory,
timingLabel,
timingVar,
timingValue
timingValue,
});
if (!timingsTimeoutHandle) {
timingsTimeoutHandle = setTimeout(() => {
@ -115,7 +115,7 @@ this.analytics = (function() {
event: eventCategory,
action,
label,
options
options,
});
if (!eventsTimeoutHandle) {
eventsTimeoutHandle = setTimeout(() => {
@ -173,8 +173,8 @@ this.analytics = (function() {
cancel: [
{ action: "cancel-shot" },
{ action: "internal", label: "document-hidden" },
{ action: "internal", label: "unhide-onboarding-frame" }
]
{ action: "internal", label: "unhide-onboarding-frame" },
],
}, {
name: "context-menu",
start: { action: "start-shot", label: "context-menu" },
@ -182,8 +182,8 @@ this.analytics = (function() {
cancel: [
{ action: "cancel-shot" },
{ action: "internal", label: "document-hidden" },
{ action: "internal", label: "unhide-onboarding-frame" }
]
{ action: "internal", label: "unhide-onboarding-frame" },
],
}, {
name: "page-action-onboarding",
start: { action: "start-shot", label: "toolbar-button" },
@ -191,8 +191,8 @@ this.analytics = (function() {
cancel: [
{ action: "cancel-shot" },
{ action: "internal", label: "document-hidden" },
{ action: "internal", label: "unhide-preselection-frame" }
]
{ action: "internal", label: "unhide-preselection-frame" },
],
}, {
name: "context-menu-onboarding",
start: { action: "start-shot", label: "context-menu" },
@ -200,84 +200,84 @@ this.analytics = (function() {
cancel: [
{ action: "cancel-shot" },
{ action: "internal", label: "document-hidden" },
{ action: "internal", label: "unhide-preselection-frame" }
]
{ action: "internal", label: "unhide-preselection-frame" },
],
}, {
name: "capture-full-page",
start: { action: "capture-full-page" },
end: { action: "internal", label: "unhide-preview-frame" },
cancel: [
{ action: "cancel-shot" },
{ action: "internal", label: "document-hidden" }
]
{ action: "internal", label: "document-hidden" },
],
}, {
name: "capture-visible",
start: { action: "capture-visible" },
end: { action: "internal", label: "unhide-preview-frame" },
cancel: [
{ action: "cancel-shot" },
{ action: "internal", label: "document-hidden" }
]
{ action: "internal", label: "document-hidden" },
],
}, {
name: "make-selection",
start: { action: "make-selection" },
end: { action: "internal", label: "unhide-selection-frame" },
cancel: [
{ action: "cancel-shot" },
{ action: "internal", label: "document-hidden" }
]
{ action: "internal", label: "document-hidden" },
],
}, {
name: "save-shot",
start: { action: "save-shot" },
end: { action: "internal", label: "open-shot-tab" },
cancel: [{ action: "cancel-shot" }, { action: "upload-failed" }]
cancel: [{ action: "cancel-shot" }, { action: "upload-failed" }],
}, {
name: "save-visible",
start: { action: "save-visible" },
end: { action: "internal", label: "open-shot-tab" },
cancel: [{ action: "cancel-shot" }, { action: "upload-failed" }]
cancel: [{ action: "cancel-shot" }, { action: "upload-failed" }],
}, {
name: "save-full-page",
start: { action: "save-full-page" },
end: { action: "internal", label: "open-shot-tab" },
cancel: [{ action: "cancel-shot" }, { action: "upload-failed" }]
cancel: [{ action: "cancel-shot" }, { action: "upload-failed" }],
}, {
name: "save-full-page-truncated",
start: { action: "save-full-page-truncated" },
end: { action: "internal", label: "open-shot-tab" },
cancel: [{ action: "cancel-shot" }, { action: "upload-failed" }]
cancel: [{ action: "cancel-shot" }, { action: "upload-failed" }],
}, {
name: "download-shot",
start: { action: "download-shot" },
end: { action: "internal", label: "deactivate" },
cancel: [
{ action: "cancel-shot" },
{ action: "internal", label: "document-hidden" }
]
{ action: "internal", label: "document-hidden" },
],
}, {
name: "download-full-page",
start: { action: "download-full-page" },
end: { action: "internal", label: "deactivate" },
cancel: [
{ action: "cancel-shot" },
{ action: "internal", label: "document-hidden" }
]
{ action: "internal", label: "document-hidden" },
],
}, {
name: "download-full-page-truncated",
start: { action: "download-full-page-truncated" },
end: { action: "internal", label: "deactivate" },
cancel: [
{ action: "cancel-shot" },
{ action: "internal", label: "document-hidden" }
]
{ action: "internal", label: "document-hidden" },
],
}, {
name: "download-visible",
start: { action: "download-visible" },
end: { action: "internal", label: "deactivate" },
cancel: [
{ action: "cancel-shot" },
{ action: "internal", label: "document-hidden" }
]
{ action: "internal", label: "document-hidden" },
],
}];
// Match a filter (action and optional label) against an action and label.

Просмотреть файл

@ -40,7 +40,7 @@ this.auth = (function() {
const info = {
deviceId: `anon${makeUuid()}`,
secret: makeUuid(),
registered: false
registered: false,
};
return info;
}
@ -76,7 +76,7 @@ this.auth = (function() {
req.send(JSON.stringify({
deviceId: registrationInfo.deviceId,
secret: registrationInfo.secret,
deviceInfo: JSON.stringify(deviceInfo())
deviceInfo: JSON.stringify(deviceInfo()),
}));
});
}

Просмотреть файл

@ -27,7 +27,7 @@ this.deviceInfo = (function() {
// platformVersion: system.platformVersion,
userAgent: navigator.userAgent,
appVendor: appName,
appName
appName,
};
};

Просмотреть файл

@ -132,7 +132,7 @@ this.main = (function() {
return;
}
senderror.showError({
popupMessage: "UNSHOOTABLE_PAGE"
popupMessage: "UNSHOOTABLE_PAGE",
});
return;
}
@ -200,7 +200,7 @@ this.main = (function() {
type: "basic",
iconUrl: "../icons/copied-notification.svg",
title: browser.i18n.getMessage("notificationLinkCopiedTitle"),
message: browser.i18n.getMessage("notificationLinkCopiedDetails", pasteSymbol)
message: browser.i18n.getMessage("notificationLinkCopiedDetails", pasteSymbol),
});
}
return null;
@ -234,7 +234,7 @@ this.main = (function() {
type: "basic",
iconUrl: "../icons/copied-notification.svg",
title: browser.i18n.getMessage("notificationImageCopiedTitle"),
message: browser.i18n.getMessage("notificationImageCopiedDetails", pasteSymbol)
message: browser.i18n.getMessage("notificationImageCopiedDetails", pasteSymbol),
});
});
});
@ -261,7 +261,7 @@ this.main = (function() {
return browser.downloads.download({
url,
incognito: windowInfo.incognito,
filename: info.filename
filename: info.filename,
}).catch((error) => {
// We are not logging error message when user cancels download
if (error && error.message && !error.message.includes("canceled")) {
@ -286,7 +286,7 @@ this.main = (function() {
// Note, we only show the error but don't report it, as we know that we can't
// take shots of these pages:
senderror.showError({
popupMessage: "UNSHOOTABLE_PAGE"
popupMessage: "UNSHOOTABLE_PAGE",
});
});

Просмотреть файл

@ -19,7 +19,7 @@ this.selectorLoader = (function() {
"blobConverters.js",
"background/selectorLoader.js",
"selector/callBackground.js",
"selector/util.js"
"selector/util.js",
];
const selectorScripts = [
@ -33,20 +33,20 @@ this.selectorLoader = (function() {
"selector/documentMetadata.js",
"selector/ui.js",
"selector/shooter.js",
"selector/uicontrol.js"
"selector/uicontrol.js",
];
// These are loaded on request (by the selector worker) to activate the onboarding:
const onboardingScripts = [
"build/onboardingCss.js",
"build/onboardingHtml.js",
"onboarding/slides.js"
"onboarding/slides.js",
];
exports.unloadIfLoaded = function(tabId) {
return browser.tabs.executeScript(tabId, {
code: "this.selectorLoader && this.selectorLoader.unloadModules()",
runAt: "document_start"
runAt: "document_start",
}).then(result => {
return result && result[0];
});
@ -58,7 +58,7 @@ this.selectorLoader = (function() {
}
return browser.tabs.executeScript(tabId, {
code: "!!this.selectorLoader",
runAt: "document_start"
runAt: "document_start",
}).then(result => {
return result && result[0];
});
@ -100,7 +100,7 @@ this.selectorLoader = (function() {
// scripts, but not the scripts in the underlying page. For more
// details, see https://mdn.io/WebExtensions/Content_scripts#Content_script_environment
code: `window.downloadOnly = ${downloadOnly}`,
runAt: "document_start"
runAt: "document_start",
});
});
});
@ -114,7 +114,7 @@ this.selectorLoader = (function() {
lastPromise = lastPromise.then(() => {
return browser.tabs.executeScript(tabId, {
file,
runAt: "document_start"
runAt: "document_start",
}).catch((error) => {
log.error("error in script:", file, error);
error.scriptName = file;

Просмотреть файл

@ -13,42 +13,42 @@ this.senderror = (function() {
const messages = {
REQUEST_ERROR: {
title: browser.i18n.getMessage("requestErrorTitle"),
info: browser.i18n.getMessage("requestErrorDetails")
info: browser.i18n.getMessage("requestErrorDetails"),
},
CONNECTION_ERROR: {
title: browser.i18n.getMessage("connectionErrorTitle"),
info: browser.i18n.getMessage("connectionErrorDetails")
info: browser.i18n.getMessage("connectionErrorDetails"),
},
LOGIN_ERROR: {
title: browser.i18n.getMessage("requestErrorTitle"),
info: browser.i18n.getMessage("loginErrorDetails")
info: browser.i18n.getMessage("loginErrorDetails"),
},
LOGIN_CONNECTION_ERROR: {
title: browser.i18n.getMessage("connectionErrorTitle"),
info: browser.i18n.getMessage("connectionErrorDetails")
info: browser.i18n.getMessage("connectionErrorDetails"),
},
UNSHOOTABLE_PAGE: {
title: browser.i18n.getMessage("unshootablePageErrorTitle"),
info: browser.i18n.getMessage("unshootablePageErrorDetails")
info: browser.i18n.getMessage("unshootablePageErrorDetails"),
},
SHOT_PAGE: {
title: browser.i18n.getMessage("selfScreenshotErrorTitle")
title: browser.i18n.getMessage("selfScreenshotErrorTitle"),
},
MY_SHOTS: {
title: browser.i18n.getMessage("selfScreenshotErrorTitle")
title: browser.i18n.getMessage("selfScreenshotErrorTitle"),
},
EMPTY_SELECTION: {
title: browser.i18n.getMessage("emptySelectionErrorTitle")
title: browser.i18n.getMessage("emptySelectionErrorTitle"),
},
PRIVATE_WINDOW: {
title: browser.i18n.getMessage("privateWindowErrorTitle"),
info: browser.i18n.getMessage("privateWindowErrorDetails")
info: browser.i18n.getMessage("privateWindowErrorDetails"),
},
generic: {
title: browser.i18n.getMessage("genericErrorTitle"),
info: browser.i18n.getMessage("genericErrorDetails"),
showMessage: true
}
showMessage: true,
},
};
communication.register("reportError", (sender, error) => {
@ -82,7 +82,7 @@ this.senderror = (function() {
type: "basic",
// FIXME: need iconUrl for an image, see #2239
title,
message
message,
});
}
};
@ -123,7 +123,7 @@ this.senderror = (function() {
tags: {category: e.popupMessage},
release: manifest.version,
message: exception.message,
extra: rest
extra: rest,
});
};

Просмотреть файл

@ -26,7 +26,7 @@ this.startBackground = (function() {
"background/analytics.js",
"background/deviceInfo.js",
"background/takeshot.js",
"background/main.js"
"background/main.js",
];
browser.pageAction.onClicked.addListener(tab => {
@ -41,7 +41,7 @@ this.startBackground = (function() {
id: "create-screenshot",
title: browser.i18n.getMessage("contextMenuLabel"),
contexts: ["page"],
documentUrlPatterns: ["<all_urls>"]
documentUrlPatterns: ["<all_urls>"],
});
browser.contextMenus.onClicked.addListener((info, tab) => {

Просмотреть файл

@ -27,9 +27,9 @@ this.takeshot = (function() {
location: selectedPos,
dimensions: {
x: selectedPos.right - selectedPos.left,
y: selectedPos.bottom - selectedPos.top
}
}
y: selectedPos.bottom - selectedPos.top,
},
},
});
});
}
@ -94,7 +94,7 @@ this.takeshot = (function() {
top: pos.top - scroll.scrollY,
left: pos.left - scroll.scrollX,
bottom: pos.bottom - scroll.scrollY,
right: pos.right - scroll.scrollX
right: pos.right - scroll.scrollX,
};
pos.width = pos.right - pos.left;
pos.height = pos.bottom - pos.top;
@ -177,7 +177,7 @@ this.takeshot = (function() {
body = concatBuffers(body, tail.buffer);
return {
"content-type": `multipart/form-data; boundary=${boundary}`,
body
body,
};
});
}
@ -199,7 +199,7 @@ this.takeshot = (function() {
}
return {
"content-type": "application/json",
body: JSON.stringify(shot)
body: JSON.stringify(shot),
};
}).then((submission) => {
@ -209,7 +209,7 @@ this.takeshot = (function() {
method: "PUT",
mode: "cors",
headers,
body: submission.body
body: submission.body,
});
}).then((resp) => {
if (!resp.ok) {

Просмотреть файл

@ -62,7 +62,7 @@ this.selection = (function () {let exports={}; class Selection {
top: Math.floor(this.top),
left: Math.floor(this.left),
bottom: Math.floor(this.bottom),
right: Math.floor(this.right)
right: Math.floor(this.right),
};
}
@ -94,7 +94,7 @@ this.selection = (function () {let exports={}; class Selection {
left: this.left,
right: this.right,
top: this.top,
bottom: this.bottom
bottom: this.bottom,
};
}

Просмотреть файл

@ -48,7 +48,7 @@ function getThumbnailDimensions(imageWidth, imageHeight) {
width: thumbnailImageWidth,
height: thumbnailImageHeight,
scaledX,
scaledY
scaledY,
};
}

Просмотреть файл

@ -34,7 +34,7 @@ this.catcher = (function() {
fromMakeError: true,
name: exc.name || "ERROR",
message: String(exc),
stack: exc.stack
stack: exc.stack,
};
for (const attr in exc) {
result[attr] = exc[attr];

Просмотреть файл

@ -94,11 +94,11 @@ this.slides = (function() {
const sentinelSplitter = "!!!";
const linkTexts = {
[termsSentinel]: browser.i18n.getMessage("termsAndPrivacyNoticeTermsLink"),
[privacySentinel]: browser.i18n.getMessage("termsAndPrivacyNoticyPrivacyLink")
[privacySentinel]: browser.i18n.getMessage("termsAndPrivacyNoticyPrivacyLink"),
};
const linkUrls = {
[termsSentinel]: "https://www.mozilla.org/about/legal/terms/services/",
[privacySentinel]: "https://www.mozilla.org/privacy/firefox/"
[privacySentinel]: "https://www.mozilla.org/privacy/firefox/",
};
const text = browser.i18n.getMessage(
"termsAndPrivacyNotice2",

Просмотреть файл

@ -152,9 +152,9 @@ this.shooter = (function() { // eslint-disable-line no-unused-vars
location: selectedPos,
dimensions: {
x: selectedPos.right - selectedPos.left,
y: selectedPos.bottom - selectedPos.top
}
}
y: selectedPos.bottom - selectedPos.top,
},
},
});
}
catcher.watchPromise(callBackground("takeShot", {
@ -164,12 +164,12 @@ this.shooter = (function() { // eslint-disable-line no-unused-vars
scrollX: window.scrollX,
scrollY: window.scrollY,
innerHeight: window.innerHeight,
innerWidth: window.innerWidth
innerWidth: window.innerWidth,
},
selectedPos,
shotId: shotObject.id,
shot: shotObject.toJSON(),
imageBlob
imageBlob,
}).then((url) => {
return clipboard.copy(url).then((copied) => {
return callBackground("openShot", { url, copied });
@ -206,7 +206,7 @@ this.shooter = (function() { // eslint-disable-line no-unused-vars
scrollX: window.scrollX,
scrollY: window.scrollY,
innerHeight: window.innerHeight,
innerWidth: window.innerWidth
innerWidth: window.innerWidth,
});
}
catcher.watchPromise(promise.then((dataUrl) => {
@ -218,8 +218,8 @@ this.shooter = (function() { // eslint-disable-line no-unused-vars
image: {
url: dataUrl,
type,
location: selectedPos
}
location: selectedPos,
},
});
ui.triggerDownload(dataUrl, shotObject.filename);
uicontrol.deactivate();
@ -272,7 +272,7 @@ this.shooter = (function() { // eslint-disable-line no-unused-vars
backend,
randomString(RANDOM_STRING_LENGTH) + "/" + domainFromUrl(location),
{
origin: shot.originFromUrl(location.href)
origin: shot.originFromUrl(location.href),
}
);
shotObject.update(documentMetadata());

Просмотреть файл

@ -130,7 +130,7 @@ this.ui = (function() { // eslint-disable-line no-unused-vars
timer: null,
windowDelayer: null,
lastHeight: null,
lastWidth: null
lastWidth: null,
},
document: null,
display(installHandlerOnDocument) {
@ -262,7 +262,7 @@ this.ui = (function() { // eslint-disable-line no-unused-vars
this.stopSizeWatch();
util.removeNode(this.element);
this.element = this.document = null;
}
},
};
iframeSelection.onResize = watchFunction(assertIsTrusted(onResize.bind(iframeSelection)), true);
@ -376,7 +376,7 @@ this.ui = (function() { // eslint-disable-line no-unused-vars
util.removeNode(this.element);
this.element = null;
this.document = null;
}
},
};
const iframePreview = exports.iframePreview = {
@ -480,7 +480,7 @@ this.ui = (function() { // eslint-disable-line no-unused-vars
util.removeNode(this.element);
this.element = null;
this.document = null;
}
},
};
iframePreSelection.onResize = watchFunction(onResize.bind(iframePreSelection), true);
@ -544,7 +544,7 @@ this.ui = (function() { // eslint-disable-line no-unused-vars
}
this.currentIframe = iframePreview;
this.unhide();
}
},
};
const movements = ["topLeft", "top", "topRight", "left", "right", "bottomLeft", "bottom", "bottomRight"];
@ -815,7 +815,7 @@ this.ui = (function() { // eslint-disable-line no-unused-vars
boxTopEl: null,
boxLeftEl: null,
boxRightEl: null,
boxBottomEl: null
boxBottomEl: null,
};
exports.HoverBox = {
@ -846,7 +846,7 @@ this.ui = (function() { // eslint-disable-line no-unused-vars
remove() {
util.removeNode(this.el);
this.el = null;
}
},
};
exports.PixelDimensions = {
@ -870,7 +870,7 @@ this.ui = (function() { // eslint-disable-line no-unused-vars
remove() {
util.removeNode(this.el);
this.el = this.xEl = this.yEl = null;
}
},
};
exports.Preview = {
@ -890,7 +890,7 @@ this.ui = (function() { // eslint-disable-line no-unused-vars
contentCell[0].textContent = browser.i18n.getMessage("imageCropPopupWarning", buildSettings.maxImageHeight);
iframe.document().querySelector(".preview-buttons").appendChild(imageCroppedEl);
}
}
},
};
/** Removes every UI this module creates */

Просмотреть файл

@ -74,7 +74,7 @@ this.uicontrol = (function() {
function eventOptionsForBox(box) {
return {
cd1: round10(Math.abs(box.bottom - box.top)),
cd2: round10(Math.abs(box.right - box.left))
cd2: round10(Math.abs(box.right - box.left)),
};
}
@ -85,14 +85,14 @@ this.uicontrol = (function() {
- (boxStart.bottom - boxStart.top)),
cd2: round10(
(boxEnd.right - boxEnd.left)
- (boxStart.right - boxStart.left))
- (boxStart.right - boxStart.left)),
};
}
function eventOptionsForMove(posStart, posEnd) {
return {
cd1: round10(posEnd.y - posStart.y),
cd2: round10(posEnd.x - posStart.x)
cd2: round10(posEnd.x - posStart.x),
};
}
@ -125,7 +125,7 @@ this.uicontrol = (function() {
bottomLeft: ["x1", "y2"],
bottom: [null, "y2"],
bottomRight: ["x2", "y2"],
move: ["*", "*"]
move: ["*", "*"],
};
const doNotAutoselectTags = {
@ -134,7 +134,7 @@ this.uicontrol = (function() {
H3: true,
H4: true,
H5: true,
H6: true
H6: true,
};
let captureType;
@ -161,7 +161,7 @@ this.uicontrol = (function() {
}, copy: () => {
sendEvent("copy-shot", "overlay-copy-button");
copyShot();
}
},
};
const standardOverlayCallbacks = {
@ -225,7 +225,7 @@ this.uicontrol = (function() {
onCopyPreview: () => {
sendEvent(`copy-${captureType.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase()}`, "copy-preview-button");
copyShot();
}
},
};
/** Holds all the objects that handle events for each state: */
@ -291,7 +291,7 @@ this.uicontrol = (function() {
dataUrl = shooter.screenshotPage(selectedPos, captureType);
ui.iframe.usePreview();
ui.Preview.display(dataUrl, captureType === "fullPageTruncated");
}
},
};
stateHandlers.onboarding = {
@ -301,7 +301,7 @@ this.uicontrol = (function() {
}
sendEvent("internal", "unhide-onboarding-frame");
catcher.watchPromise(slides.display({
onEnd: this.slidesOnEnd.bind(this)
onEnd: this.slidesOnEnd.bind(this),
}));
},
@ -312,7 +312,7 @@ this.uicontrol = (function() {
end() {
slides.remove();
}
},
};
stateHandlers.crosshairs = {
@ -499,7 +499,7 @@ this.uicontrol = (function() {
end() {
ui.HoverBox.remove();
ui.PixelDimensions.remove();
}
},
};
stateHandlers.draggingReady = {
@ -590,7 +590,7 @@ this.uicontrol = (function() {
end() {
mouseupNoAutoselect = false;
}
},
};
@ -619,14 +619,14 @@ this.uicontrol = (function() {
top: selectedPos.y1,
bottom: selectedPos.y2,
left: selectedPos.x1,
right: selectedPos.x2
right: selectedPos.x2,
}));
setState("selected");
},
end() {
ui.PixelDimensions.remove();
}
},
};
stateHandlers.selected = {
@ -653,7 +653,7 @@ this.uicontrol = (function() {
}
event.preventDefault();
return false;
}
},
};
stateHandlers.resizing = {
@ -732,14 +732,14 @@ this.uicontrol = (function() {
resizeDirection = resizeStartPos = resizeStartSelected = null;
selectedPos.sortCoords();
ui.PixelDimensions.remove();
}
},
};
stateHandlers.cancel = {
start() {
ui.iframe.hide();
ui.Box.remove();
}
},
};
function getDocumentWidth() {

Просмотреть файл

@ -46,7 +46,7 @@ this.util = (function() { // eslint-disable-line no-unused-vars
top: elBox.top + scrollY,
bottom: elBox.bottom + scrollY,
left: elBox.left + scrollX,
right: elBox.right + scrollX
right: elBox.right + scrollX,
};
if (elBox.bottom < box.top ||
elBox.top > box.bottom ||