Bug 1705751: fix Remove Buildsettings Code from Screenshots r=emalysz

Differential Revision: https://phabricator.services.mozilla.com/D112415
This commit is contained in:
Falguni Islam 2021-04-28 21:44:00 +00:00
Родитель 959874613b
Коммит 728a6f9073
12 изменённых файлов: 14 добавлений и 34 удалений

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

@ -3,7 +3,7 @@
* You can obtain one at http://mozilla.org/MPL/2.0/. */ * You can obtain one at http://mozilla.org/MPL/2.0/. */
/* globals log */ /* globals log */
/* globals main, makeUuid, deviceInfo, analytics, catcher, buildSettings, communication, browser */ /* globals main, makeUuid, deviceInfo, analytics, catcher, communication, browser */
"use strict"; "use strict";
@ -177,7 +177,7 @@ this.auth = (function() {
}; };
exports.getSentryPublicDSN = function() { exports.getSentryPublicDSN = function() {
return sentryPublicDSN || buildSettings.defaultSentryDsn; return sentryPublicDSN;
}; };
exports.getAbTests = function() { exports.getAbTests = function() {

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

@ -2,12 +2,13 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this file, * 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/. */ * You can obtain one at http://mozilla.org/MPL/2.0/. */
/* globals browser, getStrings, selectorLoader, analytics, communication, catcher, log, makeUuid, auth, senderror, startBackground, blobConverters buildSettings, startSelectionWithOnboarding */ /* globals browser, getStrings, selectorLoader, analytics, communication, catcher, log, makeUuid, auth, senderror, startBackground, blobConverters, startSelectionWithOnboarding */
"use strict"; "use strict";
this.main = (function() { this.main = (function() {
const exports = {}; const exports = {};
const pngToJpegCutoff = 2500000;
const { sendEvent, incrementCount } = analytics; const { sendEvent, incrementCount } = analytics;
@ -182,8 +183,7 @@ this.main = (function() {
canvas.getContext("2d").putImageData(imageData, 0, 0); canvas.getContext("2d").putImageData(imageData, 0, 0);
let dataUrl = canvas.toDataURL(); let dataUrl = canvas.toDataURL();
if ( if (
buildSettings.pngToJpegCutoff && dataUrl.length > pngToJpegCutoff
dataUrl.length > buildSettings.pngToJpegCutoff
) { ) {
const jpegDataUrl = canvas.toDataURL("image/jpeg"); const jpegDataUrl = canvas.toDataURL("image/jpeg");
if (jpegDataUrl.length < dataUrl.length) { if (jpegDataUrl.length < dataUrl.length) {

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

@ -15,7 +15,6 @@ this.selectorLoader = (function() {
// These modules are loaded in order, first standardScripts and then selectorScripts // These modules are loaded in order, first standardScripts and then selectorScripts
// The order is important due to dependencies // The order is important due to dependencies
const standardScripts = [ const standardScripts = [
"build/buildSettings.js",
"log.js", "log.js",
"catcher.js", "catcher.js",
"assertIsTrusted.js", "assertIsTrusted.js",

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

@ -2,7 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this file, * 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/. */ * You can obtain one at http://mozilla.org/MPL/2.0/. */
/* globals browser, communication, shot, main, auth, catcher, analytics, buildSettings, blobConverters, thumbnailGenerator */ /* globals browser, communication, shot, main, auth, catcher, analytics, blobConverters, thumbnailGenerator */
"use strict"; "use strict";

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

@ -1,14 +0,0 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* 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/. */
window.buildSettings = {
defaultSentryDsn: "",
logLevel: "" || "warn",
captureText: "" === "true",
uploadBinary: "" === "true",
pngToJpegCutoff: parseInt("" || 2500000, 10),
maxImageHeight: parseInt("" || 10000, 10),
maxImageWidth: parseInt("" || 10000, 10),
};
null;

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

@ -9,17 +9,15 @@
this.log = (function() { this.log = (function() {
const exports = {}; const exports = {};
const logLevel = "warn";
const levels = ["debug", "info", "warn", "error"]; const levels = ["debug", "info", "warn", "error"];
if (!levels.includes(buildSettings.logLevel)) {
console.warn("Invalid buildSettings.logLevel:", buildSettings.logLevel);
}
const shouldLog = {}; const shouldLog = {};
{ {
let startLogging = false; let startLogging = false;
for (const level of levels) { for (const level of levels) {
if (buildSettings.logLevel === level) { if (logLevel === level) {
startLogging = true; startLogging = true;
} }
if (startLogging) { if (startLogging) {

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

@ -15,7 +15,6 @@
"l10n_resources": [ "browser/screenshots.ftl" ], "l10n_resources": [ "browser/screenshots.ftl" ],
"background": { "background": {
"scripts": [ "scripts": [
"build/buildSettings.js",
"background/startBackground.js" "background/startBackground.js"
] ]
}, },
@ -31,7 +30,6 @@
{ {
"matches": ["https://screenshots.firefox.com/*"], "matches": ["https://screenshots.firefox.com/*"],
"js": [ "js": [
"build/buildSettings.js",
"log.js", "log.js",
"catcher.js", "catcher.js",
"selector/callBackground.js", "selector/callBackground.js",

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

@ -38,7 +38,6 @@ FINAL_TARGET_FILES.features["screenshots@mozilla.org"]["background"] += [
] ]
FINAL_TARGET_FILES.features["screenshots@mozilla.org"]["build"] += [ FINAL_TARGET_FILES.features["screenshots@mozilla.org"]["build"] += [
"build/buildSettings.js",
"build/inlineSelectionCss.js", "build/inlineSelectionCss.js",
"build/raven.js", "build/raven.js",
"build/selection.js", "build/selection.js",

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

@ -3,7 +3,7 @@
* You can obtain one at http://mozilla.org/MPL/2.0/. */ * You can obtain one at http://mozilla.org/MPL/2.0/. */
/* globals global, browser, documentMetadata, util, uicontrol, ui, catcher */ /* globals global, browser, documentMetadata, util, uicontrol, ui, catcher */
/* globals buildSettings, domainFromUrl, randomString, shot, blobConverters */ /* globals domainFromUrl, randomString, shot, blobConverters */
"use strict"; "use strict";

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

@ -2,7 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this file, * 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/. */ * You can obtain one at http://mozilla.org/MPL/2.0/. */
/* globals browser, log, util, catcher, inlineSelectionCss, callBackground, assertIsTrusted, assertIsBlankDocument, buildSettings blobConverters */ /* globals browser, log, util, catcher, inlineSelectionCss, callBackground, assertIsTrusted, assertIsBlankDocument, blobConverters */
"use strict"; "use strict";

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

@ -3,7 +3,7 @@
* You can obtain one at http://mozilla.org/MPL/2.0/. */ * You can obtain one at http://mozilla.org/MPL/2.0/. */
/* globals log, catcher, util, ui, slides, global */ /* globals log, catcher, util, ui, slides, global */
/* globals shooter, callBackground, selectorLoader, assertIsTrusted, buildSettings, selection */ /* globals shooter, callBackground, selectorLoader, assertIsTrusted, selection */
"use strict"; "use strict";
@ -49,8 +49,8 @@ this.uicontrol = (function() {
const { watchFunction, watchPromise } = catcher; const { watchFunction, watchPromise } = catcher;
const MAX_PAGE_HEIGHT = buildSettings.maxImageHeight; const MAX_PAGE_HEIGHT = 10000;
const MAX_PAGE_WIDTH = buildSettings.maxImageWidth; const MAX_PAGE_WIDTH = 10000;
// An autoselection smaller than these will be ignored entirely: // An autoselection smaller than these will be ignored entirely:
const MIN_DETECT_ABSOLUTE_HEIGHT = 10; const MIN_DETECT_ABSOLUTE_HEIGHT = 10;
const MIN_DETECT_ABSOLUTE_WIDTH = 30; const MIN_DETECT_ABSOLUTE_WIDTH = 30;

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

@ -13,7 +13,7 @@ const L10N = new LocalizationHelper(STRINGS_URI);
// These values are used to truncate the resulting image if the captured area is bigger. // These values are used to truncate the resulting image if the captured area is bigger.
// This is to avoid failing to produce a screenshot at all. // This is to avoid failing to produce a screenshot at all.
// It is recommended to keep these values in sync with the corresponding screenshots addon // It is recommended to keep these values in sync with the corresponding screenshots addon
// values in /browser/extensions/screenshots/build/buildSettings.js // values in /browser/extensions/screenshots/selector/uicontrol.js
const MAX_IMAGE_WIDTH = 10000; const MAX_IMAGE_WIDTH = 10000;
const MAX_IMAGE_HEIGHT = 10000; const MAX_IMAGE_HEIGHT = 10000;