diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-21 05:21:19 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-21 05:21:19 +0000 |
commit | 520a92573ce79e3628762e4ce06e284d50c2e548 (patch) | |
tree | dd7bece82fdce266f06a6a2a6043264255631ee7 /toolkit | |
parent | Adding debian version 115.10.0esr-1~deb12u1. (diff) | |
download | firefox-esr-520a92573ce79e3628762e4ce06e284d50c2e548.tar.xz firefox-esr-520a92573ce79e3628762e4ce06e284d50c2e548.zip |
Merging upstream version 115.11.0esr.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'toolkit')
11 files changed, 232 insertions, 113 deletions
diff --git a/toolkit/components/extensions/Extension.sys.mjs b/toolkit/components/extensions/Extension.sys.mjs index caff299eb6..e773745c65 100644 --- a/toolkit/components/extensions/Extension.sys.mjs +++ b/toolkit/components/extensions/Extension.sys.mjs @@ -1224,7 +1224,8 @@ export class ExtensionData { let { manifest } = this; if ( !manifest.background || - manifest.background.service_worker || + (manifest.background.service_worker && + WebExtensionPolicy.backgroundServiceWorkerEnabled) || this.manifestVersion > 2 ) { return false; diff --git a/toolkit/components/extensions/parent/ext-backgroundPage.js b/toolkit/components/extensions/parent/ext-backgroundPage.js index 725be65122..568d049b9d 100644 --- a/toolkit/components/extensions/parent/ext-backgroundPage.js +++ b/toolkit/components/extensions/parent/ext-backgroundPage.js @@ -264,7 +264,9 @@ this.backgroundPage = class extends ExtensionAPI { let { manifest } = extension; extension.backgroundState = BACKGROUND_STATE.STARTING; - this.isWorker = Boolean(manifest.background.service_worker); + this.isWorker = + !!manifest.background.service_worker && + WebExtensionPolicy.backgroundServiceWorkerEnabled; let BackgroundClass = this.isWorker ? BackgroundWorker : BackgroundPage; diff --git a/toolkit/components/extensions/parent/ext-runtime.js b/toolkit/components/extensions/parent/ext-runtime.js index cd18e0f0aa..2122e8faed 100644 --- a/toolkit/components/extensions/parent/ext-runtime.js +++ b/toolkit/components/extensions/parent/ext-runtime.js @@ -237,9 +237,12 @@ this.runtime = class extends ExtensionAPIPersistent { }, async internalWakeupBackground() { + const { background } = extension.manifest; if ( - extension.manifest.background && - !extension.manifest.background.service_worker && + background && + (background.page || background.scripts) && + // Note: if background.service_worker is specified, it takes + // precedence over page/scripts, and persistentBackground is false. !extension.persistentBackground ) { await extension.wakeupBackground(); diff --git a/toolkit/components/extensions/test/xpcshell/test_ext_background_script_and_service_worker.js b/toolkit/components/extensions/test/xpcshell/test_ext_background_script_and_service_worker.js new file mode 100644 index 0000000000..fc59b1810d --- /dev/null +++ b/toolkit/components/extensions/test/xpcshell/test_ext_background_script_and_service_worker.js @@ -0,0 +1,81 @@ +/* -*- Mode: indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* vim: set sts=2 sw=2 et tw=80: */ +"use strict"; + +async function testExtensionWithBackground({ + with_scripts = false, + with_service_worker = false, + with_page = false, + expected_background_type, + expected_manifest_warnings = [], +}) { + let background = {}; + if (with_scripts) { + background.scripts = ["scripts.js"]; + } + if (with_service_worker) { + background.service_worker = "sw.js"; + } + if (with_page) { + background.page = "page.html"; + } + let extension = ExtensionTestUtils.loadExtension({ + manifest: { background }, + files: { + "scripts.js": () => { + browser.test.sendMessage("from_bg", "scripts"); + }, + "sw.js": () => { + browser.test.sendMessage("from_bg", "service_worker"); + }, + "page.html": `<!DOCTYPE html><script src="page.js"></script>`, + "page.js": () => { + browser.test.sendMessage("from_bg", "page"); + }, + }, + }); + ExtensionTestUtils.failOnSchemaWarnings(false); + await extension.startup(); + ExtensionTestUtils.failOnSchemaWarnings(true); + Assert.deepEqual( + extension.extension.warnings, + expected_manifest_warnings, + "Expected manifest warnings" + ); + info("Waiting for background to start"); + Assert.equal( + await extension.awaitMessage("from_bg"), + expected_background_type, + "Expected background type" + ); + await extension.unload(); +} + +add_task(async function test_page_and_scripts() { + await testExtensionWithBackground({ + with_page: true, + with_scripts: true, + // Should be expected_background_type: "scripts", not "page". + // https://github.com/w3c/webextensions/issues/282#issuecomment-1443332913 + // ... but changing that may potentially affect backcompat of existing + // Firefox add-ons. + expected_background_type: "page", + expected_manifest_warnings: [ + "Reading manifest: Warning processing background.scripts: An unexpected property was found in the WebExtension manifest.", + ], + }); +}); + +add_task( + { skip_if: () => WebExtensionPolicy.backgroundServiceWorkerEnabled }, + async function test_scripts_and_service_worker_when_sw_disabled() { + await testExtensionWithBackground({ + with_scripts: true, + with_service_worker: true, + expected_background_type: "scripts", + expected_manifest_warnings: [ + "Reading manifest: Warning processing background.service_worker: An unexpected property was found in the WebExtension manifest.", + ], + }); + } +); diff --git a/toolkit/components/extensions/test/xpcshell/xpcshell-common.ini b/toolkit/components/extensions/test/xpcshell/xpcshell-common.ini index f76456124d..81beee5810 100644 --- a/toolkit/components/extensions/test/xpcshell/xpcshell-common.ini +++ b/toolkit/components/extensions/test/xpcshell/xpcshell-common.ini @@ -25,6 +25,7 @@ skip-if = os == "android" # Bug 1700482 skip-if = os == "android" # Android does not use Places for history. [test_ext_background_private_browsing.js] [test_ext_background_runtime_connect_params.js] +[test_ext_background_script_and_service_worker.js] [test_ext_background_sub_windows.js] [test_ext_background_teardown.js] [test_ext_background_telemetry.js] diff --git a/toolkit/components/pdfjs/content/build/pdf.js b/toolkit/components/pdfjs/content/build/pdf.js index 017a45914e..d2034d412b 100644 --- a/toolkit/components/pdfjs/content/build/pdf.js +++ b/toolkit/components/pdfjs/content/build/pdf.js @@ -829,6 +829,18 @@ function normalizeUnicode(str) { return p1 ? p1.normalize("NFKC") : NormalizationMap.get(p2); }); } +const FontRenderOps = { + BEZIER_CURVE_TO: 0, + MOVE_TO: 1, + LINE_TO: 2, + QUADRATIC_CURVE_TO: 3, + RESTORE: 4, + SAVE: 5, + SCALE: 6, + TRANSFORM: 7, + TRANSLATE: 8 +}; +exports.FontRenderOps = FontRenderOps; /***/ }), /* 2 */ @@ -965,7 +977,6 @@ function getDocument(src) { }; const transportParams = { ignoreErrors, - isEvalSupported, disableFontFace, fontExtraProperties, enableXfa, @@ -2153,7 +2164,6 @@ class WorkerTransport { } const inspectFont = params.pdfBug && globalThis.FontInspector?.enabled ? (font, url) => globalThis.FontInspector.fontAdded(font, url) : null; const font = new _font_loader.FontFaceObject(exportedData, { - isEvalSupported: params.isEvalSupported, disableFontFace: params.disableFontFace, ignoreErrors: params.ignoreErrors, inspectFont @@ -4760,7 +4770,6 @@ class FontLoader { exports.FontLoader = FontLoader; class FontFaceObject { constructor(translatedData, { - isEvalSupported = true, disableFontFace = false, ignoreErrors = false, inspectFont = null @@ -4769,7 +4778,6 @@ class FontFaceObject { for (const i in translatedData) { this[i] = translatedData[i]; } - this.isEvalSupported = isEvalSupported !== false; this.disableFontFace = disableFontFace === true; this.ignoreErrors = ignoreErrors === true; this._inspectFont = inspectFont; @@ -4824,22 +4832,72 @@ class FontFaceObject { throw ex; } (0, _util.warn)(`getPathGenerator - ignoring character: "${ex}".`); - return this.compiledGlyphs[character] = function (c, size) {}; } - if (this.isEvalSupported && _util.FeatureTest.isEvalSupported) { - const jsBuf = []; - for (const current of cmds) { - const args = current.args !== undefined ? current.args.join(",") : ""; - jsBuf.push("c.", current.cmd, "(", args, ");\n"); - } - return this.compiledGlyphs[character] = new Function("c", "size", jsBuf.join("")); + if (!Array.isArray(cmds) || cmds.length === 0) { + return this.compiledGlyphs[character] = function (c, size) {}; } - return this.compiledGlyphs[character] = function (c, size) { - for (const current of cmds) { - if (current.cmd === "scale") { - current.args = [size, -size]; - } - c[current.cmd].apply(c, current.args); + const commands = []; + for (let i = 0, ii = cmds.length; i < ii;) { + switch (cmds[i++]) { + case _util.FontRenderOps.BEZIER_CURVE_TO: + { + const [a, b, c, d, e, f] = cmds.slice(i, i + 6); + commands.push(ctx => ctx.bezierCurveTo(a, b, c, d, e, f)); + i += 6; + } + break; + case _util.FontRenderOps.MOVE_TO: + { + const [a, b] = cmds.slice(i, i + 2); + commands.push(ctx => ctx.moveTo(a, b)); + i += 2; + } + break; + case _util.FontRenderOps.LINE_TO: + { + const [a, b] = cmds.slice(i, i + 2); + commands.push(ctx => ctx.lineTo(a, b)); + i += 2; + } + break; + case _util.FontRenderOps.QUADRATIC_CURVE_TO: + { + const [a, b, c, d] = cmds.slice(i, i + 4); + commands.push(ctx => ctx.quadraticCurveTo(a, b, c, d)); + i += 4; + } + break; + case _util.FontRenderOps.RESTORE: + commands.push(ctx => ctx.restore()); + break; + case _util.FontRenderOps.SAVE: + commands.push(ctx => ctx.save()); + break; + case _util.FontRenderOps.SCALE: + _util.assert(commands.length === 2, "Scale command is only valid at the third position."); + break; + case _util.FontRenderOps.TRANSFORM: + { + const [a, b, c, d, e, f] = cmds.slice(i, i + 6); + commands.push(ctx => ctx.transform(a, b, c, d, e, f)); + i += 6; + } + break; + case _util.FontRenderOps.TRANSLATE: + { + const [a, b] = cmds.slice(i, i + 2); + commands.push(ctx => ctx.translate(a, b)); + i += 2; + } + break; + } + } + return this.compiledGlyphs[character] = function glyphDrawer(ctx, size) { + commands[0](ctx); + commands[1](ctx); + ctx.scale(size, -size); + for (let i = 2, ii = commands.length; i < ii; i++) { + commands[i](ctx); } }; } diff --git a/toolkit/components/pdfjs/content/build/pdf.worker.js b/toolkit/components/pdfjs/content/build/pdf.worker.js index 62305d24a9..87999f64a6 100644 --- a/toolkit/components/pdfjs/content/build/pdf.worker.js +++ b/toolkit/components/pdfjs/content/build/pdf.worker.js @@ -1421,6 +1421,18 @@ function normalizeUnicode(str) { return p1 ? p1.normalize("NFKC") : NormalizationMap.get(p2); }); } +const FontRenderOps = { + BEZIER_CURVE_TO: 0, + MOVE_TO: 1, + LINE_TO: 2, + QUADRATIC_CURVE_TO: 3, + RESTORE: 4, + SAVE: 5, + SCALE: 6, + TRANSFORM: 7, + TRANSLATE: 8 +}; +exports.FontRenderOps = FontRenderOps; /***/ }), /* 3 */ @@ -11304,6 +11316,10 @@ class PartialEvaluator { systemFontInfo = (0, _font_substitutions.getFontSubstitution)(this.systemFontCache, this.idFactory, this.options.standardFontDataUrl, fontName.name, standardFontName); } } + let fontMatrix = dict.getArray("FontMatrix"); + if (!Array.isArray(fontMatrix) || fontMatrix.length !== 6 || fontMatrix.some(x => typeof x !== "number")) { + fontMatrix = _util.FONT_IDENTITY_MATRIX; + } properties = { type, name: fontName.name, @@ -11316,7 +11332,7 @@ class PartialEvaluator { loadedName: baseDict.loadedName, composite, fixedPitch: false, - fontMatrix: dict.getArray("FontMatrix") || _util.FONT_IDENTITY_MATRIX, + fontMatrix, firstChar, lastChar, toUnicode, @@ -30781,22 +30797,13 @@ function lookupCmap(ranges, unicode) { } function compileGlyf(code, cmds, font) { function moveTo(x, y) { - cmds.push({ - cmd: "moveTo", - args: [x, y] - }); + cmds.add(_util.FontRenderOps.MOVE_TO, [x, y]); } function lineTo(x, y) { - cmds.push({ - cmd: "lineTo", - args: [x, y] - }); + cmds.add(_util.FontRenderOps.LINE_TO, [x, y]); } function quadraticCurveTo(xa, ya, x, y) { - cmds.push({ - cmd: "quadraticCurveTo", - args: [xa, ya, x, y] - }); + cmds.add(_util.FontRenderOps.QUADRATIC_CURVE_TO, [xa, ya, x, y]); } let i = 0; const numberOfContours = getInt16(code, i); @@ -30855,17 +30862,11 @@ function compileGlyf(code, cmds, font) { } const subglyph = font.glyphs[glyphIndex]; if (subglyph) { - cmds.push({ - cmd: "save" - }, { - cmd: "transform", - args: [scaleX, scale01, scale10, scaleY, x, y] - }); + cmds.add(_util.FontRenderOps.SAVE); + cmds.add(_util.FontRenderOps.TRANSFORM, [scaleX, scale01, scale10, scaleY, x, y]); if (!(flags & 0x02)) {} compileGlyf(subglyph, cmds, font); - cmds.push({ - cmd: "restore" - }); + cmds.add(_util.FontRenderOps.RESTORE); } } while (flags & 0x20); } else { @@ -30955,22 +30956,13 @@ function compileGlyf(code, cmds, font) { } function compileCharString(charStringCode, cmds, font, glyphId) { function moveTo(x, y) { - cmds.push({ - cmd: "moveTo", - args: [x, y] - }); + cmds.add(_util.FontRenderOps.MOVE_TO, [x, y]); } function lineTo(x, y) { - cmds.push({ - cmd: "lineTo", - args: [x, y] - }); + cmds.add(_util.FontRenderOps.LINE_TO, [x, y]); } function bezierCurveTo(x1, y1, x2, y2, x, y) { - cmds.push({ - cmd: "bezierCurveTo", - args: [x1, y1, x2, y2, x, y] - }); + cmds.add(_util.FontRenderOps.BEZIER_CURVE_TO, [x1, y1, x2, y2, x, y]); } const stack = []; let x = 0, @@ -31140,17 +31132,11 @@ function compileCharString(charStringCode, cmds, font, glyphId) { const bchar = stack.pop(); y = stack.pop(); x = stack.pop(); - cmds.push({ - cmd: "save" - }, { - cmd: "translate", - args: [x, y] - }); + cmds.add(_util.FontRenderOps.SAVE); + cmds.add(_util.FontRenderOps.TRANSLATE, [x, y]); let cmap = lookupCmap(font.cmap, String.fromCharCode(font.glyphNameMap[_encodings.StandardEncoding[achar]])); compileCharString(font.glyphs[cmap.glyphId], cmds, font, cmap.glyphId); - cmds.push({ - cmd: "restore" - }); + cmds.add(_util.FontRenderOps.RESTORE); cmap = lookupCmap(font.cmap, String.fromCharCode(font.glyphNameMap[_encodings.StandardEncoding[bchar]])); compileCharString(font.glyphs[cmap.glyphId], cmds, font, cmap.glyphId); } @@ -31317,6 +31303,22 @@ function compileCharString(charStringCode, cmds, font, glyphId) { parse(charStringCode); } const NOOP = []; +class Commands { + cmds = []; + add(cmd, args) { + if (args) { + if (args.some(arg => typeof arg !== "number")) { + warn(`Commands.add - "${cmd}" has at least one non-number arg: "${args}".`); + const newArgs = args.map(arg => typeof arg === "number" ? arg : 0); + this.cmds.push(cmd, ...newArgs); + } else { + this.cmds.push(cmd, ...args); + } + } else { + this.cmds.push(cmd); + } + } +} class CompiledFont { constructor(fontMatrix) { if (this.constructor === CompiledFont) { @@ -31334,8 +31336,7 @@ class CompiledFont { let fn = this.compiledGlyphs[glyphId]; if (!fn) { try { - fn = this.compileGlyph(this.glyphs[glyphId], glyphId); - this.compiledGlyphs[glyphId] = fn; + fn = this.compiledGlyphs[glyphId] = this.compileGlyph(this.glyphs[glyphId], glyphId); } catch (ex) { this.compiledGlyphs[glyphId] = NOOP; if (this.compiledCharCodeToGlyphId[charCode] === undefined) { @@ -31363,20 +31364,13 @@ class CompiledFont { (0, _util.warn)("Invalid fd index for glyph index."); } } - const cmds = [{ - cmd: "save" - }, { - cmd: "transform", - args: fontMatrix.slice() - }, { - cmd: "scale", - args: ["size", "-size"] - }]; + const cmds = new Commands(); + cmds.add(_util.FontRenderOps.SAVE); + cmds.add(_util.FontRenderOps.TRANSFORM, fontMatrix.slice()); + cmds.add(_util.FontRenderOps.SCALE); this.compileGlyphImpl(code, cmds, glyphId); - cmds.push({ - cmd: "restore" - }); - return cmds; + cmds.add(_util.FontRenderOps.RESTORE); + return cmds.cmds; } compileGlyphImpl() { (0, _util.unreachable)("Children classes should implement this."); diff --git a/toolkit/crashreporter/client/crashreporter.cpp b/toolkit/crashreporter/client/crashreporter.cpp index a14ea14fbc..fa3d51762d 100644 --- a/toolkit/crashreporter/client/crashreporter.cpp +++ b/toolkit/crashreporter/client/crashreporter.cpp @@ -544,7 +544,12 @@ string GetProgramPath(const string& exename) { // The other applications we ship with Firefox are stored in the main bundle // (Firefox.app/Contents/MacOS/) so we we need to go back three directories // to reach them. - path.append("../../../"); + path.erase(pos - 1); + for (size_t i = 0; i < 3; i++) { + pos = path.rfind(UI_DIR_SEPARATOR, pos - 1); + } + + path.erase(pos + 1); #endif // XP_MACOSX path.append(exename + BIN_SUFFIX); diff --git a/toolkit/modules/PopupNotifications.sys.mjs b/toolkit/modules/PopupNotifications.sys.mjs index 0c33220174..370953a271 100644 --- a/toolkit/modules/PopupNotifications.sys.mjs +++ b/toolkit/modules/PopupNotifications.sys.mjs @@ -1939,10 +1939,14 @@ PopupNotifications.prototype = { } if (type == "buttoncommand" || type == "secondarybuttoncommand") { - if (Services.focus.activeWindow != this.window) { + // TODO: Bug 1892756. + if ( + Services.focus.activeWindow != this.window || + notificationEl.matches(":-moz-window-inactive") + ) { Services.console.logStringMessage( "PopupNotifications._onButtonEvent: " + - "Button click happened before the window was focused" + "Button click happened before the window was focused / active" ); this.window.focus(); return; diff --git a/toolkit/modules/moz.build b/toolkit/modules/moz.build index 858bfc466e..6d5467bae6 100644 --- a/toolkit/modules/moz.build +++ b/toolkit/modules/moz.build @@ -230,7 +230,6 @@ EXTRA_JS_MODULES.sessionstore += [ "sessionstore/PrivacyFilter.sys.mjs", "sessionstore/PrivacyLevel.sys.mjs", "sessionstore/SessionHistory.sys.mjs", - "sessionstore/Utils.sys.mjs", ] EXTRA_JS_MODULES.third_party.fathom += ["third_party/fathom/fathom.mjs"] diff --git a/toolkit/modules/sessionstore/Utils.sys.mjs b/toolkit/modules/sessionstore/Utils.sys.mjs deleted file mode 100644 index 627cd22686..0000000000 --- a/toolkit/modules/sessionstore/Utils.sys.mjs +++ /dev/null @@ -1,29 +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/. */ - -export var Utils = Object.freeze({ - /** - * Restores frame tree |data|, starting at the given root |frame|. As the - * function recurses into descendant frames it will call cb(frame, data) for - * each frame it encounters, starting with the given root. - */ - restoreFrameTreeData(frame, data, cb) { - // Restore data for the root frame. - // The callback can abort by returning false. - if (cb(frame, data) === false) { - return; - } - - if (!data.hasOwnProperty("children")) { - return; - } - - // Recurse into child frames. - SessionStoreUtils.forEachNonDynamicChildFrame(frame, (subframe, index) => { - if (data.children[index]) { - this.restoreFrameTreeData(subframe, data.children[index], cb); - } - }); - }, -}); |