Skip to content
This repository has been archived by the owner on Jan 17, 2023. It is now read-only.

Commit

Permalink
Use double quotes. (#3977)
Browse files Browse the repository at this point in the history
  • Loading branch information
chenba committed Feb 2, 2018
1 parent 35f01a4 commit 2764e9d
Show file tree
Hide file tree
Showing 50 changed files with 292 additions and 293 deletions.
1 change: 0 additions & 1 deletion .eslintrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ rules:
no-console: [error, {allow: [debug, error, info, trace, warn]}]
no-var: error
prefer-const: error
quotes: [off, double] # TODO: change to "error"

promise/always-return: off
promise/avoid-new: off
Expand Down
2 changes: 1 addition & 1 deletion addon/bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ function handleMessage(msg, sender, sendReply) {
const telemetryEnabled = getBoolPref(TELEMETRY_ENABLED_PREF);
sendReply({type: "success", value: telemetryEnabled});
} else if (msg.funcName === "isUploadDisabled") {
const isESR = AppConstants.MOZ_UPDATE_CHANNEL === 'esr';
const isESR = AppConstants.MOZ_UPDATE_CHANNEL === "esr";
const uploadDisabled = getBoolPref(UPLOAD_DISABLED_PREF);
sendReply({type: "success", value: uploadDisabled || isESR});
} else if (msg.funcName === "isHistoryEnabled") {
Expand Down
2 changes: 1 addition & 1 deletion addon/webextension/assertIsBlankDocument.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/
this.assertIsBlankDocument = function assertIsBlankDocument(doc) {
if (doc.documentURI !== browser.extension.getURL("blank.html")) {
const exc = new Error('iframe URL does not match expected blank.html');
const exc = new Error("iframe URL does not match expected blank.html");
exc.foundURL = doc.documentURI;
throw exc;
}
Expand Down
110 changes: 55 additions & 55 deletions addon/webextension/background/analytics.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ this.analytics = (function() {

pendingEvents.forEach(event => {
event.queueTime = sendTime - event.eventTime
log.info(`sendEvent ${event.event}/${event.action}/${event.label || 'none'} ${JSON.stringify(event.options)}`);
log.info(`sendEvent ${event.event}/${event.action}/${event.label || "none"} ${JSON.stringify(event.options)}`);
});

const body = JSON.stringify({deviceId, events: pendingEvents});
Expand Down Expand Up @@ -80,13 +80,13 @@ this.analytics = (function() {
return Promise.resolve();
}
if (!telemetryEnabled) {
log.info(`Cancelled sendEvent ${eventCategory}/${action}/${label || 'none'} ${JSON.stringify(options)}`);
log.info(`Cancelled sendEvent ${eventCategory}/${action}/${label || "none"} ${JSON.stringify(options)}`);
return Promise.resolve();
}
measureTiming(action, label);
// Internal-only events are used for measuring time between events,
// but aren't submitted to GA.
if (action === 'internal') {
if (action === "internal") {
return Promise.resolve();
}
if (typeof label === "object" && (!options)) {
Expand Down Expand Up @@ -159,70 +159,70 @@ this.analytics = (function() {
// If a cancel event happens between the start and end events, the start time
// is deleted.
const rules = [{
name: 'page-action',
start: { action: 'start-shot', label: 'toolbar-button' },
end: { action: 'internal', label: 'unhide-preselection-frame' },
cancel: [{ action: 'cancel-shot' }]
name: "page-action",
start: { action: "start-shot", label: "toolbar-button" },
end: { action: "internal", label: "unhide-preselection-frame" },
cancel: [{ action: "cancel-shot" }]
}, {
name: 'context-menu',
start: { action: 'start-shot', label: 'context-menu' },
end: { action: 'internal', label: 'unhide-preselection-frame' },
cancel: [{ action: 'cancel-shot' }]
name: "context-menu",
start: { action: "start-shot", label: "context-menu" },
end: { action: "internal", label: "unhide-preselection-frame" },
cancel: [{ action: "cancel-shot" }]
}, {
name: 'capture-full-page',
start: { action: 'capture-full-page' },
end: { action: 'internal', label: 'unhide-preview-frame' },
cancel: [{ action: 'cancel-shot' }]
name: "capture-full-page",
start: { action: "capture-full-page" },
end: { action: "internal", label: "unhide-preview-frame" },
cancel: [{ action: "cancel-shot" }]
}, {
name: 'capture-visible',
start: { action: 'capture-visible' },
end: { action: 'internal', label: 'unhide-preview-frame' },
cancel: [{ action: 'cancel-shot' }]
name: "capture-visible",
start: { action: "capture-visible" },
end: { action: "internal", label: "unhide-preview-frame" },
cancel: [{ action: "cancel-shot" }]
}, {
name: 'make-selection',
start: { action: 'make-selection' },
end: { action: 'internal', label: 'unhide-selection-frame' },
cancel: [{ action: 'cancel-shot' }]
name: "make-selection",
start: { action: "make-selection" },
end: { action: "internal", label: "unhide-selection-frame" },
cancel: [{ action: "cancel-shot" }]
}, {
name: 'save-shot',
start: { action: 'save-shot' },
end: { action: 'internal', label: 'open-shot-tab' },
cancel: [{ action: 'cancel-shot' }, { action: 'upload-failed' }]
name: "save-shot",
start: { action: "save-shot" },
end: { action: "internal", label: "open-shot-tab" },
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' }]
name: "save-visible",
start: { action: "save-visible" },
end: { action: "internal", label: "open-shot-tab" },
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' }]
name: "save-full-page",
start: { action: "save-full-page" },
end: { action: "internal", label: "open-shot-tab" },
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' }]
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" }]
}, {
name: 'download-shot',
start: { action: 'download-shot' },
end: { action: 'internal', label: 'deactivate' },
cancel: [{ action: 'cancel-shot' }]
name: "download-shot",
start: { action: "download-shot" },
end: { action: "internal", label: "deactivate" },
cancel: [{ action: "cancel-shot" }]
}, {
name: 'download-full-page',
start: { action: 'download-full-page' },
end: { action: 'internal', label: 'deactivate' },
cancel: [{ action: 'cancel-shot' }]
name: "download-full-page",
start: { action: "download-full-page" },
end: { action: "internal", label: "deactivate" },
cancel: [{ action: "cancel-shot" }]
}, {
name: 'download-full-page-truncated',
start: { action: 'download-full-page-truncated' },
end: { action: 'internal', label: 'deactivate' },
cancel: [{ action: 'cancel-shot' }]
name: "download-full-page-truncated",
start: { action: "download-full-page-truncated" },
end: { action: "internal", label: "deactivate" },
cancel: [{ action: "cancel-shot" }]
}, {
name: 'download-visible',
start: { action: 'download-visible' },
end: { action: 'internal', label: 'deactivate' },
cancel: [{ action: 'cancel-shot' }]
name: "download-visible",
start: { action: "download-visible" },
end: { action: "internal", label: "deactivate" },
cancel: [{ action: "cancel-shot" }]
}];

// Match a filter (action and optional label) against an action and label.
Expand Down
4 changes: 2 additions & 2 deletions addon/webextension/background/communication.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ this.communication = (function() {
if (result.type === "success") {
return result.value;
}
throw new Error(`Error in ${funcName}: ${result.name || 'unknown'}`);
throw new Error(`Error in ${funcName}: ${result.name || "unknown"}`);
}, (error) => {
if (isBootstrapMissingError(error)) {
return exports.NO_BOOTSTRAP;
Expand All @@ -66,7 +66,7 @@ this.communication = (function() {
if (!error) {
return false;
}
return ('errorCode' in error && error.errorCode === "NO_RECEIVING_END") ||
return ("errorCode" in error && error.errorCode === "NO_RECEIVING_END") ||
(!error.errorCode && error.message === "Could not establish connection. Receiving end does not exist.");
}

Expand Down
4 changes: 2 additions & 2 deletions addon/webextension/background/senderror.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ this.senderror = (function() {
popupMessage = "generic";
}
const title = messages[popupMessage].title;
let message = messages[popupMessage].info || '';
let message = messages[popupMessage].info || "";
const showMessage = messages[popupMessage].showMessage;
if (error.message && showMessage) {
if (message) {
Expand Down Expand Up @@ -119,7 +119,7 @@ this.senderror = (function() {
}
rest.stack = exception.stack;
Raven.captureException(exception, {
logger: 'addon',
logger: "addon",
tags: {category: e.popupMessage},
release: manifest.version,
message: exception.message,
Expand Down
2 changes: 1 addition & 1 deletion addon/webextension/background/takeshot.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ this.takeshot = (function() {
return browser.tabs.create({url: shot.creatingUrl})
}).then((tab) => {
openedTab = tab;
sendEvent('internal', 'open-shot-tab');
sendEvent("internal", "open-shot-tab");
return uploadShot(shot, imageBlob, thumbnailBlob);
}).then(() => {
return browser.tabs.update(openedTab.id, {url: shot.viewUrl, loadReplace: true}).then(
Expand Down
8 changes: 4 additions & 4 deletions addon/webextension/blobConverters.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ this.blobConverters = (function() {
const exports = {};

exports.dataUrlToBlob = function(url) {
const binary = atob(url.split(',', 2)[1]);
const binary = atob(url.split(",", 2)[1]);
let contentType = exports.getTypeFromDataUrl(url);
if (contentType !== "image/png" && contentType !== "image/jpeg") {
contentType = "image/png";
Expand All @@ -13,9 +13,9 @@ this.blobConverters = (function() {
};

exports.getTypeFromDataUrl = function(url) {
let contentType = url.split(',', 1)[0];
contentType = contentType.split(';', 1)[0];
contentType = contentType.split(':', 2)[1];
let contentType = url.split(",", 1)[0];
contentType = contentType.split(";", 1)[0];
contentType = contentType.split(":", 2)[1];
return contentType;
};

Expand Down
4 changes: 2 additions & 2 deletions addon/webextension/makeUuid.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ this.makeUuid = (function() {
.crypto
.getRandomValues(new Uint8Array(36));

return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(c) {
const i = Array.prototype.slice.call(arguments).slice(-2)[0]; // grab the `offset` parameter
const r = randomValues[i] % 16|0, v = c === 'x' ? r : (r & 0x3 | 0x8);
const r = randomValues[i] % 16|0, v = c === "x" ? r : (r & 0x3 | 0x8);
return v.toString(16);
});
};
Expand Down
2 changes: 1 addition & 1 deletion addon/webextension/onboarding/slides.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ this.slides = (function() {
iframe.style.margin = "0";
iframe.scrolling = "no";
updateIframeSize();
let html = onboardingHtml.replace('<style></style>', `<style>${onboardingCss}</style>`);
let html = onboardingHtml.replace("<style></style>", `<style>${onboardingCss}</style>`);
html = html.replace(/MOZ_EXTENSION([^"]+)/g, (match, filename) => {
return browser.extension.getURL(filename);
});
Expand Down
4 changes: 2 additions & 2 deletions addon/webextension/selector/callBackground.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ this.callBackground = function callBackground(funcName, ...args) {
} else if (result && result.type === "error") {
const exc = new Error(result.message || "Unknown error");
exc.name = "BackgroundError";
if ('errorCode' in result) {
if ("errorCode" in result) {
exc.errorCode = result.errorCode;
}
if ('popupMessage' in result) {
if ("popupMessage" in result) {
exc.popupMessage = result.popupMessage;
}
throw exc;
Expand Down
20 changes: 10 additions & 10 deletions addon/webextension/selector/shooter.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ this.shooter = (function() { // eslint-disable-line no-unused-vars
}

function sanitizeError(data) {
const href = new RegExp(regexpEscape(window.location.href), 'g');
const origin = new RegExp(`${regexpEscape(window.location.origin)}[^ \t\n\r",>]*`, 'g');
const href = new RegExp(regexpEscape(window.location.href), "g");
const origin = new RegExp(`${regexpEscape(window.location.origin)}[^ \t\n\r",>]*`, "g");
const json = JSON.stringify(data)
.replace(href, 'REDACTED_HREF')
.replace(origin, 'REDACTED_URL');
.replace(href, "REDACTED_HREF")
.replace(origin, "REDACTED_URL");
const result = JSON.parse(json);
return result;
}
Expand All @@ -34,8 +34,8 @@ this.shooter = (function() { // eslint-disable-line no-unused-vars
});

catcher.watchFunction(() => {
const canvas = document.createElementNS('http://www.w3.org/1999/xhtml', 'canvas');
const ctx = canvas.getContext('2d');
const canvas = document.createElementNS("http://www.w3.org/1999/xhtml", "canvas");
const ctx = canvas.getContext("2d");
supportsDrawWindow = !!ctx.drawWindow;
})();

Expand All @@ -45,10 +45,10 @@ this.shooter = (function() { // eslint-disable-line no-unused-vars
}
const height = selectedPos.bottom - selectedPos.top;
const width = selectedPos.right - selectedPos.left;
const canvas = document.createElementNS('http://www.w3.org/1999/xhtml', 'canvas');
const ctx = canvas.getContext('2d');
const canvas = document.createElementNS("http://www.w3.org/1999/xhtml", "canvas");
const ctx = canvas.getContext("2d");
let expand = window.devicePixelRatio !== 1;
if (captureType === 'fullPage' || captureType === 'fullPageTruncated') {
if (captureType === "fullPage" || captureType === "fullPageTruncated") {
expand = false;
canvas.width = width;
canvas.height = height;
Expand Down Expand Up @@ -144,7 +144,7 @@ this.shooter = (function() { // eslint-disable-line no-unused-vars
return callBackground("openShot", { url, copied });
});
}, (error) => {
if ('popupMessage' in error && (error.popupMessage === "REQUEST_ERROR" || error.popupMessage === 'CONNECTION_ERROR')) {
if ("popupMessage" in error && (error.popupMessage === "REQUEST_ERROR" || error.popupMessage === "CONNECTION_ERROR")) {
// The error has been signaled to the user, but unlike other errors (or
// success) we should not abort the selection
deactivateAfterFinish = false;
Expand Down
Loading

0 comments on commit 2764e9d

Please sign in to comment.