Merge autoland to mozilla-central. a=merge

This commit is contained in:
Bogdan Szekely 2022-06-16 12:29:41 +03:00
Родитель 8d5d2b1ab3 5bce79e64b
Коммит d3c2f51d89
301 изменённых файлов: 4319 добавлений и 2603 удалений

43
Cargo.lock сгенерированный
Просмотреть файл

@ -99,9 +99,9 @@ dependencies = [
[[package]]
name = "arbitrary"
version = "1.1.0"
version = "1.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c38b6b6b79f671c25e1a3e785b7b82d7562ffc9cd3efdc98627e5668a2472490"
checksum = "4f7487a7cc86cea29c97c91007ad21294f9959949577b305ae118b8c11738ccf"
dependencies = [
"derive_arbitrary",
]
@ -805,9 +805,9 @@ dependencies = [
[[package]]
name = "clap_lex"
version = "0.2.0"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a37c35f1112dad5e6e0b1adaff798507497a18fceeb30cceb3bae7d1427b9213"
checksum = "5538cd660450ebeb4234cfecf8f2284b844ffc4c50531e66d584ad5b91293613"
dependencies = [
"os_str_bytes",
]
@ -1363,9 +1363,9 @@ dependencies = [
[[package]]
name = "derive_arbitrary"
version = "1.1.0"
version = "1.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "98e23c06c035dac87bd802d98f368df73a7f2cb05a66ffbd1f377e821fac4af9"
checksum = "91d001046c3cc126eb2ee9bdc946d9f482fe9e74d4a5ef191a6834fdbf84d45c"
dependencies = [
"proc-macro2",
"quote",
@ -2112,13 +2112,13 @@ dependencies = [
[[package]]
name = "getrandom"
version = "0.2.6"
version = "0.2.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9be70c98951c83b8d2f8f60d7065fa6d5146873094452a1008da8c2f1e4205ad"
checksum = "4eb1a864a501629691edf6c15a593b7a51eebaa1e8468e9ddc623de7c9b58ec6"
dependencies = [
"cfg-if 1.0.0",
"libc",
"wasi",
"wasi 0.11.0+wasi-snapshot-preview1",
]
[[package]]
@ -4584,9 +4584,9 @@ dependencies = [
[[package]]
name = "rust_decimal"
version = "1.24.0"
version = "1.25.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e2ee7337df68898256ad0d4af4aad178210d9e44d2ff900ce44064a97cd86530"
checksum = "34a3bb58e85333f1ab191bf979104b586ebd77475bc6681882825f4532dfe87c"
dependencies = [
"arrayvec",
"num-traits",
@ -4705,9 +4705,9 @@ checksum = "1ef965a420fe14fdac7dd018862966a4c14094f900e1650bbc71ddd7d580c8af"
[[package]]
name = "semver"
version = "1.0.9"
version = "1.0.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8cb243bdfdb5936c8dc3c45762a19d12ab4550cdc753bc247637d4ec35a040fd"
checksum = "a41d061efea015927ac527063765e73601444cdc344ba855bc7bd44578b25e1c"
dependencies = [
"serde",
]
@ -5251,7 +5251,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6db9e6914ab8b1ae1c260a4ae7a49b6c5611b40328a735b21862567685e73255"
dependencies = [
"libc",
"wasi",
"wasi 0.10.0+wasi-snapshot-preview999",
"winapi",
]
@ -5637,9 +5637,9 @@ checksum = "099b7128301d285f79ddd55b9a83d5e6b9e97c92e0ea0daebee7263e932de992"
[[package]]
name = "unicode-ident"
version = "1.0.0"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d22af068fba1eb5edcb4aea19d382b2a3deb4c8f9d475c589b6ada9e0fd493ee"
checksum = "5bd2fe26506023ed7b5e1e315add59d6f584c621d037f9368fea9cfb988f368c"
[[package]]
name = "unicode-normalization"
@ -5843,9 +5843,16 @@ dependencies = [
[[package]]
name = "wasi"
version = "0.10.0+wasi-snapshot-preview1"
version = "0.10.0+wasi-snapshot-preview999"
dependencies = [
"wasi 0.11.0+wasi-snapshot-preview1",
]
[[package]]
name = "wasi"
version = "0.11.0+wasi-snapshot-preview1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f"
checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
[[package]]
name = "wasm-bindgen"

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

@ -135,6 +135,9 @@ parking_lot = { path = "build/rust/parking_lot" }
# Override tinyvec with smallvec
tinyvec = { path = "build/rust/tinyvec" }
# Patch wasi 0.10 to 0.11
wasi = { path = "build/rust/wasi" }
# Patch autocfg to hide rustc output. Workaround for https://github.com/cuviper/autocfg/issues/30
autocfg = { path = "third_party/rust/autocfg" }

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

@ -97,6 +97,10 @@ bool Accessible::HasGenericType(AccGenericType aType) const {
(roleMapEntry && roleMapEntry->IsOfType(aType));
}
nsIntRect Accessible::BoundsInCSSPixels() const {
return BoundsInAppUnits().ToNearestPixels(AppUnitsPerCSSPixel());
}
LayoutDeviceIntSize Accessible::Size() const { return Bounds().Size(); }
LayoutDeviceIntPoint Accessible::Position(uint32_t aCoordType) {

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

@ -197,6 +197,16 @@ class Accessible {
*/
virtual LayoutDeviceIntRect Bounds() const = 0;
/**
* Return boundaries in screen coordinates in app units.
*/
virtual nsRect BoundsInAppUnits() const = 0;
/**
* Return boundaries in screen coordinates in CSS pixels.
*/
virtual nsIntRect BoundsInCSSPixels() const;
/**
* Returns text of accessible if accessible has text role otherwise empty
* string.

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

@ -789,10 +789,6 @@ LayoutDeviceIntRect LocalAccessible::Bounds() const {
BoundsInAppUnits(), mDoc->PresContext()->AppUnitsPerDevPixel());
}
nsIntRect LocalAccessible::BoundsInCSSPixels() const {
return BoundsInAppUnits().ToNearestPixels(AppUnitsPerCSSPixel());
}
void LocalAccessible::SetSelected(bool aSelect) {
if (!HasOwnContent()) return;

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

@ -405,18 +405,10 @@ class LocalAccessible : public nsISupports, public Accessible {
virtual void AppendTextTo(nsAString& aText, uint32_t aStartOffset = 0,
uint32_t aLength = UINT32_MAX) override;
/**
* Return boundaries in screen coordinates in app units.
*/
virtual nsRect BoundsInAppUnits() const;
virtual nsRect BoundsInAppUnits() const override;
virtual LayoutDeviceIntRect Bounds() const override;
/**
* Return boundaries in screen coordinates in CSS pixels.
*/
virtual nsIntRect BoundsInCSSPixels() const;
/**
* Return boundaries rect relative the bounding frame.
*/

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

@ -457,7 +457,7 @@ void RemoteAccessibleBase<Derived>::ApplyScrollOffset(nsRect& aBounds) const {
}
template <class Derived>
nsRect RemoteAccessibleBase<Derived>::GetBoundsInAppUnits() const {
nsRect RemoteAccessibleBase<Derived>::BoundsInAppUnits() const {
dom::CanonicalBrowsingContext* cbc =
static_cast<dom::BrowserParent*>(mDoc->Manager())
->GetBrowsingContext()

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

@ -181,7 +181,7 @@ class RemoteAccessibleBase : public Accessible, public HyperTextAccessibleBase {
virtual LayoutDeviceIntRect Bounds() const override;
nsRect GetBoundsInAppUnits() const;
virtual nsRect BoundsInAppUnits() const override;
virtual uint64_t State() override;

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

@ -202,7 +202,7 @@ Accessible* ChildAtPoint(
int32_t aX, int32_t aY,
LocalAccessible::EWhichChildAtPoint aWhichChild) override;
LayoutDeviceIntRect Bounds() const override;
nsIntRect BoundsInCSSPixels();
virtual nsIntRect BoundsInCSSPixels() const override;
void Language(nsString& aLocale);
void DocType(nsString& aType);

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

@ -989,7 +989,11 @@ LayoutDeviceIntRect RemoteAccessible::Bounds() const {
return rect;
}
nsIntRect RemoteAccessible::BoundsInCSSPixels() {
nsIntRect RemoteAccessible::BoundsInCSSPixels() const {
if (StaticPrefs::accessibility_cache_enabled_AtStartup()) {
return RemoteAccessibleBase<RemoteAccessible>::BoundsInCSSPixels();
}
nsIntRect rect;
Unused << mDoc->SendExtentsInCSSPixels(mID, &rect.x, &rect.y, &rect.width,
&rect.height);

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

@ -252,7 +252,11 @@ LayoutDeviceIntRect RemoteAccessible::Bounds() const {
return rect;
}
nsIntRect RemoteAccessible::BoundsInCSSPixels() {
nsIntRect RemoteAccessible::BoundsInCSSPixels() const {
if (StaticPrefs::accessibility_cache_enabled_AtStartup()) {
return RemoteAccessibleBase<RemoteAccessible>::BoundsInCSSPixels();
}
RefPtr<IGeckoCustom> custom = QueryInterface<IGeckoCustom>(this);
if (!custom) {
return nsIntRect();

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

@ -435,13 +435,7 @@ xpcAccessible::GetBounds(int32_t* aX, int32_t* aY, int32_t* aWidth,
if (!IntlGeneric()) return NS_ERROR_FAILURE;
LayoutDeviceIntRect rect;
if (LocalAccessible* acc = IntlGeneric()->AsLocal()) {
rect = acc->Bounds();
} else {
rect = IntlGeneric()->AsRemote()->Bounds();
}
LayoutDeviceIntRect rect = IntlGeneric()->Bounds();
rect.GetRect(aX, aY, aWidth, aHeight);
return NS_OK;
}
@ -462,13 +456,7 @@ xpcAccessible::GetBoundsInCSSPixels(int32_t* aX, int32_t* aY, int32_t* aWidth,
return NS_ERROR_FAILURE;
}
nsIntRect rect;
if (LocalAccessible* acc = IntlGeneric()->AsLocal()) {
rect = acc->BoundsInCSSPixels();
} else {
rect = IntlGeneric()->AsRemote()->BoundsInCSSPixels();
}
nsIntRect rect = IntlGeneric()->BoundsInCSSPixels();
rect.GetRect(aX, aY, aWidth, aHeight);
return NS_OK;
}

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

@ -4,8 +4,6 @@
"use strict";
Cu.importGlobalProperties(["fetch"]);
var EXPORTED_SYMBOLS = ["AboutProtectionsParent"];
const { XPCOMUtils } = ChromeUtils.import(
"resource://gre/modules/XPCOMUtils.jsm"

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

@ -115,6 +115,8 @@ class ClickHandlerParent extends JSWindowActorParent {
csp: data.csp ? lazy.E10SUtils.deserializeCSP(data.csp) : null,
frameID: data.frameID,
openerBrowser: browser,
// The child ensures that untrusted events have a valid user activation.
hasValidUserGestureActivation: true,
};
// The new tab/window must use the same userContextId.

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

@ -1220,8 +1220,6 @@ pref("browser.bookmarks.editDialog.maxRecentFolders", 7);
// just save on Accept, once the project is complete.
pref("browser.bookmarks.editDialog.delayedApply.enabled", false);
pref("dom.ipc.shims.enabledWarnings", false);
#if defined(XP_WIN) && defined(MOZ_SANDBOX)
// This controls the strength of the Windows content process sandbox for
// testing purposes. This will require a restart.
@ -1606,6 +1604,8 @@ pref("browser.aboutwelcome.enabled", true);
// Used to set multistage welcome UX
pref("browser.aboutwelcome.screens", "");
pref("browser.aboutwelcome.skipFocus", true);
// Used to enable template for MR 2022 Onboarding
pref("browser.aboutwelcome.templateMR", false);
// The pref that controls if the What's New panel is enabled.
pref("browser.messaging-system.whatsNewPanel.enabled", true);

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

@ -1508,11 +1508,13 @@ function _loadURI(browser, uri, params = {}) {
userContextId,
csp,
remoteTypeOverride,
hasValidUserGestureActivation,
} = params || {};
let loadFlags =
params.loadFlags || params.flags || Ci.nsIWebNavigation.LOAD_FLAGS_NONE;
let hasValidUserGestureActivation =
hasValidUserGestureActivation ??=
document.hasValidTransientUserGestureActivation;
if (!triggeringPrincipal) {
throw new Error("Must load with a triggering Principal");
}
@ -2245,7 +2247,7 @@ var gBrowserInit = {
});
} catch (e) {}
} else if (window.arguments.length >= 3) {
// window.arguments[1]: unused (bug 871161)
// window.arguments[1]: extraOptions (nsIPropertyBag)
// [2]: referrerInfo (nsIReferrerInfo)
// [3]: postData (nsIInputStream)
// [4]: allowThirdPartyFixup (bool)
@ -2260,23 +2262,50 @@ var gBrowserInit = {
window.arguments[5] != undefined
? window.arguments[5]
: Ci.nsIScriptSecurityManager.DEFAULT_USER_CONTEXT_ID;
loadURI(
uriToLoad,
window.arguments[2] || null,
window.arguments[3] || null,
window.arguments[4] || false,
let hasValidUserGestureActivation = undefined;
let fromExternal = undefined;
if (window.arguments[1]) {
if (!(window.arguments[1] instanceof Ci.nsIPropertyBag2)) {
throw new Error(
"window.arguments[1] must be null or Ci.nsIPropertyBag2!"
);
}
let extraOptions = window.arguments[1];
if (extraOptions.hasKey("hasValidUserGestureActivation")) {
hasValidUserGestureActivation = extraOptions.getPropertyAsBool(
"hasValidUserGestureActivation"
);
}
if (extraOptions.hasKey("fromExternal")) {
fromExternal = extraOptions.getPropertyAsBool("fromExternal");
}
}
try {
openLinkIn(uriToLoad, "current", {
referrerInfo: window.arguments[2] || null,
postData: window.arguments[3] || null,
allowThirdPartyFixup: window.arguments[4] || false,
userContextId,
// pass the origin principal (if any) and force its use to create
// an initial about:blank viewer if present:
window.arguments[6],
window.arguments[7],
!!window.arguments[6],
window.arguments[8],
originPrincipal: window.arguments[6],
originStoragePrincipal: window.arguments[7],
triggeringPrincipal: window.arguments[8],
// TODO fix allowInheritPrincipal to default to false.
// Default to true unless explicitly set to false because of bug 1475201.
window.arguments[9] !== false,
window.arguments[10]
);
allowInheritPrincipal: window.arguments[9] !== false,
csp: window.arguments[10],
forceAboutBlankViewerInCurrent: !!window.arguments[6],
hasValidUserGestureActivation,
fromExternal,
});
} catch (e) {
Cu.reportError(e);
}
window.focus();
} else {
// Note: loadOneOrMoreURIs *must not* be called if window.arguments.length >= 3.
@ -6272,13 +6301,18 @@ nsBrowserAccess.prototype = {
// Pass all params to openDialog to ensure that "url" isn't passed through
// loadOneOrMoreURIs, which splits based on "|"
try {
let extraOptions = Cc[
"@mozilla.org/hash-property-bag;1"
].createInstance(Ci.nsIWritablePropertyBag2);
extraOptions.setPropertyAsBool("fromExternal", isExternal);
openDialog(
AppConstants.BROWSER_CHROME_URL,
"_blank",
features,
// window.arguments
url,
null,
extraOptions,
null,
null,
null,

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

@ -1309,6 +1309,7 @@ class nsContextMenu {
triggeringPrincipal: this.principal,
csp: this.csp,
frameID: this.contentData.frameID,
hasValidUserGestureActivation: true,
};
for (let p in extra) {
params[p] = extra[p];

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

@ -409,12 +409,17 @@ function openLinkIn(url, where, params) {
);
wuri.data = url;
let charset = null;
if (aCharset) {
charset = Cc["@mozilla.org/supports-string;1"].createInstance(
Ci.nsISupportsString
let extraOptions = Cc["@mozilla.org/hash-property-bag;1"].createInstance(
Ci.nsIWritablePropertyBag2
);
charset.data = "charset=" + aCharset;
if (params.hasValidUserGestureActivation !== undefined) {
extraOptions.setPropertyAsBool(
"hasValidUserGestureActivation",
params.hasValidUserGestureActivation
);
}
if (params.fromExternal !== undefined) {
extraOptions.setPropertyAsBool("fromExternal", params.fromExternal);
}
var allowThirdPartyFixupSupports = Cc[
@ -428,7 +433,7 @@ function openLinkIn(url, where, params) {
userContextIdSupports.data = aUserContextId;
sa.appendElement(wuri);
sa.appendElement(charset);
sa.appendElement(extraOptions);
sa.appendElement(aReferrerInfo);
sa.appendElement(aPostData);
sa.appendElement(allowThirdPartyFixupSupports);
@ -579,6 +584,9 @@ function openLinkIn(url, where, params) {
if (aForceAllowDataURI) {
flags |= Ci.nsIWebNavigation.LOAD_FLAGS_FORCE_ALLOW_DATA_URI;
}
if (params.fromExternal) {
flags |= Ci.nsIWebNavigation.LOAD_FLAGS_FROM_EXTERNAL;
}
let { URI_INHERITS_SECURITY_CONTEXT } = Ci.nsIProtocolHandler;
if (
@ -600,6 +608,7 @@ function openLinkIn(url, where, params) {
referrerInfo: aReferrerInfo,
postData: aPostData,
userContextId: aUserContextId,
hasValidUserGestureActivation: params.hasValidUserGestureActivation,
});
if (aResolveOnContentBrowserReady) {
aResolveOnContentBrowserReady(targetBrowser);
@ -636,6 +645,7 @@ function openLinkIn(url, where, params) {
csp: aCsp,
focusUrlBar,
openerBrowser: params.openerBrowser,
fromExternal: params.fromExternal,
});
targetBrowser = tabUsedForLoad.linkedBrowser;

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

@ -250,12 +250,17 @@ function openBrowserWindow(
});
args = [uriArray];
} else {
let extraOptions = Cc["@mozilla.org/hash-property-bag;1"].createInstance(
Ci.nsIWritablePropertyBag2
);
extraOptions.setPropertyAsBool("fromExternal", true);
// Always pass at least 3 arguments to avoid the "|"-splitting behavior,
// ie. avoid the loadOneOrMoreURIs function.
// Also, we need to pass the triggering principal.
args = [
urlOrUrlList,
null, // charset
extraOptions,
null, // refererInfo
postData,
undefined, // allowThirdPartyFixup; this would be `false` but that

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

@ -17,11 +17,13 @@ const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
const { AppConstants } = ChromeUtils.import(
"resource://gre/modules/AppConstants.jsm"
);
const { E10SUtils } = ChromeUtils.import(
"resource://gre/modules/E10SUtils.jsm"
);
const lazy = {};
XPCOMUtils.defineLazyModuleGetters(lazy, {
E10SUtils: "resource://gre/modules/E10SUtils.jsm",
LoginBreaches: "resource:///modules/LoginBreaches.jsm",
LoginHelper: "resource://gre/modules/LoginHelper.jsm",
LoginExport: "resource://gre/modules/LoginExport.jsm",
@ -69,8 +71,7 @@ const PRIMARY_PASSWORD_NOTIFICATION_ID = "primary-password-login-required";
// about:logins will always use the privileged content process,
// even if it is disabled for other consumers such as about:newtab.
const EXPECTED_ABOUTLOGINS_REMOTE_TYPE =
lazy.E10SUtils.PRIVILEGEDABOUT_REMOTE_TYPE;
const EXPECTED_ABOUTLOGINS_REMOTE_TYPE = E10SUtils.PRIVILEGEDABOUT_REMOTE_TYPE;
let _gPasswordRemaskTimeout = null;
const convertSubjectToLogin = subject => {
subject.QueryInterface(Ci.nsILoginMetaInfo).QueryInterface(Ci.nsILoginInfo);

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

@ -260,7 +260,7 @@ this.windows = class extends ExtensionAPIPersistent {
}
}
args.appendElement(null); // unused
args.appendElement(null); // extraOptions
args.appendElement(null); // referrerInfo
args.appendElement(null); // postData
args.appendElement(null); // allowThirdPartyFixup

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

@ -9,9 +9,12 @@ var EXPORTED_SYMBOLS = ["Qihoo360seMigrationUtils"];
const { XPCOMUtils } = ChromeUtils.import(
"resource://gre/modules/XPCOMUtils.jsm"
);
const { MigrationUtils } = ChromeUtils.import(
"resource:///modules/MigrationUtils.jsm"
);
const lazy = {};
XPCOMUtils.defineLazyModuleGetters(lazy, {
MigrationUtils: "resource:///modules/MigrationUtils.jsm",
PlacesUIUtils: "resource:///modules/PlacesUIUtils.jsm",
PlacesUtils: "resource://gre/modules/PlacesUtils.jsm",
Sqlite: "resource://gre/modules/Sqlite.jsm",
@ -32,7 +35,7 @@ function Bookmarks(aProfileFolder) {
this._file = file;
}
Bookmarks.prototype = {
type: lazy.MigrationUtils.resourceTypes.BOOKMARKS,
type: MigrationUtils.resourceTypes.BOOKMARKS,
get exists() {
return this._file.exists() && this._file.isReadable();
@ -105,10 +108,7 @@ Bookmarks.prototype = {
if (toolbarBMs.length) {
let parentGuid = lazy.PlacesUtils.bookmarks.toolbarGuid;
await lazy.MigrationUtils.insertManyBookmarksWrapper(
toolbarBMs,
parentGuid
);
await MigrationUtils.insertManyBookmarksWrapper(toolbarBMs, parentGuid);
lazy.PlacesUIUtils.maybeToggleBookmarkToolbarVisibilityAfterMigration();
}
})().then(

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

@ -11,8 +11,6 @@
var EXPORTED_SYMBOLS = ["ChromeMacOSLoginCrypto"];
Cu.importGlobalProperties(["crypto"]);
const { XPCOMUtils } = ChromeUtils.import(
"resource://gre/modules/XPCOMUtils.jsm"
);

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

@ -19,10 +19,13 @@ const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
const { AppConstants } = ChromeUtils.import(
"resource://gre/modules/AppConstants.jsm"
);
const { MigratorPrototype } = ChromeUtils.import(
"resource:///modules/MigrationUtils.jsm"
);
const lazy = {};
XPCOMUtils.defineLazyModuleGetters(lazy, {
ChromeMigrationUtils: "resource:///modules/ChromeMigrationUtils.jsm",
MigratorPrototype: "resource:///modules/MigrationUtils.jsm",
MigrationUtils: "resource:///modules/MigrationUtils.jsm",
NetUtil: "resource://gre/modules/NetUtil.jsm",
OS: "resource://gre/modules/osfile.jsm",
@ -76,7 +79,7 @@ function ChromeProfileMigrator() {
this._chromeUserDataPathSuffix = "Chrome";
}
ChromeProfileMigrator.prototype = Object.create(lazy.MigratorPrototype);
ChromeProfileMigrator.prototype = Object.create(MigratorPrototype);
ChromeProfileMigrator.prototype._keychainServiceName = "Chrome Safe Storage";
ChromeProfileMigrator.prototype._keychainAccountName = "Chrome";

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

@ -11,8 +11,6 @@
var EXPORTED_SYMBOLS = ["ChromeWindowsLoginCrypto"];
Cu.importGlobalProperties(["atob", "crypto"]);
const { ChromeMigrationUtils } = ChromeUtils.import(
"resource:///modules/ChromeMigrationUtils.jsm"
);

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

@ -31,11 +31,7 @@ ChromeUtils.defineModuleGetter(
"WindowsRegistry",
"resource://gre/modules/WindowsRegistry.jsm"
);
ChromeUtils.defineModuleGetter(
lazy,
"ctypes",
"resource://gre/modules/ctypes.jsm"
);
const { ctypes } = ChromeUtils.import("resource://gre/modules/ctypes.jsm");
const EDGE_COOKIE_PATH_OPTIONS = ["", "#!001\\", "#!002\\"];
const EDGE_COOKIES_SUFFIX = "MicrosoftEdge\\Cookies";
@ -57,15 +53,15 @@ const WEB_CREDENTIALS_VAULT_ID = [
];
const wintypes = {
BOOL: lazy.ctypes.int,
DWORD: lazy.ctypes.uint32_t,
DWORDLONG: lazy.ctypes.uint64_t,
CHAR: lazy.ctypes.char,
PCHAR: lazy.ctypes.char.ptr,
LPCWSTR: lazy.ctypes.char16_t.ptr,
PDWORD: lazy.ctypes.uint32_t.ptr,
VOIDP: lazy.ctypes.voidptr_t,
WORD: lazy.ctypes.uint16_t,
BOOL: ctypes.int,
DWORD: ctypes.uint32_t,
DWORDLONG: ctypes.uint64_t,
CHAR: ctypes.char,
PCHAR: ctypes.char.ptr,
LPCWSTR: ctypes.char16_t.ptr,
PDWORD: ctypes.uint32_t.ptr,
VOIDP: ctypes.voidptr_t,
WORD: ctypes.uint16_t,
};
// TODO: Bug 1202978 - Refactor MSMigrationUtils ctypes helpers
@ -74,7 +70,7 @@ function CtypesKernelHelpers() {
this._functions = {};
this._libs = {};
this._structs.SYSTEMTIME = new lazy.ctypes.StructType("SYSTEMTIME", [
this._structs.SYSTEMTIME = new ctypes.StructType("SYSTEMTIME", [
{ wYear: wintypes.WORD },
{ wMonth: wintypes.WORD },
{ wDayOfWeek: wintypes.WORD },
@ -85,17 +81,17 @@ function CtypesKernelHelpers() {
{ wMilliseconds: wintypes.WORD },
]);
this._structs.FILETIME = new lazy.ctypes.StructType("FILETIME", [
this._structs.FILETIME = new ctypes.StructType("FILETIME", [
{ dwLowDateTime: wintypes.DWORD },
{ dwHighDateTime: wintypes.DWORD },
]);
try {
this._libs.kernel32 = lazy.ctypes.open("Kernel32");
this._libs.kernel32 = ctypes.open("Kernel32");
this._functions.FileTimeToSystemTime = this._libs.kernel32.declare(
"FileTimeToSystemTime",
lazy.ctypes.winapi_abi,
ctypes.winapi_abi,
wintypes.BOOL,
this._structs.FILETIME.ptr,
this._structs.SYSTEMTIME.ptr
@ -142,7 +138,7 @@ CtypesKernelHelpers.prototype = {
systemTime.address()
);
if (result == 0) {
throw new Error(lazy.ctypes.winLastError);
throw new Error(ctypes.winLastError);
}
// System time is in UTC, so we use Date.UTC to get milliseconds from epoch,
@ -165,11 +161,11 @@ function CtypesVaultHelpers() {
this._structs = {};
this._functions = {};
this._structs.GUID = new lazy.ctypes.StructType("GUID", [
this._structs.GUID = new ctypes.StructType("GUID", [
{ id: wintypes.DWORD.array(4) },
]);
this._structs.VAULT_ITEM_ELEMENT = new lazy.ctypes.StructType(
this._structs.VAULT_ITEM_ELEMENT = new ctypes.StructType(
"VAULT_ITEM_ELEMENT",
[
// not documented
@ -187,7 +183,7 @@ function CtypesVaultHelpers() {
]
);
this._structs.VAULT_ELEMENT = new lazy.ctypes.StructType("VAULT_ELEMENT", [
this._structs.VAULT_ELEMENT = new ctypes.StructType("VAULT_ELEMENT", [
// vault item schemaId
{ schemaId: this._structs.GUID },
// a pointer to the name of the browser VAULT_ITEM_ELEMENT
@ -212,11 +208,11 @@ function CtypesVaultHelpers() {
]);
try {
this._vaultcliLib = lazy.ctypes.open("vaultcli.dll");
this._vaultcliLib = ctypes.open("vaultcli.dll");
this._functions.VaultOpenVault = this._vaultcliLib.declare(
"VaultOpenVault",
lazy.ctypes.winapi_abi,
ctypes.winapi_abi,
wintypes.DWORD,
// GUID
this._structs.GUID.ptr,
@ -227,7 +223,7 @@ function CtypesVaultHelpers() {
);
this._functions.VaultEnumerateItems = this._vaultcliLib.declare(
"VaultEnumerateItems",
lazy.ctypes.winapi_abi,
ctypes.winapi_abi,
wintypes.DWORD,
// Vault Handle
wintypes.VOIDP,
@ -236,18 +232,18 @@ function CtypesVaultHelpers() {
// Items Count
wintypes.PDWORD,
// Items
lazy.ctypes.voidptr_t
ctypes.voidptr_t
);
this._functions.VaultCloseVault = this._vaultcliLib.declare(
"VaultCloseVault",
lazy.ctypes.winapi_abi,
ctypes.winapi_abi,
wintypes.DWORD,
// Vault Handle
wintypes.VOIDP
);
this._functions.VaultGetItem = this._vaultcliLib.declare(
"VaultGetItem",
lazy.ctypes.winapi_abi,
ctypes.winapi_abi,
wintypes.DWORD,
// Vault Handle
wintypes.VOIDP,
@ -268,7 +264,7 @@ function CtypesVaultHelpers() {
);
this._functions.VaultFree = this._vaultcliLib.declare(
"VaultFree",
lazy.ctypes.winapi_abi,
ctypes.winapi_abi,
wintypes.DWORD,
// Memory
this._structs.VAULT_ELEMENT.ptr

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

@ -12,7 +12,6 @@ const { AppConstants } = ChromeUtils.import(
"resource://gre/modules/AppConstants.jsm"
);
const lazy = {};
XPCOMUtils.defineLazyGlobalGetters(lazy, ["fetch"]);
XPCOMUtils.defineLazyModuleGetters(lazy, {
SnippetsTestMessageProvider:
"resource://activity-stream/lib/SnippetsTestMessageProvider.jsm",
@ -192,7 +191,7 @@ const MessageLoaderUtils = {
let response;
try {
response = await lazy.fetch(provider.url, {
response = await fetch(provider.url, {
headers,
credentials: "omit",
});

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

@ -13,6 +13,12 @@ const { XPCOMUtils } = ChromeUtils.import(
const { AppConstants } = ChromeUtils.import(
"resource://gre/modules/AppConstants.jsm"
);
const { NewTabUtils } = ChromeUtils.import(
"resource://gre/modules/NewTabUtils.jsm"
);
const { ShellService } = ChromeUtils.import(
"resource:///modules/ShellService.jsm"
);
const lazy = {};
@ -20,9 +26,7 @@ XPCOMUtils.defineLazyModuleGetters(lazy, {
ASRouterPreferences: "resource://activity-stream/lib/ASRouterPreferences.jsm",
AddonManager: "resource://gre/modules/AddonManager.jsm",
ClientEnvironment: "resource://normandy/lib/ClientEnvironment.jsm",
NewTabUtils: "resource://gre/modules/NewTabUtils.jsm",
ProfileAge: "resource://gre/modules/ProfileAge.jsm",
ShellService: "resource:///modules/ShellService.jsm",
TelemetryEnvironment: "resource://gre/modules/TelemetryEnvironment.jsm",
AttributionCode: "resource:///modules/AttributionCode.jsm",
TargetingContext: "resource://messaging-system/targeting/Targeting.jsm",
@ -116,7 +120,7 @@ XPCOMUtils.defineLazyServiceGetters(lazy, {
const FXA_USERNAME_PREF = "services.sync.username";
const { activityStreamProvider: asProvider } = lazy.NewTabUtils;
const { activityStreamProvider: asProvider } = NewTabUtils;
const FXA_ATTACHED_CLIENTS_UPDATE_INTERVAL = 4 * 60 * 60 * 1000; // Four hours
const FRECENT_SITES_UPDATE_INTERVAL = 6 * 60 * 60 * 1000; // Six hours
@ -265,7 +269,7 @@ const QueryCache = {
"doesAppNeedPin",
null,
FRECENT_SITES_UPDATE_INTERVAL,
lazy.ShellService
ShellService
),
},
};
@ -477,7 +481,7 @@ const TargetingGetters = {
},
get isDefaultBrowser() {
try {
return lazy.ShellService.isDefaultBrowser();
return ShellService.isDefaultBrowser();
} catch (e) {}
return null;
},
@ -498,7 +502,7 @@ const TargetingGetters = {
return QueryCache.queries.RecentBookmarks.get();
},
get pinnedSites() {
return lazy.NewTabUtils.pinnedLinks.links.map(site =>
return NewTabUtils.pinnedLinks.links.map(site =>
site
? {
url: site.url,

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

@ -1,8 +1,9 @@
const lazy = {};
/* 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/. */
const lazy = {};
ChromeUtils.defineModuleGetter(
lazy,
"IndexedDB",

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

@ -10,8 +10,6 @@ const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
const lazy = {};
XPCOMUtils.defineLazyGlobalGetters(lazy, ["fetch"]);
XPCOMUtils.defineLazyModuleGetters(lazy, {
PrivateBrowsingUtils: "resource://gre/modules/PrivateBrowsingUtils.jsm",
RemoteL10n: "resource://activity-stream/lib/RemoteL10n.jsm",
@ -881,7 +879,7 @@ const CFRPageActions = {
async _fetchLatestAddonVersion(id) {
let url = null;
try {
const response = await lazy.fetch(`${ADDONS_API_URL}/${id}/`, {
const response = await fetch(`${ADDONS_API_URL}/${id}/`, {
credentials: "omit",
});
if (response.status !== 204 && response.ok) {

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

@ -3,9 +3,6 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
const { XPCOMUtils } = ChromeUtils.import(
"resource://gre/modules/XPCOMUtils.jsm"
);
const lazy = {};
ChromeUtils.defineModuleGetter(
lazy,
@ -21,7 +18,6 @@ const { setTimeout, clearTimeout } = ChromeUtils.import(
"resource://gre/modules/Timer.jsm"
);
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
XPCOMUtils.defineLazyGlobalGetters(lazy, ["fetch"]);
const { actionTypes: at, actionCreators: ac } = ChromeUtils.import(
"resource://activity-stream/common/Actions.jsm"
);
@ -287,7 +283,7 @@ class DiscoveryStreamFeed {
const controller = new AbortController();
const { signal } = controller;
const fetchPromise = lazy.fetch(endpoint, {
const fetchPromise = fetch(endpoint, {
...options,
credentials: "omit",
signal,

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

@ -18,11 +18,6 @@ ChromeUtils.defineModuleGetter(
);
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
const { XPCOMUtils } = ChromeUtils.import(
"resource://gre/modules/XPCOMUtils.jsm"
);
XPCOMUtils.defineLazyGlobalGetters(lazy, ["fetch"]);
const { BasePromiseWorker } = ChromeUtils.import(
"resource://gre/modules/PromiseWorker.jsm"
@ -67,7 +62,7 @@ class PersonalityProvider {
}
const server = Services.prefs.getCharPref("services.settings.server");
const serverInfo = await (
await lazy.fetch(`${server}/`, {
await fetch(`${server}/`, {
credentials: "omit",
})
).json();

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

@ -11,8 +11,6 @@ const { XPCOMUtils } = ChromeUtils.import(
const lazy = {};
XPCOMUtils.defineLazyGlobalGetters(lazy, ["fetch"]);
ChromeUtils.defineModuleGetter(
lazy,
"BackgroundPageThumbs",
@ -63,7 +61,7 @@ const Screenshots = {
// Blob URIs for the screenshots.
const imgPath = lazy.PageThumbs.getThumbnailPath(url);
const filePathResponse = await lazy.fetch(`file://${imgPath}`);
const filePathResponse = await fetch(`file://${imgPath}`);
const fileContents = await filePathResponse.blob();
// Check if the file is empty, which indicates there isn't actually a

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

@ -2,15 +2,8 @@
* 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/. */
const { XPCOMUtils } = ChromeUtils.import(
"resource://gre/modules/XPCOMUtils.jsm"
);
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
const lazy = {};
XPCOMUtils.defineLazyGlobalGetters(lazy, ["fetch"]);
const TIPPYTOP_PATH = "chrome://activity-stream/content/data/content/tippytop/";
const TIPPYTOP_JSON_PATH =
"chrome://activity-stream/content/data/content/tippytop/top_sites.json";
@ -43,7 +36,7 @@ class TippyTopProvider {
// Load the Tippy Top sites from the json manifest.
try {
for (const site of await (
await lazy.fetch(TIPPYTOP_JSON_PATH, {
await fetch(TIPPYTOP_JSON_PATH, {
credentials: "omit",
})
).json()) {

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

@ -74,8 +74,6 @@ ChromeUtils.defineModuleGetter(
"resource://gre/modules/Region.jsm"
);
XPCOMUtils.defineLazyGlobalGetters(lazy, ["fetch"]);
XPCOMUtils.defineLazyGetter(lazy, "log", () => {
const { Logger } = ChromeUtils.import(
"resource://messaging-system/lib/Logger.jsm"
@ -186,7 +184,7 @@ class ContileIntegration {
}
try {
let url = Services.prefs.getStringPref(CONTILE_ENDPOINT_PREF);
const response = await lazy.fetch(url, { credentials: "omit" });
const response = await fetch(url, { credentials: "omit" });
if (!response.ok) {
lazy.log.warn(
`Contile endpoint returned unexpected status: ${response.status}`

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

@ -3,15 +3,10 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
const { XPCOMUtils } = ChromeUtils.import(
"resource://gre/modules/XPCOMUtils.jsm"
);
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
const { NewTabUtils } = ChromeUtils.import(
"resource://gre/modules/NewTabUtils.jsm"
);
const lazy = {};
XPCOMUtils.defineLazyGlobalGetters(lazy, ["fetch"]);
const { actionTypes: at, actionCreators: ac } = ChromeUtils.import(
"resource://activity-stream/common/Actions.jsm"
@ -29,6 +24,7 @@ const { PersistentCache } = ChromeUtils.import(
"resource://activity-stream/lib/PersistentCache.jsm"
);
const lazy = {};
ChromeUtils.defineModuleGetter(
lazy,
"pktApi",
@ -196,7 +192,7 @@ class TopStoriesFeed {
return null;
}
try {
const response = await lazy.fetch(this.stories_endpoint, {
const response = await fetch(this.stories_endpoint, {
credentials: "omit",
});
if (!response.ok) {
@ -296,7 +292,7 @@ class TopStoriesFeed {
return null;
}
try {
const response = await lazy.fetch(this.topics_endpoint, {
const response = await fetch(this.topics_endpoint, {
credentials: "omit",
});
if (!response.ok) {

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

@ -14,8 +14,6 @@ const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
const RS_SERVER_PREF = "services.settings.server";
Cu.importGlobalProperties(["fetch"]);
const RemoteImagesTestUtils = {
/**
* Serve a mock Remote Settings server with content for Remote Images

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

@ -6,8 +6,6 @@
var EXPORTED_SYMBOLS = ["PageDataSchema"];
Cu.importGlobalProperties(["fetch"]);
const { XPCOMUtils } = ChromeUtils.import(
"resource://gre/modules/XPCOMUtils.jsm"
);

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

@ -10,13 +10,15 @@ const { XPCOMUtils } = ChromeUtils.import(
"resource://gre/modules/XPCOMUtils.jsm"
);
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
const { EventEmitter } = ChromeUtils.import(
"resource://gre/modules/EventEmitter.jsm"
);
const lazy = {};
XPCOMUtils.defineLazyModuleGetters(lazy, {
BrowserWindowTracker: "resource:///modules/BrowserWindowTracker.jsm",
E10SUtils: "resource://gre/modules/E10SUtils.jsm",
EventEmitter: "resource://gre/modules/EventEmitter.jsm",
HiddenFrame: "resource://gre/modules/HiddenFrame.jsm",
PromiseUtils: "resource://gre/modules/PromiseUtils.jsm",
});
@ -270,7 +272,7 @@ class PageDataCache {
* the format defined by the schemas at `browser/components/pagedata/schemas`.
*/
const PageDataService = new (class PageDataService extends lazy.EventEmitter {
const PageDataService = new (class PageDataService extends EventEmitter {
/**
* Caches page data discovered from browsers.
*

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

@ -7,11 +7,13 @@ const { XPCOMUtils } = ChromeUtils.import(
"resource://gre/modules/XPCOMUtils.jsm"
);
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
const { EventEmitter } = ChromeUtils.import(
"resource://gre/modules/EventEmitter.jsm"
);
const lazy = {};
XPCOMUtils.defineLazyModuleGetters(lazy, {
EventEmitter: "resource://gre/modules/EventEmitter.jsm",
DeferredTask: "resource://gre/modules/DeferredTask.jsm",
FilterAdult: "resource://activity-stream/lib/FilterAdult.jsm",
PlacesUIUtils: "resource:///modules/PlacesUIUtils.jsm",
@ -75,7 +77,7 @@ XPCOMUtils.defineLazyGetter(lazy, "logConsole", function() {
* This component is intentionally decoupled from where the context comes from
* so it can be unit tested.
*/
class SnapshotSelector extends lazy.EventEmitter {
class SnapshotSelector extends EventEmitter {
/**
* All of the active selectors.
*/

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

@ -230,6 +230,9 @@ const { XPCOMUtils } = ChromeUtils.import(
const { AppConstants } = ChromeUtils.import(
"resource://gre/modules/AppConstants.jsm"
);
const { GlobalState } = ChromeUtils.import(
"resource:///modules/sessionstore/GlobalState.jsm"
);
const lazy = {};
@ -248,7 +251,6 @@ XPCOMUtils.defineLazyModuleGetters(lazy, {
BrowserWindowTracker: "resource:///modules/BrowserWindowTracker.jsm",
DevToolsShim: "chrome://devtools-startup/content/DevToolsShim.jsm",
E10SUtils: "resource://gre/modules/E10SUtils.jsm",
GlobalState: "resource:///modules/sessionstore/GlobalState.jsm",
HomePage: "resource:///modules/HomePage.jsm",
PrivacyFilter: "resource://gre/modules/sessionstore/PrivacyFilter.jsm",
PromiseUtils: "resource://gre/modules/PromiseUtils.jsm",
@ -606,7 +608,7 @@ var SessionStoreInternal = {
"nsISupportsWeakReference",
]),
_globalState: new lazy.GlobalState(),
_globalState: new GlobalState(),
// A counter to be used to generate a unique ID for each closed tab or window.
_nextClosedId: 0,

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

@ -17,8 +17,6 @@ const { XPCOMUtils } = ChromeUtils.import(
);
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
XPCOMUtils.defineLazyGlobalGetters(this, ["fetch"]);
XPCOMUtils.defineLazyModuleGetters(this, {
ProfileAge: "resource://gre/modules/ProfileAge.jsm",
UrlbarPrefs: "resource:///modules/UrlbarPrefs.jsm",

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

@ -28,8 +28,6 @@ XPCOMUtils.defineLazyModuleGetters(this, {
UrlbarUtils: "resource:///modules/UrlbarUtils.jsm",
});
XPCOMUtils.defineLazyGlobalGetters(this, ["crypto", "fetch"]);
const TIMESTAMP_TEMPLATE = "%YYYYMMDDHH%";
const TIMESTAMP_LENGTH = 10;
const TIMESTAMP_REGEXP = /^\d{10}$/;

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

@ -165,7 +165,7 @@ const AVAILABLE_SHIMS = [
types: ["image", "imageset", "xmlhttprequest"],
},
],
onlyIfDFPIActive: true,
onlyIfBlockedByETP: true,
},
{
id: "AdSafeProtectedGoogleIMAAdapter",
@ -545,7 +545,7 @@ const AVAILABLE_SHIMS = [
types: ["image", "imageset", "xmlhttprequest"],
},
],
onlyIfDFPIActive: true,
onlyIfBlockedByETP: true,
},
{
id: "Vidible",

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

@ -2,7 +2,7 @@
"manifest_version": 2,
"name": "Web Compatibility Interventions",
"description": "Urgent post-release fixes for web compatibility.",
"version": "102.12.0",
"version": "102.13.0",
"applications": {
"gecko": {
"id": "webcompat@mozilla.org",

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

@ -4,8 +4,6 @@
"use strict";
Cu.importGlobalProperties(["fetch"]);
var EXPORTED_SYMBOLS = [
"PartnerLinkAttribution",
"CONTEXTUAL_SERVICES_PING_TYPES",

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

@ -0,0 +1,17 @@
[package]
name = "wasi"
version = "0.10.0+wasi-snapshot-preview999"
edition = "2018"
license = "MPL-2.0"
[lib]
path = "lib.rs"
[dependencies.wasi]
version = "0.11"
default-features = false
[features]
default = ["wasi/default"]
rustc-dep-of-std = ["wasi/rustc-dep-of-std"]
std = ["wasi/std"]

5
build/rust/wasi/lib.rs Normal file
Просмотреть файл

@ -0,0 +1,5 @@
/* 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/. */
pub use wasi::*;

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

@ -49,6 +49,7 @@ The plugin implements the following rules:
eslint-plugin-mozilla/reject-addtask-only
eslint-plugin-mozilla/reject-chromeutils-import-params
eslint-plugin-mozilla/reject-global-this
eslint-plugin-mozilla/reject-globalThis-modification
eslint-plugin-mozilla/reject-importGlobalProperties
eslint-plugin-mozilla/reject-osfile
eslint-plugin-mozilla/reject-relative-requires

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

@ -0,0 +1,19 @@
reject-globalThis-modification
==============================
Reject any modification to ``globalThis`` inside the system modules.
``globalThis`` is the shared global inside the system modules, and modification
on it is visible from all modules, and it shouldn't be done unless it's really
necessary.
Examples of incorrect code for this rule:
-----------------------------------------
.. code-block:: js
globalThis.foo = 10;
Object.defineProperty(globalThis, "bar", { value: 20});
XPCOMUtils.defineLazyModuleGetters(globalThis, {
Services: "resource://gre/modules/Services.jsm",
});

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

@ -16,8 +16,6 @@ if (DEBUG) {
var EXPORTED_SYMBOLS = ["IndexedDBHelper"];
Cu.importGlobalProperties(["indexedDB"]);
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
function getErrorName(err) {

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

@ -3,8 +3,6 @@
* http://creativecommons.org/publicdomain/zero/1.0/
*/
Cu.importGlobalProperties(["indexedDB"]);
var EXPORTED_SYMBOLS = ["GlobalObjectsModule"];
function GlobalObjectsModule() {}

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

@ -20,6 +20,7 @@
#include "mozilla/ipc/GeckoChildProcessHost.h"
#if defined(XP_LINUX) && defined(MOZ_SANDBOX)
# include "mozilla/SandboxInfo.h"
# include "base/shared_memory.h"
#endif
#include "mozilla/Services.h"
#include "mozilla/SSE.h"
@ -261,6 +262,16 @@ class NotifyGMPProcessLoadedTask : public Runnable {
NS_IMETHOD Run() override {
MOZ_ASSERT(NS_IsMainThread());
bool canProfile = true;
#if defined(XP_LINUX) && defined(MOZ_SANDBOX)
if (SandboxInfo::Get().Test(SandboxInfo::kEnabledForMedia) &&
base::SharedMemory::UsingPosixShm()) {
canProfile = false;
}
#endif
if (canProfile) {
nsCOMPtr<nsISerialEventTarget> gmpEventTarget =
mGMPParent->GMPEventTarget();
if (!gmpEventTarget) {
@ -274,6 +285,7 @@ class NotifyGMPProcessLoadedTask : public Runnable {
NewRunnableMethod<ipc::Endpoint<mozilla::PProfilerChild>&&>(
"GMPParent::SendInitProfiler", mGMPParent,
&GMPParent::SendInitProfiler, std::move(profilerParent)));
}
return NS_OK;
}

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

@ -774,7 +774,7 @@ void FFmpegVideoDecoder<LIBAV_VER>::InitVAAPICodecContext() {
#endif
static int64_t GetFramePts(AVFrame* aFrame) {
#if LIBAVCODEC_VERSION_MAJOR > 58
#if LIBAVCODEC_VERSION_MAJOR > 57
return aFrame->pts;
#else
return aFrame->pkt_pts;

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

@ -15,8 +15,6 @@ XPCOMUtils.defineLazyGetter(lazy, "gDOMBundle", () =>
Services.strings.createBundle("chrome://global/locale/dom/dom.properties")
);
XPCOMUtils.defineLazyGlobalGetters(lazy, ["crypto"]);
// getCryptoParamsFromHeaders is exported for test purposes.
const EXPORTED_SYMBOLS = ["PushCrypto", "getCryptoParamsFromHeaders"];
@ -243,17 +241,13 @@ function concatArray(arrays) {
}
function hmac(key) {
this.keyPromise = lazy.crypto.subtle.importKey(
"raw",
key,
HMAC_SHA256,
false,
["sign"]
);
this.keyPromise = crypto.subtle.importKey("raw", key, HMAC_SHA256, false, [
"sign",
]);
}
hmac.prototype.hash = function(input) {
return this.keyPromise.then(k => lazy.crypto.subtle.sign("HMAC", k, input));
return this.keyPromise.then(k => crypto.subtle.sign("HMAC", k, input));
};
function hkdf(salt, ikm) {
@ -331,7 +325,7 @@ class Decoder {
try {
let ikm = await this.computeSharedSecret();
let [gcmBits, nonce] = await this.deriveKeyAndNonce(ikm);
let key = await lazy.crypto.subtle.importKey(
let key = await crypto.subtle.importKey(
"raw",
gcmBits,
"AES-GCM",
@ -368,14 +362,14 @@ class Decoder {
*/
async computeSharedSecret() {
let [appServerKey, subscriptionPrivateKey] = await Promise.all([
lazy.crypto.subtle.importKey("raw", this.senderKey, ECDH_KEY, false, [
crypto.subtle.importKey("raw", this.senderKey, ECDH_KEY, false, [
"deriveBits",
]),
lazy.crypto.subtle.importKey("jwk", this.privateKey, ECDH_KEY, false, [
crypto.subtle.importKey("jwk", this.privateKey, ECDH_KEY, false, [
"deriveBits",
]),
]);
return lazy.crypto.subtle.deriveBits(
return crypto.subtle.deriveBits(
{ name: "ECDH", public: appServerKey },
subscriptionPrivateKey,
256
@ -408,7 +402,7 @@ class Decoder {
name: "AES-GCM",
iv: generateNonce(nonce, index),
};
let decoded = await lazy.crypto.subtle.decrypt(params, key, slice);
let decoded = await crypto.subtle.decrypt(params, key, slice);
return this.unpadChunk(new Uint8Array(decoded), last);
}
@ -609,22 +603,22 @@ var PushCrypto = {
concatArray,
generateAuthenticationSecret() {
return lazy.crypto.getRandomValues(new Uint8Array(16));
return crypto.getRandomValues(new Uint8Array(16));
},
validateAppServerKey(key) {
return lazy.crypto.subtle
return crypto.subtle
.importKey("raw", key, ECDSA_KEY, true, ["verify"])
.then(_ => key);
},
generateKeys() {
return lazy.crypto.subtle
return crypto.subtle
.generateKey(ECDH_KEY, true, ["deriveBits"])
.then(cryptoKey =>
Promise.all([
lazy.crypto.subtle.exportKey("raw", cryptoKey.publicKey),
lazy.crypto.subtle.exportKey("jwk", cryptoKey.privateKey),
crypto.subtle.exportKey("raw", cryptoKey.publicKey),
crypto.subtle.exportKey("jwk", cryptoKey.privateKey),
])
);
},
@ -731,10 +725,9 @@ var PushCrypto = {
// purposes we allow it to be specified.
const senderKeyPair =
options.senderKeyPair ||
(await lazy.crypto.subtle.generateKey(ECDH_KEY, true, ["deriveBits"]));
(await crypto.subtle.generateKey(ECDH_KEY, true, ["deriveBits"]));
// allowing a salt to be specified is useful for tests.
const salt =
options.salt || lazy.crypto.getRandomValues(new Uint8Array(16));
const salt = options.salt || crypto.getRandomValues(new Uint8Array(16));
const rs = options.rs === undefined ? 4096 : options.rs;
const encoder = new aes128gcmEncoder(
@ -773,7 +766,7 @@ class aes128gcmEncoder {
this.senderKeyPair.privateKey
);
const rawSenderPublicKey = await lazy.crypto.subtle.exportKey(
const rawSenderPublicKey = await crypto.subtle.exportKey(
"raw",
this.senderKeyPair.publicKey
);
@ -782,7 +775,7 @@ class aes128gcmEncoder {
rawSenderPublicKey
);
const contentEncryptionKey = await lazy.crypto.subtle.importKey(
const contentEncryptionKey = await crypto.subtle.importKey(
"raw",
gcmBits,
"AES-GCM",
@ -808,7 +801,7 @@ class aes128gcmEncoder {
if (this.plaintext.byteLength === 0) {
// Send an authentication tag for empty messages.
chunks = [
await lazy.crypto.subtle.encrypt(
await crypto.subtle.encrypt(
{
name: "AES-GCM",
iv: generateNonce(nonce, 0),
@ -826,7 +819,7 @@ class aes128gcmEncoder {
let isLast = index == inChunks.length - 1;
let padding = new Uint8Array([isLast ? 2 : 1]);
let input = concatArray([slice, padding]);
return lazy.crypto.subtle.encrypt(
return crypto.subtle.encrypt(
{
name: "AES-GCM",
iv: generateNonce(nonce, index),
@ -860,7 +853,7 @@ class aes128gcmEncoder {
// Note: this duplicates some of Decoder.computeSharedSecret, but the key
// management is slightly different.
async computeSharedSecret(receiverPublicKey, senderPrivateKey) {
const receiverPublicCryptoKey = await lazy.crypto.subtle.importKey(
const receiverPublicCryptoKey = await crypto.subtle.importKey(
"raw",
receiverPublicKey,
ECDH_KEY,
@ -868,7 +861,7 @@ class aes128gcmEncoder {
["deriveBits"]
);
return lazy.crypto.subtle.deriveBits(
return crypto.subtle.deriveBits(
{ name: "ECDH", public: receiverPublicCryptoKey },
senderPrivateKey,
256

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

@ -3,3 +3,6 @@ support-files = file_no_cache.sjs
[browser_navigation.js]
[browser_external_loads.js]
support-files =
file_dummy_link.html
file_dummy_link_location.html

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

@ -1,6 +1,11 @@
"use strict";
let gExpectedHeader = {};
const TEST_PATH = getRootDirectory(gTestPath).replace(
"chrome://mochitests/content",
"https://example.com"
);
var gExpectedHeader = {};
function checkSecFetchUser(subject, topic, data) {
let channel = subject.QueryInterface(Ci.nsIHttpChannel);
@ -27,7 +32,7 @@ function checkSecFetchUser(subject, topic, data) {
);
} catch (e) {
if (expectedValue) {
ok(false, "required headers are set");
ok(false, `${header} should be set`);
} else {
ok(true, `${header} should not be set`);
}
@ -37,7 +42,10 @@ function checkSecFetchUser(subject, topic, data) {
add_task(async function external_load() {
waitForExplicitFinish();
Services.obs.addObserver(checkSecFetchUser, "http-on-stop-request");
// Simulate an external load in the *current* window with
// Ci.nsIBrowserDOMWindow.OPEN_EXTERNAL and the system principal.
gExpectedHeader = {
"sec-fetch-site": "none",
"sec-fetch-mode": "navigate",
@ -45,13 +53,9 @@ add_task(async function external_load() {
"sec-fetch-user": "?1",
};
Services.obs.addObserver(checkSecFetchUser, "http-on-stop-request");
let loaded = BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser);
// Simulate an external load with Ci.nsIBrowserDOMWindow.OPEN_EXTERNAL and
// the system principal.
window.browserDOMWindow.openURI(
makeURI("https://example.com"),
makeURI(`${TEST_PATH}file_dummy_link.html`),
null,
Ci.nsIBrowserDOMWindow.OPEN_CURRENTWINDOW,
Ci.nsIBrowserDOMWindow.OPEN_EXTERNAL,
@ -59,6 +63,96 @@ add_task(async function external_load() {
);
await loaded;
// Open a link in a *new* window through the context menu.
gExpectedHeader = {
"sec-fetch-site": "same-origin",
"sec-fetch-mode": "navigate",
"sec-fetch-dest": "document",
"sec-fetch-user": "?1",
};
loaded = BrowserTestUtils.waitForNewWindow({
url: `${TEST_PATH}file_dummy_link_location.html`,
});
BrowserTestUtils.waitForEvent(document, "popupshown", false, event => {
document.getElementById("context-openlink").doCommand();
event.target.hidePopup();
return true;
});
BrowserTestUtils.synthesizeMouseAtCenter(
"#dummylink",
{ type: "contextmenu", button: 2 },
gBrowser.selectedBrowser
);
let win = await loaded;
win.close();
// Simulate an external load in a *new* window with
// Ci.nsIBrowserDOMWindow.OPEN_EXTERNAL and the system principal.
gExpectedHeader = {
"sec-fetch-site": "none",
"sec-fetch-mode": "navigate",
"sec-fetch-dest": "document",
"sec-fetch-user": "?1",
};
loaded = BrowserTestUtils.waitForNewWindow({
url: "https://example.com/newwindow",
});
window.browserDOMWindow.openURI(
makeURI("https://example.com/newwindow"),
null,
Ci.nsIBrowserDOMWindow.OPEN_NEWWINDOW,
Ci.nsIBrowserDOMWindow.OPEN_EXTERNAL,
Services.scriptSecurityManager.getSystemPrincipal()
);
win = await loaded;
win.close();
// Open a *new* window through window.open without user activation.
gExpectedHeader = {
"sec-fetch-site": "same-origin",
"sec-fetch-mode": "navigate",
"sec-fetch-dest": "document",
};
loaded = BrowserTestUtils.waitForNewWindow({
url: "https://example.com/windowopen",
});
await SpecialPowers.spawn(gBrowser.selectedBrowser, [], () => {
content.window.open(
"https://example.com/windowopen",
"_blank",
"height=500,width=500"
);
});
win = await loaded;
win.close();
// Open a *new* window through window.open with user activation.
gExpectedHeader = {
"sec-fetch-site": "same-origin",
"sec-fetch-mode": "navigate",
"sec-fetch-dest": "document",
"sec-fetch-user": "?1",
};
loaded = BrowserTestUtils.waitForNewWindow({
url: "https://example.com/windowopen_withactivation",
});
await SpecialPowers.spawn(gBrowser.selectedBrowser, [], () => {
content.document.notifyUserGestureActivation();
content.window.open(
"https://example.com/windowopen_withactivation",
"_blank",
"height=500,width=500"
);
content.document.clearUserGestureActivation();
});
win = await loaded;
win.close();
Services.obs.removeObserver(checkSecFetchUser, "http-on-stop-request");
finish();
});

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

@ -0,0 +1,9 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Bug 1738694 - Sec-Fetch-User header is missing when opening a link in a new window</title>
</head>
<body>
<a id="dummylink" href="file_dummy_link_location.html">Open</a>
</body>
</html>

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

@ -0,0 +1,9 @@
<!DOCTYPE HTML>
<html>
<head>
<title>Bug 1738694 - Sec-Fetch-User header is missing when opening a link in a new window</title>
</head>
<body>
<h1>file_dummy_link_location.html</h1>
</body>
</html>

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

@ -17,8 +17,6 @@ XPCOMUtils.defineLazyModuleGetters(lazy, {
setTimeout: "resource://gre/modules/Timer.jsm",
});
XPCOMUtils.defineLazyGlobalGetters(lazy, ["fetch"]);
// GeolocationPositionError has no interface object, so we can't use that here.
const POSITION_UNAVAILABLE = 2;
@ -492,7 +490,7 @@ NetworkGeolocationProvider.prototype = {
Services.prefs.getIntPref("geo.provider.network.timeout")
);
let req = await lazy.fetch(url, fetchOpts);
let req = await fetch(url, fetchOpts);
lazy.clearTimeout(timeoutId);
let result = req.json();
return result;

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

@ -179,4 +179,51 @@ bool SplitNodeResult::MoveCaretPointTo(EditorDOMPoint& aPointToPutCaret,
return true;
}
/******************************************************************************
* mozilla::SplitRangeOffFromNodeResult
*****************************************************************************/
nsresult SplitRangeOffFromNodeResult::SuggestCaretPointTo(
const HTMLEditor& aHTMLEditor, const SuggestCaretOptions& aOptions) const {
mHandledCaretPoint = true;
if (!mCaretPoint.IsSet()) {
if (aOptions.contains(SuggestCaret::OnlyIfHasSuggestion)) {
return NS_OK;
}
NS_WARNING("There was no suggestion to put caret");
return NS_ERROR_FAILURE;
}
if (aOptions.contains(SuggestCaret::OnlyIfTransactionsAllowedToDoIt) &&
!aHTMLEditor.AllowsTransactionsToChangeSelection()) {
return NS_OK;
}
nsresult rv = aHTMLEditor.CollapseSelectionTo(mCaretPoint);
if (MOZ_UNLIKELY(rv == NS_ERROR_EDITOR_DESTROYED)) {
NS_WARNING(
"EditorBase::CollapseSelectionTo() caused destroying the editor");
return NS_ERROR_EDITOR_DESTROYED;
}
return aOptions.contains(SuggestCaret::AndIgnoreTrivialError) &&
MOZ_UNLIKELY(NS_FAILED(rv))
? NS_SUCCESS_EDITOR_BUT_IGNORED_TRIVIAL_ERROR
: rv;
}
bool SplitRangeOffFromNodeResult::MoveCaretPointTo(
EditorDOMPoint& aPointToPutCaret, const HTMLEditor& aHTMLEditor,
const SuggestCaretOptions& aOptions) {
MOZ_ASSERT(!aOptions.contains(SuggestCaret::AndIgnoreTrivialError));
mHandledCaretPoint = true;
if (aOptions.contains(SuggestCaret::OnlyIfHasSuggestion) &&
!mCaretPoint.IsSet()) {
return false;
}
if (aOptions.contains(SuggestCaret::OnlyIfTransactionsAllowedToDoIt) &&
!aHTMLEditor.AllowsTransactionsToChangeSelection()) {
return false;
}
aPointToPutCaret = UnwrapCaretPoint();
return true;
}
} // namespace mozilla

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

@ -825,6 +825,41 @@ class MOZ_STACK_CLASS SplitRangeOffFromNodeResult final {
return dom::Element::FromNodeOrNull(mRightContent);
}
/**
* Suggest caret position to aHTMLEditor.
*/
[[nodiscard]] MOZ_CAN_RUN_SCRIPT nsresult SuggestCaretPointTo(
const HTMLEditor& aHTMLEditor, const SuggestCaretOptions& aOptions) const;
/**
* IgnoreCaretPointSuggestion() should be called if the method does not want
* to use caret position recommended by this instance.
*/
void IgnoreCaretPointSuggestion() const { mHandledCaretPoint = true; }
bool HasCaretPointSuggestion() const { return mCaretPoint.IsSet(); }
constexpr EditorDOMPoint&& UnwrapCaretPoint() {
mHandledCaretPoint = true;
return std::move(mCaretPoint);
}
bool MoveCaretPointTo(EditorDOMPoint& aPointToPutCaret,
const SuggestCaretOptions& aOptions) {
MOZ_ASSERT(!aOptions.contains(SuggestCaret::AndIgnoreTrivialError));
MOZ_ASSERT(
!aOptions.contains(SuggestCaret::OnlyIfTransactionsAllowedToDoIt));
if (aOptions.contains(SuggestCaret::OnlyIfHasSuggestion) &&
!mCaretPoint.IsSet()) {
return false;
}
aPointToPutCaret = UnwrapCaretPoint();
return true;
}
bool MoveCaretPointTo(EditorDOMPoint& aPointToPutCaret,
const HTMLEditor& aHTMLEditor,
const SuggestCaretOptions& aOptions);
SplitRangeOffFromNodeResult() = delete;
SplitRangeOffFromNodeResult(nsIContent* aLeftContent,
nsIContent* aMiddleContent,
nsIContent* aRightContent)
@ -833,12 +868,22 @@ class MOZ_STACK_CLASS SplitRangeOffFromNodeResult final {
mRightContent(aRightContent),
mRv(NS_OK) {}
SplitRangeOffFromNodeResult(nsIContent* aLeftContent,
nsIContent* aMiddleContent,
nsIContent* aRightContent,
EditorDOMPoint&& aPointToPutCaret)
: mLeftContent(aLeftContent),
mMiddleContent(aMiddleContent),
mRightContent(aRightContent),
mCaretPoint(std::move(aPointToPutCaret)),
mRv(NS_OK) {}
SplitRangeOffFromNodeResult(SplitNodeResult&& aSplitResultAtLeftOfMiddleNode,
SplitNodeResult&& aSplitResultAtRightOfMiddleNode)
: mRv(NS_OK) {
// The given results are created for creating this instance so that the
// caller may not need to handle with them. For making who taking the
// reposible clearer, we should move them into this constructor.
// responsible clearer, we should move them into this constructor.
SplitNodeResult splitResultAtLeftOfMiddleNode(
std::move(aSplitResultAtLeftOfMiddleNode));
SplitNodeResult splitResultARightOfMiddleNode(
@ -855,6 +900,15 @@ class MOZ_STACK_CLASS SplitRangeOffFromNodeResult final {
if (!mMiddleContent && splitResultAtLeftOfMiddleNode.isOk()) {
mMiddleContent = splitResultAtLeftOfMiddleNode.GetNextContent();
}
// Prefer the right split result if available.
if (splitResultARightOfMiddleNode.HasCaretPointSuggestion()) {
splitResultAtLeftOfMiddleNode.IgnoreCaretPointSuggestion();
mCaretPoint = splitResultARightOfMiddleNode.UnwrapCaretPoint();
}
// Otherwise, if the left split result has a suggestion, take it.
else if (splitResultAtLeftOfMiddleNode.HasCaretPointSuggestion()) {
mCaretPoint = splitResultAtLeftOfMiddleNode.UnwrapCaretPoint();
}
}
explicit SplitRangeOffFromNodeResult(nsresult aRv) : mRv(aRv) {
@ -869,14 +923,24 @@ class MOZ_STACK_CLASS SplitRangeOffFromNodeResult final {
SplitRangeOffFromNodeResult& operator=(SplitRangeOffFromNodeResult&& aOther) =
default;
#ifdef DEBUG
~SplitRangeOffFromNodeResult() {
MOZ_ASSERT_IF(isOk(), !mCaretPoint.IsSet() || mHandledCaretPoint);
}
#endif
private:
nsCOMPtr<nsIContent> mLeftContent;
nsCOMPtr<nsIContent> mMiddleContent;
nsCOMPtr<nsIContent> mRightContent;
// The point which is a good point to put caret from point of view the
// splitter.
EditorDOMPoint mCaretPoint;
nsresult mRv;
SplitRangeOffFromNodeResult() = delete;
bool mutable mHandledCaretPoint = false;
};
/*****************************************************************************

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

@ -3794,7 +3794,7 @@ nsresult HTMLEditor::RemoveListAtSelectionAsSubAction() {
nsresult HTMLEditor::FormatBlockContainerWithTransaction(nsAtom& blockType) {
MOZ_ASSERT(IsTopLevelEditSubActionDataAvailable());
RefPtr<Element> editingHost = ComputeEditingHost();
const RefPtr<Element> editingHost = ComputeEditingHost();
if (MOZ_UNLIKELY(NS_WARN_IF(!editingHost))) {
return NS_ERROR_FAILURE;
}
@ -3972,16 +3972,27 @@ nsresult HTMLEditor::FormatBlockContainerWithTransaction(nsAtom& blockType) {
return rv;
}
if (&blockType == nsGkAtoms::normal || &blockType == nsGkAtoms::_empty) {
nsresult rv = RemoveBlockContainerElements(arrayOfContents);
NS_WARNING_ASSERTION(NS_SUCCEEDED(rv),
"HTMLEditor::RemoveBlockContainerElements() failed");
return rv;
Result<EditorDOMPoint, nsresult> removeBlockContainerElementsResult =
RemoveBlockContainerElementsWithTransaction(arrayOfContents);
if (MOZ_UNLIKELY(removeBlockContainerElementsResult.isErr())) {
NS_WARNING(
"HTMLEditor::RemoveBlockContainerElementsWithTransaction() failed");
removeBlockContainerElementsResult.unwrapErr();
}
rv = CreateOrChangeBlockContainerElement(arrayOfContents, blockType);
NS_WARNING_ASSERTION(
NS_SUCCEEDED(rv),
"HTMLEditor::CreateOrChangeBlockContainerElement() failed");
return rv;
// Selection will be restored by `restoreSelectionLater`. Therefore, we
// should ignore the suggested caret point.
return NS_OK;
}
Result<EditorDOMPoint, nsresult> wrapContentsInBlockElementResult =
CreateOrChangeBlockContainerElement(arrayOfContents, blockType,
*editingHost);
if (MOZ_UNLIKELY(wrapContentsInBlockElementResult.isErr())) {
NS_WARNING("HTMLEditor::CreateOrChangeBlockContainerElement() failed");
return wrapContentsInBlockElementResult.unwrapErr();
}
// Selection will be restored by `restoreSelectionLater`. Therefore, we
// should ignore the suggested caret point.
return NS_OK;
}
nsresult HTMLEditor::MaybeInsertPaddingBRElementForEmptyLastLineAtSelection() {
@ -5292,36 +5303,37 @@ SplitRangeOffFromNodeResult HTMLEditor::HandleOutdentAtSelectionInternal() {
}
SplitRangeOffFromNodeResult
HTMLEditor::SplitRangeOffFromBlockAndRemoveMiddleContainer(
Element& aBlockElement, nsIContent& aStartOfRange,
HTMLEditor::RemoveBlockContainerElementWithTransactionBetween(
Element& aBlockContainerElement, nsIContent& aStartOfRange,
nsIContent& aEndOfRange) {
MOZ_ASSERT(IsEditActionDataAvailable());
SplitRangeOffFromNodeResult splitResult =
SplitRangeOffFromBlock(aBlockElement, aStartOfRange, aEndOfRange);
EditorDOMPoint pointToPutCaret;
SplitRangeOffFromNodeResult splitResult = SplitRangeOffFromBlock(
aBlockContainerElement, aStartOfRange, aEndOfRange);
if (splitResult.EditorDestroyed()) {
NS_WARNING(
"HTMLEditor::SplitRangeOffFromBlock() caused destorying the editor");
NS_WARNING("HTMLEditor::SplitRangeOffFromBlock() failed");
return splitResult;
}
NS_WARNING_ASSERTION(
splitResult.isOk(),
if (splitResult.isOk()) {
splitResult.MoveCaretPointTo(pointToPutCaret,
{SuggestCaret::OnlyIfHasSuggestion});
} else {
NS_WARNING(
"HTMLEditor::SplitRangeOffFromBlock() failed, but might be ignored");
const Result<EditorDOMPoint, nsresult> unwrapBlockElementResult =
RemoveBlockContainerWithTransaction(aBlockElement);
if (MOZ_UNLIKELY(unwrapBlockElementResult.isErr())) {
}
Result<EditorDOMPoint, nsresult> unwrapBlockElementResult =
RemoveBlockContainerWithTransaction(aBlockContainerElement);
if (unwrapBlockElementResult.isErr()) {
NS_WARNING("HTMLEditor::RemoveBlockContainerWithTransaction() failed");
return SplitRangeOffFromNodeResult(unwrapBlockElementResult.inspectErr());
}
const EditorDOMPoint& pointToPutCaret = unwrapBlockElementResult.inspect();
if (AllowsTransactionsToChangeSelection() && pointToPutCaret.IsSet()) {
nsresult rv = CollapseSelectionTo(pointToPutCaret);
if (NS_FAILED(rv)) {
return SplitRangeOffFromNodeResult(rv);
}
if (unwrapBlockElementResult.inspect().IsSet()) {
pointToPutCaret = unwrapBlockElementResult.unwrap();
}
return SplitRangeOffFromNodeResult(splitResult.GetLeftContent(), nullptr,
splitResult.GetRightContent());
splitResult.GetRightContent(),
std::move(pointToPutCaret));
}
SplitRangeOffFromNodeResult HTMLEditor::SplitRangeOffFromBlock(
@ -5338,7 +5350,8 @@ SplitRangeOffFromNodeResult HTMLEditor::SplitRangeOffFromBlock(
SplitNodeResult splitAtStartResult = SplitNodeDeepWithTransaction(
aBlockElement, EditorDOMPoint(&aStartOfMiddleElement),
SplitAtEdges::eDoNotCreateEmptyContainer);
if (MOZ_UNLIKELY(NS_WARN_IF(splitAtStartResult.EditorDestroyed()))) {
if (splitAtStartResult.EditorDestroyed()) {
NS_WARNING("HTMLEditor::SplitNodeDeepWithTransaction() failed (at left)");
return SplitRangeOffFromNodeResult(NS_ERROR_EDITOR_DESTROYED);
}
NS_WARNING_ASSERTION(
@ -5350,7 +5363,8 @@ SplitRangeOffFromNodeResult HTMLEditor::SplitRangeOffFromBlock(
auto atAfterEnd = EditorDOMPoint::After(aEndOfMiddleElement);
SplitNodeResult splitAtEndResult = SplitNodeDeepWithTransaction(
aBlockElement, atAfterEnd, SplitAtEdges::eDoNotCreateEmptyContainer);
if (MOZ_UNLIKELY(NS_WARN_IF(splitAtEndResult.EditorDestroyed()))) {
if (splitAtEndResult.EditorDestroyed()) {
NS_WARNING("HTMLEditor::SplitNodeDeepWithTransaction() failed (at right)");
return SplitRangeOffFromNodeResult(NS_ERROR_EDITOR_DESTROYED);
}
NS_WARNING_ASSERTION(
@ -5358,26 +5372,6 @@ SplitRangeOffFromNodeResult HTMLEditor::SplitRangeOffFromBlock(
"HTMLEditor::SplitNodeDeepWithTransaction(SplitAtEdges::"
"eDoNotCreateEmptyContainer) after end of middle element failed");
if (AllowsTransactionsToChangeSelection() &&
(splitAtStartResult.HasCaretPointSuggestion() ||
splitAtEndResult.HasCaretPointSuggestion())) {
const SplitNodeResult& splitNodeResultHavingLatestCaretSuggestion =
[&]() -> SplitNodeResult& {
if (splitAtEndResult.HasCaretPointSuggestion()) {
splitAtStartResult.IgnoreCaretPointSuggestion();
return splitAtEndResult;
}
return splitAtStartResult;
}();
nsresult rv =
splitNodeResultHavingLatestCaretSuggestion.SuggestCaretPointTo(
*this, {SuggestCaret::OnlyIfHasSuggestion});
if (NS_FAILED(rv)) {
NS_WARNING("SplitNodeResult::SuggestCaretPointTo() failed");
return SplitRangeOffFromNodeResult(rv);
}
}
return SplitRangeOffFromNodeResult(std::move(splitAtStartResult),
std::move(splitAtEndResult));
}
@ -5389,18 +5383,34 @@ SplitRangeOffFromNodeResult HTMLEditor::OutdentPartOfBlock(
SplitRangeOffFromNodeResult splitResult =
SplitRangeOffFromBlock(aBlockElement, aStartOfOutdent, aEndOfOutdent);
if (NS_WARN_IF(splitResult.EditorDestroyed())) {
if (splitResult.EditorDestroyed()) {
NS_WARNING("HTMLEditor::SplitRangeOffFromBlock() failed");
return SplitRangeOffFromNodeResult(NS_ERROR_EDITOR_DESTROYED);
}
if (!splitResult.GetMiddleContentAsElement()) {
NS_WARNING(
"HTMLEditor::SplitRangeOffFromBlock() didn't return middle content");
splitResult.IgnoreCaretPointSuggestion();
return SplitRangeOffFromNodeResult(NS_ERROR_FAILURE);
}
NS_WARNING_ASSERTION(
splitResult.isOk(),
if (splitResult.isOk()) {
nsresult rv = splitResult.SuggestCaretPointTo(
*this, {SuggestCaret::OnlyIfHasSuggestion,
SuggestCaret::OnlyIfTransactionsAllowedToDoIt,
SuggestCaret::AndIgnoreTrivialError});
if (NS_FAILED(rv)) {
NS_WARNING("SplitRangeOffFromNodeResult::SuggestCaretPointTo() failed");
return SplitRangeOffFromNodeResult(rv);
}
NS_WARNING_ASSERTION(NS_SUCCEEDED(rv),
"SplitRangeOffFromNodeResult::SuggestCaretPointTo() "
"failed, but ignored");
} else {
NS_WARNING(
"HTMLEditor::SplitRangeOffFromBlock() failed, but might be ignored");
}
if (aBlockIndentedWith == BlockIndentedWith::HTML) {
Result<EditorDOMPoint, nsresult> unwrapBlockElementResult =
@ -8323,8 +8333,9 @@ nsresult HTMLEditor::MoveNodesIntoNewBlockquoteElement(
return NS_OK;
}
nsresult HTMLEditor::RemoveBlockContainerElements(
nsTArray<OwningNonNull<nsIContent>>& aArrayOfContents) {
Result<EditorDOMPoint, nsresult>
HTMLEditor::RemoveBlockContainerElementsWithTransaction(
const nsTArray<OwningNonNull<nsIContent>>& aArrayOfContents) {
MOZ_ASSERT(IsEditActionDataAvailable());
// Intent of this routine is to be used for converting to/from headers,
@ -8332,41 +8343,38 @@ nsresult HTMLEditor::RemoveBlockContainerElements(
// inline things...
RefPtr<Element> blockElement;
nsCOMPtr<nsIContent> firstContent, lastContent;
EditorDOMPoint pointToPutCaret;
for (auto& content : aArrayOfContents) {
// If curNode is an <address>, <p>, <hn>, or <pre>, remove it.
if (HTMLEditUtils::IsFormatNode(content)) {
// Process any partial progress saved
if (blockElement) {
SplitRangeOffFromNodeResult removeMiddleContainerResult =
SplitRangeOffFromBlockAndRemoveMiddleContainer(
SplitRangeOffFromNodeResult unwrapBlockElementResult =
RemoveBlockContainerElementWithTransactionBetween(
*blockElement, *firstContent, *lastContent);
if (removeMiddleContainerResult.isErr()) {
if (unwrapBlockElementResult.isErr()) {
NS_WARNING(
"HTMLEditor::SplitRangeOffFromBlockAndRemoveMiddleContainer() "
"HTMLEditor::RemoveBlockContainerElementWithTransactionBetween() "
"failed");
return removeMiddleContainerResult.unwrapErr();
return Err(unwrapBlockElementResult.unwrapErr());
}
unwrapBlockElementResult.MoveCaretPointTo(
pointToPutCaret, {SuggestCaret::OnlyIfHasSuggestion});
firstContent = lastContent = blockElement = nullptr;
}
if (!EditorUtils::IsEditableContent(content, EditorType::HTML)) {
continue;
}
// Remove current block
const Result<EditorDOMPoint, nsresult> unwrapFormatBlockResult =
Result<EditorDOMPoint, nsresult> unwrapFormatBlockResult =
RemoveBlockContainerWithTransaction(
MOZ_KnownLive(*content->AsElement()));
if (MOZ_UNLIKELY(unwrapFormatBlockResult.isErr())) {
NS_WARNING("HTMLEditor::RemoveBlockContainerWithTransaction() failed");
return unwrapFormatBlockResult.inspectErr();
return unwrapFormatBlockResult;
}
const EditorDOMPoint& pointToPutCaret = unwrapFormatBlockResult.inspect();
if (!AllowsTransactionsToChangeSelection() || !pointToPutCaret.IsSet()) {
continue;
}
nsresult rv = CollapseSelectionTo(pointToPutCaret);
if (NS_FAILED(rv)) {
NS_WARNING("EditorBase::CollapseSelectionTo() failed");
return rv;
if (unwrapFormatBlockResult.inspect().IsSet()) {
pointToPutCaret = unwrapFormatBlockResult.unwrap();
}
continue;
}
@ -8378,15 +8386,17 @@ nsresult HTMLEditor::RemoveBlockContainerElements(
HTMLEditUtils::IsAnyListElement(content)) {
// Process any partial progress saved
if (blockElement) {
SplitRangeOffFromNodeResult removeMiddleContainerResult =
SplitRangeOffFromBlockAndRemoveMiddleContainer(
SplitRangeOffFromNodeResult unwrapBlockElementResult =
RemoveBlockContainerElementWithTransactionBetween(
*blockElement, *firstContent, *lastContent);
if (removeMiddleContainerResult.isErr()) {
if (unwrapBlockElementResult.isErr()) {
NS_WARNING(
"HTMLEditor::SplitRangeOffFromBlockAndRemoveMiddleContainer() "
"HTMLEditor::RemoveBlockContainerElementWithTransactionBetween() "
"failed");
return removeMiddleContainerResult.unwrapErr();
return Err(unwrapBlockElementResult.unwrapErr());
}
unwrapBlockElementResult.MoveCaretPointTo(
pointToPutCaret, {SuggestCaret::OnlyIfHasSuggestion});
firstContent = lastContent = blockElement = nullptr;
}
if (!EditorUtils::IsEditableContent(content, EditorType::HTML)) {
@ -8395,10 +8405,15 @@ nsresult HTMLEditor::RemoveBlockContainerElements(
// Recursion time
AutoTArray<OwningNonNull<nsIContent>, 24> childContents;
HTMLEditor::GetChildNodesOf(*content, childContents);
nsresult rv = RemoveBlockContainerElements(childContents);
if (NS_FAILED(rv)) {
NS_WARNING("HTMLEditor::RemoveBlockContainerElements() failed");
return rv;
Result<EditorDOMPoint, nsresult> removeBlockContainerElementsResult =
RemoveBlockContainerElementsWithTransaction(childContents);
if (MOZ_UNLIKELY(removeBlockContainerElementsResult.isErr())) {
NS_WARNING(
"HTMLEditor::RemoveBlockContainerElementsWithTransaction() failed");
return removeBlockContainerElementsResult;
}
if (removeBlockContainerElementsResult.inspect().IsSet()) {
pointToPutCaret = removeBlockContainerElementsResult.unwrap();
}
continue;
}
@ -8414,15 +8429,17 @@ nsresult HTMLEditor::RemoveBlockContainerElements(
// Otherwise, we have progressed beyond end of blockElement, so let's
// handle it now. We need to remove the portion of blockElement that
// contains [firstContent - lastContent].
SplitRangeOffFromNodeResult removeMiddleContainerResult =
SplitRangeOffFromBlockAndRemoveMiddleContainer(
SplitRangeOffFromNodeResult unwrapBlockElementResult =
RemoveBlockContainerElementWithTransactionBetween(
*blockElement, *firstContent, *lastContent);
if (removeMiddleContainerResult.isErr()) {
if (unwrapBlockElementResult.isErr()) {
NS_WARNING(
"HTMLEditor::SplitRangeOffFromBlockAndRemoveMiddleContainer() "
"HTMLEditor::RemoveBlockContainerElementWithTransactionBetween() "
"failed");
return removeMiddleContainerResult.unwrapErr();
return Err(unwrapBlockElementResult.unwrapErr());
}
unwrapBlockElementResult.MoveCaretPointTo(
pointToPutCaret, {SuggestCaret::OnlyIfHasSuggestion});
firstContent = lastContent = blockElement = nullptr;
// Fall out and handle content
}
@ -8441,49 +8458,50 @@ nsresult HTMLEditor::RemoveBlockContainerElements(
if (blockElement) {
// Some node that is already sans block style. Skip over it and process
// any partial progress saved.
SplitRangeOffFromNodeResult removeMiddleContainerResult =
SplitRangeOffFromBlockAndRemoveMiddleContainer(
SplitRangeOffFromNodeResult unwrapBlockElementResult =
RemoveBlockContainerElementWithTransactionBetween(
*blockElement, *firstContent, *lastContent);
if (removeMiddleContainerResult.isErr()) {
if (unwrapBlockElementResult.isErr()) {
NS_WARNING(
"HTMLEditor::SplitRangeOffFromBlockAndRemoveMiddleContainer() "
"HTMLEditor::RemoveBlockContainerElementWithTransactionBetween() "
"failed");
return removeMiddleContainerResult.unwrapErr();
return Err(unwrapBlockElementResult.unwrapErr());
}
unwrapBlockElementResult.MoveCaretPointTo(
pointToPutCaret, {SuggestCaret::OnlyIfHasSuggestion});
firstContent = lastContent = blockElement = nullptr;
continue;
}
}
// Process any partial progress saved
if (blockElement) {
SplitRangeOffFromNodeResult removeMiddleContainerResult =
SplitRangeOffFromBlockAndRemoveMiddleContainer(
SplitRangeOffFromNodeResult unwrapBlockElementResult =
RemoveBlockContainerElementWithTransactionBetween(
*blockElement, *firstContent, *lastContent);
if (removeMiddleContainerResult.isErr()) {
if (unwrapBlockElementResult.isErr()) {
NS_WARNING(
"HTMLEditor::SplitRangeOffFromBlockAndRemoveMiddleContainer() "
"HTMLEditor::RemoveBlockContainerElementWithTransactionBetween() "
"failed");
return removeMiddleContainerResult.unwrapErr();
return Err(unwrapBlockElementResult.unwrapErr());
}
unwrapBlockElementResult.MoveCaretPointTo(
pointToPutCaret, {SuggestCaret::OnlyIfHasSuggestion});
firstContent = lastContent = blockElement = nullptr;
}
return NS_OK;
return pointToPutCaret;
}
nsresult HTMLEditor::CreateOrChangeBlockContainerElement(
nsTArray<OwningNonNull<nsIContent>>& aArrayOfContents, nsAtom& aBlockTag) {
Result<EditorDOMPoint, nsresult>
HTMLEditor::CreateOrChangeBlockContainerElement(
nsTArray<OwningNonNull<nsIContent>>& aArrayOfContents, nsAtom& aBlockTag,
const Element& aEditingHost) {
MOZ_ASSERT(IsTopLevelEditSubActionDataAvailable());
RefPtr<Element> editingHost = ComputeEditingHost();
if (MOZ_UNLIKELY(NS_WARN_IF(!editingHost))) {
return NS_ERROR_FAILURE;
}
// Intent of this routine is to be used for converting to/from headers,
// paragraphs, pre, and address. Those blocks that pretty much just contain
// inline things...
nsCOMPtr<Element> newBlock;
nsCOMPtr<Element> curBlock;
RefPtr<Element> newBlock, curBlock;
EditorDOMPoint pointToPutCaret;
for (auto& content : aArrayOfContents) {
EditorDOMPoint atContent(content);
if (NS_WARN_IF(!atContent.IsInContentNode())) {
@ -8519,26 +8537,17 @@ nsresult HTMLEditor::CreateOrChangeBlockContainerElement(
NS_WARNING(
"EditorBase::ReplaceContainerAndCloneAttributesWithTransaction() "
"failed");
return newBlockElementOrError.unwrapErr();
return Err(newBlockElementOrError.unwrapErr());
}
// If the new block element was moved to different element or removed by
// the web app via mutation event listener, we should stop handling this
// action since we cannot handle each of a lot of edge cases.
if (NS_WARN_IF(newBlockElementOrError.GetNewNode()->GetParentNode() !=
atContent.GetContainer())) {
return NS_ERROR_EDITOR_UNEXPECTED_DOM_TREE;
return Err(NS_ERROR_EDITOR_UNEXPECTED_DOM_TREE);
}
nsresult rv = newBlockElementOrError.SuggestCaretPointTo(
*this, {SuggestCaret::OnlyIfHasSuggestion,
SuggestCaret::OnlyIfTransactionsAllowedToDoIt,
SuggestCaret::AndIgnoreTrivialError});
if (NS_FAILED(rv)) {
NS_WARNING("CreateElementResult::SuggestCaretPointTo() failed");
return rv;
}
NS_WARNING_ASSERTION(
rv != NS_SUCCESS_EDITOR_BUT_IGNORED_TRIVIAL_ERROR,
"CreateElementResult::SuggestCaretPointTo() failed, but ignored");
newBlockElementOrError.MoveCaretPointTo(
pointToPutCaret, {SuggestCaret::OnlyIfHasSuggestion});
newBlock = newBlockElementOrError.UnwrapNewNode();
continue;
}
@ -8554,12 +8563,16 @@ nsresult HTMLEditor::CreateOrChangeBlockContainerElement(
AutoTArray<OwningNonNull<nsIContent>, 24> childContents;
HTMLEditor::GetChildNodesOf(*content, childContents);
if (!childContents.IsEmpty()) {
nsresult rv =
CreateOrChangeBlockContainerElement(childContents, aBlockTag);
if (NS_FAILED(rv)) {
Result<EditorDOMPoint, nsresult> wrapChildrenInBlockElementResult =
CreateOrChangeBlockContainerElement(childContents, aBlockTag,
aEditingHost);
if (MOZ_UNLIKELY(wrapChildrenInBlockElementResult.isErr())) {
NS_WARNING(
"HTMLEditor::CreateOrChangeBlockContainerElement() failed");
return rv;
return wrapChildrenInBlockElementResult;
}
if (wrapChildrenInBlockElementResult.inspect().IsSet()) {
pointToPutCaret = wrapChildrenInBlockElementResult.unwrap();
}
continue;
}
@ -8568,7 +8581,7 @@ nsresult HTMLEditor::CreateOrChangeBlockContainerElement(
CreateElementResult createNewBlockElementResult =
InsertElementWithSplittingAncestorsWithTransaction(
aBlockTag, atContent, BRElementNextToSplitPoint::Keep,
*editingHost);
aEditingHost);
if (createNewBlockElementResult.isErr()) {
NS_WARNING(
nsPrintfCString(
@ -8576,15 +8589,10 @@ nsresult HTMLEditor::CreateOrChangeBlockContainerElement(
"InsertElementWithSplittingAncestorsWithTransaction(%s) failed",
nsAtomCString(&aBlockTag).get())
.get());
return createNewBlockElementResult.unwrapErr();
}
nsresult rv = createNewBlockElementResult.SuggestCaretPointTo(
*this, {SuggestCaret::OnlyIfHasSuggestion,
SuggestCaret::OnlyIfTransactionsAllowedToDoIt});
if (NS_FAILED(rv)) {
NS_WARNING("CreateElementResult::SuggestCaretPointTo() failed");
return rv;
return Err(createNewBlockElementResult.unwrapErr());
}
createNewBlockElementResult.MoveCaretPointTo(
pointToPutCaret, {SuggestCaret::OnlyIfHasSuggestion});
MOZ_ASSERT(createNewBlockElementResult.GetNewNode());
// Remember our new block for postprocessing
TopLevelEditSubActionDataRef().mNewBlockElement =
@ -8603,7 +8611,7 @@ nsresult HTMLEditor::CreateOrChangeBlockContainerElement(
nsresult rv = DeleteNodeWithTransaction(MOZ_KnownLive(*content));
if (NS_FAILED(rv)) {
NS_WARNING("EditorBase::DeleteNodeWithTransaction() failed");
return rv;
return Err(rv);
}
continue;
}
@ -8613,7 +8621,7 @@ nsresult HTMLEditor::CreateOrChangeBlockContainerElement(
CreateElementResult createNewBlockElementResult =
InsertElementWithSplittingAncestorsWithTransaction(
aBlockTag, atContent, BRElementNextToSplitPoint::Keep,
*editingHost);
aEditingHost);
if (createNewBlockElementResult.isErr()) {
NS_WARNING(
nsPrintfCString(
@ -8621,15 +8629,10 @@ nsresult HTMLEditor::CreateOrChangeBlockContainerElement(
"InsertElementWithSplittingAncestorsWithTransaction(%s) failed",
nsAtomCString(&aBlockTag).get())
.get());
return createNewBlockElementResult.unwrapErr();
}
nsresult rv = createNewBlockElementResult.SuggestCaretPointTo(
*this, {SuggestCaret::OnlyIfHasSuggestion,
SuggestCaret::OnlyIfTransactionsAllowedToDoIt});
if (NS_FAILED(rv)) {
NS_WARNING("CreateElementResult::SuggestCaretPointTo() failed");
return rv;
return Err(createNewBlockElementResult.unwrapErr());
}
createNewBlockElementResult.MoveCaretPointTo(
pointToPutCaret, {SuggestCaret::OnlyIfHasSuggestion});
RefPtr<Element> newBlockElement =
createNewBlockElementResult.UnwrapNewNode();
MOZ_ASSERT(newBlockElement);
@ -8638,23 +8641,14 @@ nsresult HTMLEditor::CreateOrChangeBlockContainerElement(
TopLevelEditSubActionDataRef().mNewBlockElement = newBlockElement;
// MOZ_KnownLive because 'aArrayOfContents' is guaranteed to keep it
// alive.
const MoveNodeResult moveNodeResult = MoveNodeToEndWithTransaction(
MoveNodeResult moveNodeResult = MoveNodeToEndWithTransaction(
MOZ_KnownLive(content), *newBlockElement);
if (moveNodeResult.isErr()) {
NS_WARNING("HTMLEditor::MoveNodeToEndWithTransaction() failed");
return moveNodeResult.unwrapErr();
return Err(moveNodeResult.unwrapErr());
}
rv = moveNodeResult.SuggestCaretPointTo(
*this, {SuggestCaret::OnlyIfHasSuggestion,
SuggestCaret::OnlyIfTransactionsAllowedToDoIt,
SuggestCaret::AndIgnoreTrivialError});
if (NS_FAILED(rv)) {
NS_WARNING("MoveNodeResult::SuggestCaretPointTo() failed");
return rv;
}
NS_WARNING_ASSERTION(
rv != NS_SUCCESS_EDITOR_BUT_IGNORED_TRIVIAL_ERROR,
"MoveNodeResult::SuggestCaretPointTo() failed, but ignored");
moveNodeResult.MoveCaretPointTo(pointToPutCaret,
{SuggestCaret::OnlyIfHasSuggestion});
curBlock = std::move(newBlockElement);
continue;
}
@ -8678,22 +8672,17 @@ nsresult HTMLEditor::CreateOrChangeBlockContainerElement(
CreateElementResult createNewBlockElementResult =
InsertElementWithSplittingAncestorsWithTransaction(
aBlockTag, atContent, BRElementNextToSplitPoint::Keep,
*editingHost);
aEditingHost);
if (createNewBlockElementResult.isErr()) {
NS_WARNING(nsPrintfCString("HTMLEditor::"
"InsertElementWithSplittingAncestorsWithTr"
"ansaction(%s) failed",
nsAtomCString(&aBlockTag).get())
.get());
return createNewBlockElementResult.unwrapErr();
}
nsresult rv = createNewBlockElementResult.SuggestCaretPointTo(
*this, {SuggestCaret::OnlyIfHasSuggestion,
SuggestCaret::OnlyIfTransactionsAllowedToDoIt});
if (NS_FAILED(rv)) {
NS_WARNING("CreateElementResult::SuggestCaretPointTo() failed");
return rv;
return Err(createNewBlockElementResult.unwrapErr());
}
createNewBlockElementResult.MoveCaretPointTo(
pointToPutCaret, {SuggestCaret::OnlyIfHasSuggestion});
MOZ_ASSERT(createNewBlockElementResult.GetNewNode());
curBlock = createNewBlockElementResult.UnwrapNewNode();
@ -8707,7 +8696,7 @@ nsresult HTMLEditor::CreateOrChangeBlockContainerElement(
if (NS_WARN_IF(!atContent.IsSet())) {
// This is possible due to mutation events, let's not assert
return NS_ERROR_UNEXPECTED;
return Err(NS_ERROR_UNEXPECTED);
}
// XXX If content is a br, replace it with a return if going to <pre>
@ -8719,26 +8708,17 @@ nsresult HTMLEditor::CreateOrChangeBlockContainerElement(
// alive. We could try to make that a rvalue ref and create a const array
// on the stack here, but callers are passing in auto arrays, and we don't
// want to introduce copies..
const MoveNodeResult moveNodeResult =
MoveNodeResult moveNodeResult =
MoveNodeToEndWithTransaction(MOZ_KnownLive(content), *curBlock);
if (moveNodeResult.isErr()) {
NS_WARNING("HTMLEditor::MoveNodeToEndWithTransaction() failed");
return moveNodeResult.unwrapErr();
return Err(moveNodeResult.unwrapErr());
}
nsresult rv = moveNodeResult.SuggestCaretPointTo(
*this, {SuggestCaret::OnlyIfHasSuggestion,
SuggestCaret::OnlyIfTransactionsAllowedToDoIt,
SuggestCaret::AndIgnoreTrivialError});
if (NS_FAILED(rv)) {
NS_WARNING("MoveNodeResult::SuggestCaretPointTo() failed");
return rv;
}
NS_WARNING_ASSERTION(
rv != NS_SUCCESS_EDITOR_BUT_IGNORED_TRIVIAL_ERROR,
"MoveNodeResult::SuggestCaretPointTo() failed, but ignored");
moveNodeResult.MoveCaretPointTo(pointToPutCaret,
{SuggestCaret::OnlyIfHasSuggestion});
}
}
return NS_OK;
return pointToPutCaret;
}
SplitNodeResult HTMLEditor::MaybeSplitAncestorsForInsertWithTransaction(

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

@ -1541,7 +1541,7 @@ class HTMLEditor final : public EditorBase,
/**
* SplitRangeOffFromBlock() splits aBlockElement at two points, before
* aStartOfMiddleElement and after aEndOfMiddleElement. If they are very
* start or very end of aBlcok, this won't create empty block.
* start or very end of aBlockElement, this won't create empty block.
*
* @param aBlockElement A block element which will be split.
* @param aStartOfMiddleElement Start node of middle block element.
@ -1553,25 +1553,28 @@ class HTMLEditor final : public EditorBase,
nsIContent& aEndOfMiddleElement);
/**
* SplitRangeOffFromBlockAndRemoveMiddleContainer() splits the nodes
* between aStartOfRange and aEndOfRange, then, removes the middle element
* and moves its content to where the middle element was.
* RemoveBlockContainerElementWithTransactionBetween() splits the nodes
* at aStartOfRange and aEndOfRange, then, removes the middle element which
* was split off from aBlockContainerElement and moves the ex-children to
* where the middle element was. I.e., all nodes between aStartOfRange and
* aEndOfRange (including themselves) will be unwrapped from
* aBlockContainerElement.
*
* @param aBlockElement The node which will be split.
* @param aBlockContainerElement The node which will be split.
* @param aStartOfRange The first node which will be unwrapped
* from aBlockElement.
* from aBlockContainerElement.
* @param aEndOfRange The last node which will be unwrapped from
* aBlockElement.
* aBlockContainerElement.
* @return The left content is new created left
* element of aBlockElement.
* element of aBlockContainerElement.
* The right content is split element,
* i.e., must be aBlockElement.
* i.e., must be aBlockContainerElement.
* The middle content is nullptr since
* removing it is the job of this method.
*/
[[nodiscard]] MOZ_CAN_RUN_SCRIPT SplitRangeOffFromNodeResult
SplitRangeOffFromBlockAndRemoveMiddleContainer(Element& aBlockElement,
nsIContent& aStartOfRange,
RemoveBlockContainerElementWithTransactionBetween(
Element& aBlockContainerElement, nsIContent& aStartOfRange,
nsIContent& aEndOfRange);
/**
@ -1588,15 +1591,19 @@ class HTMLEditor final : public EditorBase,
nsTArray<OwningNonNull<nsIContent>>& aArrayOfContents);
/**
* RemoveBlockContainerElements() removes all format blocks, table related
* element, etc in aArrayOfContents from the DOM tree.
* If aArrayOfContents has a format node, it will be removed and its contents
* RemoveBlockContainerElementsWithTransaction() removes all format blocks,
* table related element, etc in aArrayOfContents from the DOM tree. If
* aArrayOfContents has a format node, it will be removed and its contents
* will be moved to where it was.
* If aArrayOfContents has a table related element, <li>, <blockquote> or
* <div>, it will be removed and its contents will be moved to where it was.
*
* @return A suggest point to put caret if succeeded, but it may be
* unset if there is no suggestion.
*/
[[nodiscard]] MOZ_CAN_RUN_SCRIPT nsresult RemoveBlockContainerElements(
nsTArray<OwningNonNull<nsIContent>>& aArrayOfContents);
[[nodiscard]] MOZ_CAN_RUN_SCRIPT Result<EditorDOMPoint, nsresult>
RemoveBlockContainerElementsWithTransaction(
const nsTArray<OwningNonNull<nsIContent>>& aArrayOfContents);
/**
* CreateOrChangeBlockContainerElement() formats all nodes in aArrayOfContents
@ -1613,9 +1620,13 @@ class HTMLEditor final : public EditorBase,
*
* @param aArrayOfContents Must be descendants of a node.
* @param aBlockTag The element name of new block elements.
* @param aEditingHost The editing host.
* @return May suggest a point to put caret if succeeded.
*/
[[nodiscard]] MOZ_CAN_RUN_SCRIPT nsresult CreateOrChangeBlockContainerElement(
nsTArray<OwningNonNull<nsIContent>>& aArrayOfContents, nsAtom& aBlockTag);
[[nodiscard]] MOZ_CAN_RUN_SCRIPT Result<EditorDOMPoint, nsresult>
CreateOrChangeBlockContainerElement(
nsTArray<OwningNonNull<nsIContent>>& aArrayOfContents, nsAtom& aBlockTag,
const Element& aEditingHost);
/**
* FormatBlockContainerWithTransaction() is implementation of "formatBlock"
@ -1626,10 +1637,12 @@ class HTMLEditor final : public EditorBase,
*
* @param aBlockType New block tag name.
* If nsGkAtoms::normal or nsGkAtoms::_empty,
* RemoveBlockContainerElements() will be called.
* RemoveBlockContainerElementsWithTransaction()
* will be called.
* If nsGkAtoms::blockquote,
* MoveNodesIntoNewBlockquoteElement() will be
* called. Otherwise,
* called.
* Otherwise,
* CreateOrChangeBlockContainerElement() will be
* called.
*/
@ -4660,6 +4673,7 @@ class HTMLEditor final : public EditorBase,
friend class SlurpBlobEventListener; // BlobReader
friend class SplitNodeResult; // CollapseSelectionTo
friend class SplitNodeTransaction; // DoJoinNodes, DoSplitNode
friend class SplitRangeOffFromNodeResult; // CollapseSelectionTo
friend class TransactionManager; // DidDoTransaction, DidRedoTransaction,
// DidUndoTransaction
friend class

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

@ -320,7 +320,9 @@ private:
V operator* (const SkNx<N,T>& x, T y) { return x * SkNx<N,T>(y); }
V operator/ (const SkNx<N,T>& x, T y) { return x / SkNx<N,T>(y); }
V operator& (const SkNx<N,T>& x, T y) { return x & SkNx<N,T>(y); }
V operator&&(const SkNx<N,T>& x, const SkNx<N,T>& y) { return x & y; }
V operator| (const SkNx<N,T>& x, T y) { return x | SkNx<N,T>(y); }
V operator||(const SkNx<N,T>& x, const SkNx<N,T>& y) { return x | y; }
V operator^ (const SkNx<N,T>& x, T y) { return x ^ SkNx<N,T>(y); }
V operator==(const SkNx<N,T>& x, T y) { return x == SkNx<N,T>(y); }
V operator!=(const SkNx<N,T>& x, T y) { return x != SkNx<N,T>(y); }

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

@ -1595,8 +1595,8 @@ SI void clip_color(F* r, F* g, F* b, F a) {
l = lum(*r, *g, *b);
auto clip = [=](F c) {
c = if_then_else(mn >= 0, c, l + (c - l) * ( l) / (l - mn) );
c = if_then_else(mx > a, l + (c - l) * (a - l) / (mx - l), c);
c = if_then_else(mn < 0 && l != mn, l + (c - l) * ( l) / (l - mn), c);
c = if_then_else(mx > a && l != mx, l + (c - l) * (a - l) / (mx - l), c);
c = max(c, 0); // Sometimes without this we may dip just a little negative.
return c;
};

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

@ -82,7 +82,8 @@ nsresult Downscaler::BeginFrame(const nsIntSize& aOriginalSize,
aHasAlpha);
mOriginalSize = aOriginalSize;
mScale = gfxSize(double(mOriginalSize.width) / mTargetSize.width,
mScale = gfx::MatrixScalesDouble(
double(mOriginalSize.width) / mTargetSize.width,
double(mOriginalSize.height) / mTargetSize.height);
mOutputBuffer = aOutputBuffer;
mHasAlpha = aHasAlpha;
@ -244,7 +245,7 @@ DownscalerInvalidRect Downscaler::TakeInvalidRect() {
// Compute the original size invalid rect.
invalidRect.mOriginalSizeRect = invalidRect.mTargetSizeRect;
invalidRect.mOriginalSizeRect.ScaleRoundOut(mScale.width, mScale.height);
invalidRect.mOriginalSizeRect.ScaleRoundOut(mScale.xScale, mScale.yScale);
return invalidRect;
}

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

@ -17,6 +17,7 @@
#include "gfxPoint.h"
#include "nsRect.h"
#include "mozilla/gfx/ConvolutionFilter.h"
#include "mozilla/gfx/Matrix.h"
namespace mozilla {
namespace image {
@ -55,7 +56,7 @@ class Downscaler {
const nsIntSize FrameSize() const {
return nsIntSize(mFrameRect.Width(), mFrameRect.Height());
}
const gfxSize& Scale() const { return mScale; }
const gfx::MatrixScalesDouble& Scale() const { return mScale; }
/**
* Begins a new frame and reinitializes the Downscaler.
@ -118,7 +119,7 @@ class Downscaler {
nsIntSize mOriginalSize;
nsIntSize mTargetSize;
nsIntRect mFrameRect;
gfxSize mScale;
gfx::MatrixScalesDouble mScale;
uint8_t* mOutputBuffer;

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

@ -155,6 +155,8 @@ class SharedMemory {
// pid to the given string and return true. If not, return false.
// (This is public so that the Linux sandboxing code can use it.)
static bool AppendPosixShmPrefix(std::string* str, pid_t pid);
// Similar, but simply returns whether POSIX shm is in use.
static bool UsingPosixShm();
#endif
private:

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

@ -81,6 +81,13 @@ bool SharedMemory::IsHandleValid(const SharedMemoryHandle& handle) {
// static
SharedMemoryHandle SharedMemory::NULLHandle() { return nullptr; }
// static
bool SharedMemory::UsingPosixShm() {
// Undocumented feature of AppendPosixShmPrefix to reduce code
// duplication: if the string pointer is null, it's ignored.
return AppendPosixShmPrefix(nullptr, 0);
}
#ifdef ANDROID
// Android has its own shared memory API, ashmem. It doesn't support
@ -88,6 +95,7 @@ SharedMemoryHandle SharedMemory::NULLHandle() { return nullptr; }
// because its SELinux policy prevents the procfs operations we'd use
// (see bug 1670277 for more details).
// static
bool SharedMemory::AppendPosixShmPrefix(std::string* str, pid_t pid) {
return false;
}
@ -262,6 +270,10 @@ bool SharedMemory::AppendPosixShmPrefix(std::string* str, pid_t pid) {
if (HaveMemfd()) {
return false;
}
// See also UsingPosixShm().
if (!str) {
return true;
}
*str += '/';
# ifdef MOZ_WIDGET_GTK
// The Snap package environment doesn't provide a private /dev/shm

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

@ -21,10 +21,7 @@ let global = Cu.getGlobalForObject({});
// and `MessagePort`. This table maps those extra symbols to the main
// import name.
const EXTRA_GLOBAL_NAME_TO_IMPORT_NAME = {
Headers: "fetch",
MessagePort: "MessageChannel",
Request: "fetch",
Response: "fetch",
};
/**

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

@ -107,37 +107,75 @@ static LazyLogModule gJSCLLog("JSComponentLoader");
#define ERROR_UNINITIALIZED_SYMBOL \
"%s - Symbol '%s' accessed before initialization. Cyclic import?"
static constexpr char JSMSuffix[] = ".jsm";
static constexpr size_t JSMSuffixLength = mozilla::ArrayLength(JSMSuffix) - 1;
static constexpr char MJSSuffix[] = ".sys.mjs";
static constexpr size_t MJSSuffixLength = mozilla::ArrayLength(MJSSuffix) - 1;
static constexpr char JSM_Suffix[] = ".jsm";
static constexpr size_t JSM_SuffixLength = mozilla::ArrayLength(JSM_Suffix) - 1;
static constexpr char JSM_JS_Suffix[] = ".jsm.js";
static constexpr size_t JSM_JS_SuffixLength =
mozilla::ArrayLength(JSM_JS_Suffix) - 1;
static constexpr char JS_Suffix[] = ".js";
static constexpr size_t JS_SuffixLength = mozilla::ArrayLength(JS_Suffix) - 1;
static constexpr char MJS_Suffix[] = ".sys.mjs";
static constexpr size_t MJS_SuffixLength = mozilla::ArrayLength(MJS_Suffix) - 1;
static bool IsJSM(const nsACString& aLocation) {
if (aLocation.Length() < JSMSuffixLength) {
if (aLocation.Length() < JSM_SuffixLength) {
return false;
}
const auto ext = Substring(aLocation, aLocation.Length() - JSMSuffixLength);
return ext == JSMSuffix;
const auto ext = Substring(aLocation, aLocation.Length() - JSM_SuffixLength);
return ext == JSM_Suffix;
}
static bool IsJS(const nsACString& aLocation) {
if (aLocation.Length() < JS_SuffixLength) {
return false;
}
const auto ext = Substring(aLocation, aLocation.Length() - JS_SuffixLength);
return ext == JS_Suffix;
}
static bool IsJSM_JS(const nsACString& aLocation) {
if (aLocation.Length() < JSM_JS_SuffixLength) {
return false;
}
const auto ext =
Substring(aLocation, aLocation.Length() - JSM_JS_SuffixLength);
return ext == JSM_JS_Suffix;
}
static bool IsMJS(const nsACString& aLocation) {
if (aLocation.Length() < MJSSuffixLength) {
if (aLocation.Length() < MJS_SuffixLength) {
return false;
}
const auto ext = Substring(aLocation, aLocation.Length() - MJSSuffixLength);
return ext == MJSSuffix;
const auto ext = Substring(aLocation, aLocation.Length() - MJS_SuffixLength);
return ext == MJS_Suffix;
}
static void ToJSM(const nsACString& aLocation, nsAutoCString& aOut) {
static void MJSToJSM(const nsACString& aLocation, nsAutoCString& aOut) {
MOZ_ASSERT(IsMJS(aLocation));
aOut = Substring(aLocation, 0, aLocation.Length() - MJSSuffixLength);
aOut += JSMSuffix;
aOut = Substring(aLocation, 0, aLocation.Length() - MJS_SuffixLength);
aOut += JSM_Suffix;
}
static void ToMJS(const nsACString& aLocation, nsAutoCString& aOut) {
MOZ_ASSERT(IsJSM(aLocation));
aOut = Substring(aLocation, 0, aLocation.Length() - JSMSuffixLength);
aOut += MJSSuffix;
static bool TryToMJS(const nsACString& aLocation, nsAutoCString& aOut) {
if (IsJSM(aLocation)) {
aOut = Substring(aLocation, 0, aLocation.Length() - JSM_SuffixLength);
aOut += MJS_Suffix;
return true;
}
if (IsJSM_JS(aLocation)) {
aOut = Substring(aLocation, 0, aLocation.Length() - JSM_JS_SuffixLength);
aOut += MJS_Suffix;
return true;
}
if (IsJS(aLocation)) {
aOut = Substring(aLocation, 0, aLocation.Length() - JS_SuffixLength);
aOut += MJS_Suffix;
return true;
}
return false;
}
static bool Dump(JSContext* cx, unsigned argc, Value* vp) {
@ -1128,9 +1166,12 @@ nsresult mozJSComponentLoader::IsModuleLoaded(const nsACString& aLocation,
return NS_OK;
}
if (IsJSM(aLocation) && mModuleLoader) {
if (mModuleLoader) {
nsAutoCString mjsLocation;
ToMJS(aLocation, mjsLocation);
if (!TryToMJS(aLocation, mjsLocation)) {
*retval = false;
return NS_OK;
}
ComponentLoaderInfo mjsInfo(mjsLocation);
@ -1171,7 +1212,10 @@ nsresult mozJSComponentLoader::GetLoadedJSAndESModules(
for (const auto& location : modules) {
if (IsMJS(location)) {
nsAutoCString jsmLocation;
ToJSM(location, jsmLocation);
// NOTE: Unconditionally convert to *.jsm. This doesn't cover *.js case
// but given `Cu.loadedModules` is rarely used for system modules,
// this won't cause much compat issue.
MJSToJSM(location, jsmLocation);
aLoadedModules.AppendElement(jsmLocation);
}
}
@ -1517,13 +1561,11 @@ nsresult mozJSComponentLoader::TryFallbackToImportModule(
JSContext* aCx, const nsACString& aLocation,
JS::MutableHandleObject aModuleGlobal,
JS::MutableHandleObject aModuleExports, bool aIgnoreExports) {
if (!IsJSM(aLocation)) {
nsAutoCString mjsLocation;
if (!TryToMJS(aLocation, mjsLocation)) {
return NS_ERROR_FILE_NOT_FOUND;
}
nsAutoCString mjsLocation;
ToMJS(aLocation, mjsLocation);
JS::RootedObject moduleNamespace(aCx);
nsresult rv = ImportModule(aCx, mjsLocation, &moduleNamespace);
NS_ENSURE_SUCCESS(rv, rv);

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

@ -270,7 +270,7 @@ static bool SandboxImport(JSContext* cx, unsigned argc, Value* vp) {
return true;
}
static bool SandboxCreateCrypto(JSContext* cx, JS::HandleObject obj) {
bool xpc::SandboxCreateCrypto(JSContext* cx, JS::Handle<JSObject*> obj) {
MOZ_ASSERT(JS_IsGlobalObject(obj));
nsIGlobalObject* native = xpc::NativeGlobal(obj);
@ -359,7 +359,7 @@ static bool SandboxFetchPromise(JSContext* cx, unsigned argc, Value* vp) {
return ConvertExceptionToPromise(cx, args.rval());
}
static bool SandboxCreateFetch(JSContext* cx, HandleObject obj) {
bool xpc::SandboxCreateFetch(JSContext* cx, JS::Handle<JSObject*> obj) {
MOZ_ASSERT(JS_IsGlobalObject(obj));
return JS_DefineFunction(cx, obj, "fetch", SandboxFetchPromise, 2, 0) &&

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

@ -128,6 +128,9 @@ const char* const XPCJSRuntime::mStrings[] = {
"interfaceId", // IDX_INTERFACE_ID
"initializer", // IDX_INITIALIZER
"print", // IDX_PRINT
"fetch", // IDX_FETCH
"crypto", // IDX_CRYPTO
"indexedDB", // IDX_INDEXEDDB
};
/***************************************************************************/

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

@ -11,6 +11,7 @@
#include "BackstagePass.h"
#include "mozilla/dom/BindingUtils.h"
#include "mozilla/dom/WebIDLGlobalNameHash.h"
#include "mozilla/dom/IndexedDatabaseManager.h"
using namespace mozilla::dom;
@ -66,7 +67,36 @@ BackstagePass::Resolve(nsIXPConnectWrappedNative* wrapper, JSContext* cx,
JS::RootedId id(cx, idArg);
*_retval =
WebIDLGlobalNameHash::ResolveForSystemGlobal(cx, obj, id, resolvedp);
return *_retval ? NS_OK : NS_ERROR_FAILURE;
if (!*_retval) {
return NS_ERROR_FAILURE;
}
if (*resolvedp) {
return NS_OK;
}
XPCJSContext* xpccx = XPCJSContext::Get();
if (id == xpccx->GetStringID(XPCJSContext::IDX_FETCH)) {
*_retval = xpc::SandboxCreateFetch(cx, obj);
if (!*_retval) {
return NS_ERROR_FAILURE;
}
*resolvedp = true;
} else if (id == xpccx->GetStringID(XPCJSContext::IDX_CRYPTO)) {
*_retval = xpc::SandboxCreateCrypto(cx, obj);
if (!*_retval) {
return NS_ERROR_FAILURE;
}
*resolvedp = true;
} else if (id == xpccx->GetStringID(XPCJSContext::IDX_INDEXEDDB)) {
*_retval = IndexedDatabaseManager::DefineIndexedDB(cx, obj);
if (!*_retval) {
return NS_ERROR_FAILURE;
}
*resolvedp = true;
}
return NS_OK;
}
NS_IMETHODIMP

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

@ -404,6 +404,9 @@ class XPCJSContext final : public mozilla::CycleCollectedJSContext,
IDX_INTERFACE_ID,
IDX_INITIALIZER,
IDX_PRINT,
IDX_FETCH,
IDX_CRYPTO,
IDX_INDEXEDDB,
IDX_TOTAL_COUNT // just a count of the above
};
@ -2850,6 +2853,9 @@ void InitializeValue(const nsXPTType& aType, void* aValue);
void DestructValue(const nsXPTType& aType, void* aValue,
uint32_t aArrayLen = 0);
bool SandboxCreateCrypto(JSContext* cx, JS::Handle<JSObject*> obj);
bool SandboxCreateFetch(JSContext* cx, JS::Handle<JSObject*> obj);
} // namespace xpc
namespace mozilla {

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

@ -27,6 +27,30 @@ add_task(function test_Cu_import_shim_first() {
Assert.equal(exports2.obj.value, 10);
Assert.ok(exports2.obj === global2.obj);
Assert.ok(exports2.obj === global.obj);
// Also test with *.js extension.
const exports3 = {};
const global3 = Components.utils.import(
"resource://test/esmified-1.js", exports3
);
Assert.equal(global3.loadCount, 1);
Assert.equal(global3.obj.value, 10);
Assert.equal(exports3.loadCount, 1);
Assert.equal(exports3.obj.value, 10);
Assert.ok(exports3.obj === global3.obj);
Assert.ok(exports3.obj === global.obj);
// Also test with *.jsm.js extension.
const exports4 = {};
const global4 = Components.utils.import(
"resource://test/esmified-1.js", exports4
);
Assert.equal(global4.loadCount, 1);
Assert.equal(global4.obj.value, 10);
Assert.equal(exports4.loadCount, 1);
Assert.equal(exports4.obj.value, 10);
Assert.ok(exports4.obj === global4.obj);
Assert.ok(exports4.obj === global.obj);
});
add_task(function test_Cu_import_no_shim_first() {
@ -303,6 +327,8 @@ add_task(function test_Cu_import_not_exported_shim() {
add_task(function test_Cu_isModuleLoaded_shim() {
Assert.equal(Cu.isModuleLoaded("resource://test/esmified-5.jsm"), false);
Assert.equal(Cu.isModuleLoaded("resource://test/esmified-5.js"), false);
Assert.equal(Cu.isModuleLoaded("resource://test/esmified-5.jsm.js"), false);
Assert.equal(Cu.loadedModules.includes("resource://test/esmified-5.jsm"), false);
Assert.equal(Cu.isModuleLoaded("resource://test/esmified-5.sys.mjs"), false);
Assert.equal(Cu.loadedModules.includes("resource://test/esmified-5.sys.mjs"), false);
@ -310,6 +336,8 @@ add_task(function test_Cu_isModuleLoaded_shim() {
Cu.import("resource://test/esmified-5.jsm", {});
Assert.equal(Cu.isModuleLoaded("resource://test/esmified-5.jsm"), true);
Assert.equal(Cu.isModuleLoaded("resource://test/esmified-5.js"), true);
Assert.equal(Cu.isModuleLoaded("resource://test/esmified-5.jsm.js"), true);
Assert.equal(Cu.loadedModules.includes("resource://test/esmified-5.jsm"), true);
// This is false because Cu.isModuleLoaded does not support ESM directly
@ -320,7 +348,11 @@ add_task(function test_Cu_isModuleLoaded_shim() {
add_task(function test_Cu_isModuleLoaded_no_shim() {
Assert.equal(Cu.isModuleLoaded("resource://test/esmified-6.jsm"), false);
Assert.equal(Cu.isModuleLoaded("resource://test/esmified-6.js"), false);
Assert.equal(Cu.isModuleLoaded("resource://test/esmified-6.jsm.js"), false);
Assert.equal(Cu.loadedModules.includes("resource://test/esmified-6.jsm"), false);
Assert.equal(Cu.loadedModules.includes("resource://test/esmified-6.js"), false);
Assert.equal(Cu.loadedModules.includes("resource://test/esmified-6.jsm.js"), false);
Assert.equal(Cu.isModuleLoaded("resource://test/esmified-6.sys.mjs"), false);
Assert.equal(Cu.loadedModules.includes("resource://test/esmified-6.sys.mjs"), false);
@ -330,8 +362,14 @@ add_task(function test_Cu_isModuleLoaded_no_shim() {
// query that accesses the ESM-ified module returns the existence of
// ESM.
Assert.equal(Cu.isModuleLoaded("resource://test/esmified-6.jsm"), true);
Assert.equal(Cu.isModuleLoaded("resource://test/esmified-6.js"), true);
Assert.equal(Cu.isModuleLoaded("resource://test/esmified-6.jsm.js"), true);
Assert.equal(Cu.loadedModules.includes("resource://test/esmified-6.jsm"), true);
// This is false because shim always use *.jsm.
Assert.equal(Cu.loadedModules.includes("resource://test/esmified-6.js"), false);
Assert.equal(Cu.loadedModules.includes("resource://test/esmified-6.jsm.js"), false);
// This is false because Cu.isModuleLoaded does not support ESM directly
// (bug 1768819)
Assert.equal(Cu.isModuleLoaded("resource://test/esmified-6.sys.mjs"), false);

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

@ -18,7 +18,7 @@ load 1469472.html
load 1477831-1.html
load 1504033.html
load 1514544-1.html
asserts(0-1) load 1547420-1.html
asserts(0-1) asserts-if(Android,0-2) load 1547420-1.html
load 1549909.html
asserts(6) load 1551389-1.html # bug 847368
asserts(0-2) load 1555819-1.html

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

@ -0,0 +1,19 @@
<!DOCTYPE html>
<meta charset="utf-8">
<div style="width: 100px; height: 100px;">
<canvas id="c" width="100" height="100"></canvas>
</div>
<script>
var ctx = document.getElementById('c').getContext('2d');
var grd = ctx.createLinearGradient(0, 0, 100, 0);
grd.addColorStop(0, 'black');
grd.addColorStop(1, 'white');
ctx.fillStyle = grd;
ctx.fillRect(0, 0, 100, 100);
ctx.globalAlpha = 0.8;
ctx.fillStyle = 'white';
ctx.fillRect(0, 0, 100, 100);
</script>

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

@ -0,0 +1,20 @@
<!DOCTYPE html>
<meta charset="utf-8">
<div style="width: 100px; height: 100px;">
<canvas id="c" width="100" height="100"></canvas>
</div>
<script>
var ctx = document.getElementById('c').getContext('2d');
var grd = ctx.createLinearGradient(0, 0, 100, 0);
grd.addColorStop(0, 'black');
grd.addColorStop(1, 'white');
ctx.fillStyle = grd;
ctx.fillRect(0, 0, 100, 100);
ctx.globalCompositeOperation = 'luminosity';
ctx.globalAlpha = 0.8;
ctx.fillStyle = 'white';
ctx.fillRect(0, 0, 100, 100);
</script>

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

@ -2116,6 +2116,7 @@ pref(image.downscale-during-decode.enabled,true) == 1744468-1.html 1744468-1-ref
== 1747272-1.html 1747272-1-ref.html
== 1750146-1.html 1750146-1-ref.html
== 1735265-1.html 1735265-1-ref.html
fuzzy(0-1,0-1000) == 1769082-1.html 1769082-1-ref.html
== 1773484.html 1773484-ref.html
# The following tests are skipped on Android since Android doesn't deal very

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

@ -14,8 +14,6 @@ var { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
const lazy = {};
XPCOMUtils.defineLazyGlobalGetters(lazy, ["URL"]);
XPCOMUtils.defineLazyModuleGetters(lazy, {
ManifestObtainer: "resource://gre/modules/ManifestObtainer.jsm",
});
@ -83,7 +81,7 @@ class ContentDelegateChild extends GeckoViewActorChild {
let elementSrc = (isImage || isMedia) && (node.currentSrc || node.src);
if (elementSrc) {
const isBlob = elementSrc.startsWith("blob:");
if (isBlob && !lazy.URL.isValidURL(elementSrc)) {
if (isBlob && !URL.isValidURL(elementSrc)) {
elementSrc = null;
}
}

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

@ -13,10 +13,6 @@
* let Log = ChromeUtils.import("resource://gre/modules/AndroidLog.jsm")
* .AndroidLog;
*
* // Or require it in a chrome worker:
* importScripts("resource://gre/modules/workers/require.js");
* let Log = require("resource://gre/modules/AndroidLog.jsm");
*
* // Use Log.i, Log.v, Log.d, Log.w, and Log.e to log verbose, debug, info,
* // warning, and error messages, respectively.
* Log.v("MyModule", "This is a verbose message.");
@ -40,14 +36,8 @@
* truncates tags longer than MAX_TAG_LENGTH characters (not including "Gecko").
*/
if (typeof Components != "undefined") {
// Specify exported symbols for JSM module loader.
//
// (bug 1773390)
// eslint-disable-next-line mozilla/reject-global-this
this.EXPORTED_SYMBOLS = ["AndroidLog"];
var { ctypes } = ChromeUtils.import("resource://gre/modules/ctypes.jsm");
}
const EXPORTED_SYMBOLS = ["AndroidLog"];
const { ctypes } = ChromeUtils.import("resource://gre/modules/ctypes.jsm");
// From <https://android.googlesource.com/platform/system/core/+/master/include/android/log.h>.
const ANDROID_LOG_VERBOSE = 2;

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

@ -7,13 +7,13 @@ const { XPCOMUtils } = ChromeUtils.import(
"resource://gre/modules/XPCOMUtils.jsm"
);
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
const { Log } = ChromeUtils.import("resource://gre/modules/Log.jsm");
const lazy = {};
XPCOMUtils.defineLazyModuleGetters(lazy, {
AndroidLog: "resource://gre/modules/AndroidLog.jsm",
EventDispatcher: "resource://gre/modules/Messaging.jsm",
Log: "resource://gre/modules/Log.jsm",
});
var EXPORTED_SYMBOLS = ["GeckoViewUtils"];
@ -22,7 +22,7 @@ var EXPORTED_SYMBOLS = ["GeckoViewUtils"];
* A formatter that does not prepend time/name/level information to messages,
* because those fields are logged separately when using the Android logger.
*/
class AndroidFormatter extends lazy.Log.BasicFormatter {
class AndroidFormatter extends Log.BasicFormatter {
format(message) {
return this.formatText(message);
}
@ -32,20 +32,20 @@ class AndroidFormatter extends lazy.Log.BasicFormatter {
* AndroidAppender
* Logs to Android logcat using AndroidLog.jsm
*/
class AndroidAppender extends lazy.Log.Appender {
class AndroidAppender extends Log.Appender {
constructor(aFormatter) {
super(aFormatter || new AndroidFormatter());
this._name = "AndroidAppender";
// Map log level to AndroidLog.foo method.
this._mapping = {
[lazy.Log.Level.Fatal]: "e",
[lazy.Log.Level.Error]: "e",
[lazy.Log.Level.Warn]: "w",
[lazy.Log.Level.Info]: "i",
[lazy.Log.Level.Config]: "d",
[lazy.Log.Level.Debug]: "d",
[lazy.Log.Level.Trace]: "v",
[Log.Level.Fatal]: "e",
[Log.Level.Error]: "e",
[Log.Level.Warn]: "w",
[Log.Level.Info]: "i",
[Log.Level.Config]: "d",
[Log.Level.Debug]: "d",
[Log.Level.Trace]: "v",
};
}
@ -358,7 +358,7 @@ var GeckoViewUtils = {
this._log(log.logger, level, strings, exprs);
XPCOMUtils.defineLazyGetter(log, "logger", _ => {
const logger = lazy.Log.repository.getLogger(tag);
const logger = Log.repository.getLogger(tag);
logger.parent = this.rootLogger;
return logger;
});
@ -372,7 +372,7 @@ var GeckoViewUtils = {
get rootLogger() {
if (!this._rootLogger) {
this._rootLogger = lazy.Log.repository.getLogger("GeckoView");
this._rootLogger = Log.repository.getLogger("GeckoView");
this._rootLogger.addAppender(new AndroidAppender());
this._rootLogger.manageLevelFromPref("geckoview.logging");
}
@ -389,7 +389,7 @@ var GeckoViewUtils = {
);
}
if (aLogger.level > lazy.Log.Level.Numbers[aLevel]) {
if (aLogger.level > Log.Level.Numbers[aLevel]) {
// Log disabled.
return;
}

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

@ -11,20 +11,23 @@ const { XPCOMUtils } = ChromeUtils.import(
"resource://gre/modules/XPCOMUtils.jsm"
);
const { WebSocketConnection } = ChromeUtils.import(
"chrome://remote/content/shared/WebSocketConnection.jsm"
);
const lazy = {};
XPCOMUtils.defineLazyModuleGetters(lazy, {
Log: "chrome://remote/content/shared/Log.jsm",
truncate: "chrome://remote/content/shared/Format.jsm",
UnknownMethodError: "chrome://remote/content/cdp/Error.jsm",
WebSocketConnection: "chrome://remote/content/shared/WebSocketConnection.jsm",
});
XPCOMUtils.defineLazyGetter(lazy, "logger", () =>
lazy.Log.get(lazy.Log.TYPES.CDP)
);
class CDPConnection extends lazy.WebSocketConnection {
class CDPConnection extends WebSocketConnection {
/**
* @param {WebSocket} webSocket
* The WebSocket server connection to wrap.

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

@ -6,18 +6,11 @@
var EXPORTED_SYMBOLS = ["DOM"];
var { XPCOMUtils } = ChromeUtils.import(
"resource://gre/modules/XPCOMUtils.jsm"
const { ContentProcessDomain } = ChromeUtils.import(
"chrome://remote/content/cdp/domains/ContentProcessDomain.jsm"
);
const lazy = {};
XPCOMUtils.defineLazyModuleGetters(lazy, {
ContentProcessDomain:
"chrome://remote/content/cdp/domains/ContentProcessDomain.jsm",
});
class DOM extends lazy.ContentProcessDomain {
class DOM extends ContentProcessDomain {
constructor(session) {
super(session);
this.enabled = false;

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

@ -10,15 +10,17 @@ var { XPCOMUtils } = ChromeUtils.import(
"resource://gre/modules/XPCOMUtils.jsm"
);
const { ContentProcessDomain } = ChromeUtils.import(
"chrome://remote/content/cdp/domains/ContentProcessDomain.jsm"
);
const lazy = {};
XPCOMUtils.defineLazyModuleGetters(lazy, {
AnimationFramePromise: "chrome://remote/content/shared/Sync.jsm",
ContentProcessDomain:
"chrome://remote/content/cdp/domains/ContentProcessDomain.jsm",
});
class Emulation extends lazy.ContentProcessDomain {
class Emulation extends ContentProcessDomain {
// commands
/**

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

@ -6,18 +6,11 @@
var EXPORTED_SYMBOLS = ["Input"];
var { XPCOMUtils } = ChromeUtils.import(
"resource://gre/modules/XPCOMUtils.jsm"
const { ContentProcessDomain } = ChromeUtils.import(
"chrome://remote/content/cdp/domains/ContentProcessDomain.jsm"
);
const lazy = {};
XPCOMUtils.defineLazyModuleGetters(lazy, {
ContentProcessDomain:
"chrome://remote/content/cdp/domains/ContentProcessDomain.jsm",
});
class Input extends lazy.ContentProcessDomain {
class Input extends ContentProcessDomain {
constructor(session) {
super(session);

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

@ -7,17 +7,11 @@
var EXPORTED_SYMBOLS = ["Log"];
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
const { XPCOMUtils } = ChromeUtils.import(
"resource://gre/modules/XPCOMUtils.jsm"
const { ContentProcessDomain } = ChromeUtils.import(
"chrome://remote/content/cdp/domains/ContentProcessDomain.jsm"
);
const lazy = {};
XPCOMUtils.defineLazyModuleGetters(lazy, {
ContentProcessDomain:
"chrome://remote/content/cdp/domains/ContentProcessDomain.jsm",
});
const CONSOLE_MESSAGE_LEVEL_MAP = {
[Ci.nsIConsoleMessage.debug]: "verbose",
[Ci.nsIConsoleMessage.info]: "info",
@ -25,7 +19,7 @@ const CONSOLE_MESSAGE_LEVEL_MAP = {
[Ci.nsIConsoleMessage.error]: "error",
};
class Log extends lazy.ContentProcessDomain {
class Log extends ContentProcessDomain {
constructor(session) {
super(session);
this.enabled = false;

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

@ -6,18 +6,11 @@
var EXPORTED_SYMBOLS = ["Network"];
var { XPCOMUtils } = ChromeUtils.import(
"resource://gre/modules/XPCOMUtils.jsm"
const { ContentProcessDomain } = ChromeUtils.import(
"chrome://remote/content/cdp/domains/ContentProcessDomain.jsm"
);
const lazy = {};
XPCOMUtils.defineLazyModuleGetters(lazy, {
ContentProcessDomain:
"chrome://remote/content/cdp/domains/ContentProcessDomain.jsm",
});
class Network extends lazy.ContentProcessDomain {
class Network extends ContentProcessDomain {
// commands
/**

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

@ -6,18 +6,11 @@
var EXPORTED_SYMBOLS = ["Performance"];
var { XPCOMUtils } = ChromeUtils.import(
"resource://gre/modules/XPCOMUtils.jsm"
const { ContentProcessDomain } = ChromeUtils.import(
"chrome://remote/content/cdp/domains/ContentProcessDomain.jsm"
);
const lazy = {};
XPCOMUtils.defineLazyModuleGetters(lazy, {
ContentProcessDomain:
"chrome://remote/content/cdp/domains/ContentProcessDomain.jsm",
});
class Performance extends lazy.ContentProcessDomain {
class Performance extends ContentProcessDomain {
constructor(session) {
super(session);
this.enabled = false;

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

@ -11,13 +11,16 @@ const { XPCOMUtils } = ChromeUtils.import(
"resource://gre/modules/XPCOMUtils.jsm"
);
const { addDebuggerToGlobal } = ChromeUtils.import(
"resource://gre/modules/jsdebugger.jsm"
);
const { ContentProcessDomain } = ChromeUtils.import(
"chrome://remote/content/cdp/domains/ContentProcessDomain.jsm"
);
const lazy = {};
XPCOMUtils.defineLazyModuleGetters(lazy, {
addDebuggerToGlobal: "resource://gre/modules/jsdebugger.jsm",
ContentProcessDomain:
"chrome://remote/content/cdp/domains/ContentProcessDomain.jsm",
executeSoon: "chrome://remote/content/shared/Sync.jsm",
ExecutionContext:
"chrome://remote/content/cdp/domains/content/runtime/ExecutionContext.jsm",
@ -30,7 +33,8 @@ XPCOMUtils.defineLazyGetter(lazy, "ConsoleAPIStorage", () => {
});
// Import the `Debugger` constructor in the current scope
lazy.addDebuggerToGlobal(globalThis);
// eslint-disable-next-line mozilla/reject-globalThis-modification
addDebuggerToGlobal(globalThis);
const CONSOLE_API_LEVEL_MAP = {
warn: "warning",
@ -62,7 +66,7 @@ class SetMap extends Map {
}
}
class Runtime extends lazy.ContentProcessDomain {
class Runtime extends ContentProcessDomain {
constructor(session) {
super(session);
this.enabled = false;

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

@ -6,18 +6,11 @@
var EXPORTED_SYMBOLS = ["Security"];
var { XPCOMUtils } = ChromeUtils.import(
"resource://gre/modules/XPCOMUtils.jsm"
const { ContentProcessDomain } = ChromeUtils.import(
"chrome://remote/content/cdp/domains/ContentProcessDomain.jsm"
);
const lazy = {};
XPCOMUtils.defineLazyModuleGetters(lazy, {
ContentProcessDomain:
"chrome://remote/content/cdp/domains/ContentProcessDomain.jsm",
});
class Security extends lazy.ContentProcessDomain {
class Security extends ContentProcessDomain {
constructor(session) {
super(session);
this.enabled = false;

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

@ -7,17 +7,12 @@
var EXPORTED_SYMBOLS = ["Browser"];
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
const { XPCOMUtils } = ChromeUtils.import(
"resource://gre/modules/XPCOMUtils.jsm"
const { Domain } = ChromeUtils.import(
"chrome://remote/content/cdp/domains/Domain.jsm"
);
const lazy = {};
XPCOMUtils.defineLazyModuleGetters(lazy, {
Domain: "chrome://remote/content/cdp/domains/Domain.jsm",
});
class Browser extends lazy.Domain {
class Browser extends Domain {
getVersion() {
const { isHeadless } = Cc["@mozilla.org/gfx/info;1"].getService(
Ci.nsIGfxInfo

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

@ -10,17 +10,19 @@ const { XPCOMUtils } = ChromeUtils.import(
"resource://gre/modules/XPCOMUtils.jsm"
);
const { Domain } = ChromeUtils.import(
"chrome://remote/content/cdp/domains/Domain.jsm"
);
const lazy = {};
XPCOMUtils.defineLazyModuleGetters(lazy, {
NetUtil: "resource://gre/modules/NetUtil.jsm",
Domain: "chrome://remote/content/cdp/domains/Domain.jsm",
});
const MAX_WINDOW_SIZE = 10000000;
class Emulation extends lazy.Domain {
class Emulation extends Domain {
destructor() {
this.setUserAgentOverride({ userAgent: "", platform: "" });

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

@ -6,20 +6,14 @@
var EXPORTED_SYMBOLS = ["Fetch"];
const { XPCOMUtils } = ChromeUtils.import(
"resource://gre/modules/XPCOMUtils.jsm"
const { Domain } = ChromeUtils.import(
"chrome://remote/content/cdp/domains/Domain.jsm"
);
const lazy = {};
XPCOMUtils.defineLazyModuleGetters(lazy, {
Domain: "chrome://remote/content/cdp/domains/Domain.jsm",
});
// Note: For now this domain has only been added so that clients using CDP
// (like Selenium) don't break when trying to disable Fetch events.
class Fetch extends lazy.Domain {
class Fetch extends Domain {
constructor(session) {
super(session);

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

@ -10,21 +10,25 @@ const { XPCOMUtils } = ChromeUtils.import(
"resource://gre/modules/XPCOMUtils.jsm"
);
const { Domain } = ChromeUtils.import(
"chrome://remote/content/cdp/domains/Domain.jsm"
);
const { StreamRegistry } = ChromeUtils.import(
"chrome://remote/content/cdp/StreamRegistry.jsm"
);
const lazy = {};
XPCOMUtils.defineLazyModuleGetters(lazy, {
OS: "resource://gre/modules/osfile.jsm",
Domain: "chrome://remote/content/cdp/domains/Domain.jsm",
StreamRegistry: "chrome://remote/content/cdp/StreamRegistry.jsm",
});
const DEFAULT_CHUNK_SIZE = 10 * 1024 * 1024;
// Global singleton for managing open streams
const streamRegistry = new lazy.StreamRegistry();
const streamRegistry = new StreamRegistry();
class IO extends lazy.Domain {
class IO extends Domain {
// commands
/**

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

@ -7,17 +7,12 @@
var EXPORTED_SYMBOLS = ["Input"];
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
const { XPCOMUtils } = ChromeUtils.import(
"resource://gre/modules/XPCOMUtils.jsm"
const { Domain } = ChromeUtils.import(
"chrome://remote/content/cdp/domains/Domain.jsm"
);
const lazy = {};
XPCOMUtils.defineLazyModuleGetters(lazy, {
Domain: "chrome://remote/content/cdp/domains/Domain.jsm",
});
class Input extends lazy.Domain {
class Input extends Domain {
// commands
/**

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

@ -7,16 +7,11 @@
var EXPORTED_SYMBOLS = ["Network"];
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
const { XPCOMUtils } = ChromeUtils.import(
"resource://gre/modules/XPCOMUtils.jsm"
const { Domain } = ChromeUtils.import(
"chrome://remote/content/cdp/domains/Domain.jsm"
);
const lazy = {};
XPCOMUtils.defineLazyModuleGetters(lazy, {
Domain: "chrome://remote/content/cdp/domains/Domain.jsm",
});
const MAX_COOKIE_EXPIRY = Number.MAX_SAFE_INTEGER;
const LOAD_CAUSE_STRINGS = {
@ -43,7 +38,7 @@ const LOAD_CAUSE_STRINGS = {
[Ci.nsIContentPolicy.TYPE_WEB_MANIFEST]: "WebManifest",
};
class Network extends lazy.Domain {
class Network extends Domain {
constructor(session) {
super(session);
this.enabled = false;

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

@ -11,6 +11,10 @@ const { XPCOMUtils } = ChromeUtils.import(
"resource://gre/modules/XPCOMUtils.jsm"
);
const { Domain } = ChromeUtils.import(
"chrome://remote/content/cdp/domains/Domain.jsm"
);
const lazy = {};
XPCOMUtils.defineLazyModuleGetters(lazy, {
@ -21,7 +25,6 @@ XPCOMUtils.defineLazyModuleGetters(lazy, {
DialogHandler:
"chrome://remote/content/cdp/domains/parent/page/DialogHandler.jsm",
Domain: "chrome://remote/content/cdp/domains/Domain.jsm",
PollPromise: "chrome://remote/content/shared/Sync.jsm",
streamRegistry: "chrome://remote/content/cdp/domains/parent/IO.jsm",
TabManager: "chrome://remote/content/shared/TabManager.jsm",
@ -42,7 +45,7 @@ const PDF_TRANSFER_MODES = {
const TIMEOUT_SET_HISTORY_INDEX = 1000;
class Page extends lazy.Domain {
class Page extends Domain {
constructor(session) {
super(session);

Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше