Skip to content

Commit

Permalink
131.0b2
Browse files Browse the repository at this point in the history
  • Loading branch information
bot committed Sep 5, 2024
1 parent 28f335d commit 3d1199f
Show file tree
Hide file tree
Showing 723 changed files with 20,209 additions and 21,771 deletions.
1 change: 1 addition & 0 deletions firefox-src-part/browser/actors/ClickHandlerParent.sys.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ export class ClickHandlerParent extends JSWindowActorParent {
openerBrowser: browser,
// The child ensures that untrusted events have a valid user activation.
hasValidUserGestureActivation: true,
textDirectiveUserActivation: true,
triggeringRemoteType: this.manager.domProcess?.remoteType,
};

Expand Down
7 changes: 0 additions & 7 deletions firefox-src-part/browser/actors/ContextMenuChild.sys.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,6 @@ export class ContextMenuChild extends JSWindowActorChild {
}
break;
case "pictureinpicture":
if (!media.isCloningElementVisually) {
Services.telemetry.keyedScalarAdd(
"pictureinpicture.opened_method",
"contextmenu",
1
);
}
let event = new this.contentWindow.CustomEvent(
"MozTogglePictureInPicture",
{
Expand Down
121 changes: 119 additions & 2 deletions firefox-src-part/browser/actors/ContextMenuParent.sys.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,18 @@
* 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/. */

import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs";

const lazy = {};

ChromeUtils.defineESModuleGetters(lazy, {
E10SUtils: "resource://gre/modules/E10SUtils.sys.mjs",
FirefoxRelay: "resource://gre/modules/FirefoxRelay.sys.mjs",
WebNavigationFrames: "resource://gre/modules/WebNavigationFrames.sys.mjs",
});

XPCOMUtils.defineLazyServiceGetters(lazy, {
BrowserHandler: ["@mozilla.org/browser/clh;1", "nsIBrowserHandler"],
});

export class ContextMenuParent extends JSWindowActorParent {
Expand All @@ -18,14 +26,14 @@ export class ContextMenuParent extends JSWindowActorParent {
// loads nsContextMenu.js. In that case, try to find the chromeEventHandler,
// since that'll likely be the "top" <xul:browser>, and then use its window's
// nsContextMenu instance instead.
if (!win.openContextMenu) {
if (!win.nsContextMenu) {
let topBrowser = browser.ownerGlobal.docShell.chromeEventHandler;
win = topBrowser.ownerGlobal;
}

message.data.context.showRelay &&= lazy.FirefoxRelay.isEnabled;

win.openContextMenu(message, browser, this);
this.#openContextMenu(message.data, win, browser);
}

hiding() {
Expand Down Expand Up @@ -114,4 +122,113 @@ export class ContextMenuParent extends JSWindowActorParent {
targetIdentifier,
});
}

/**
* Handles opening of the context menu for the appropraite browser.
*
* @param {object} data
* The data for the context menu, received from the child.
* @param {DOMWindow} win
* The window in which the context menu is to be opened.
* @param {Browser} browser
* The browser the context menu is being opened for.
*/
#openContextMenu(data, win, browser) {
if (lazy.BrowserHandler.kiosk) {
// Don't display context menus in kiosk mode
return;
}
let wgp = this.manager;

if (!wgp.isCurrentGlobal) {
// Don't display context menus for unloaded documents
return;
}

// NOTE: We don't use `wgp.documentURI` here as we want to use the failed
// channel URI in the case we have loaded an error page.
let documentURIObject = wgp.browsingContext.currentURI;

let frameReferrerInfo = data.frameReferrerInfo;
if (frameReferrerInfo) {
frameReferrerInfo =
lazy.E10SUtils.deserializeReferrerInfo(frameReferrerInfo);
}

let linkReferrerInfo = data.linkReferrerInfo;
if (linkReferrerInfo) {
linkReferrerInfo =
lazy.E10SUtils.deserializeReferrerInfo(linkReferrerInfo);
}

let frameID = lazy.WebNavigationFrames.getFrameId(wgp.browsingContext);

win.nsContextMenu.contentData = {
context: data.context,
browser,
actor: this,
editFlags: data.editFlags,
spellInfo: data.spellInfo,
principal: wgp.documentPrincipal,
storagePrincipal: wgp.documentStoragePrincipal,
documentURIObject,
docLocation: documentURIObject.spec,
charSet: data.charSet,
referrerInfo: lazy.E10SUtils.deserializeReferrerInfo(data.referrerInfo),
frameReferrerInfo,
linkReferrerInfo,
contentType: data.contentType,
contentDisposition: data.contentDisposition,
frameID,
frameOuterWindowID: frameID,
frameBrowsingContext: wgp.browsingContext,
selectionInfo: data.selectionInfo,
disableSetDesktopBackground: data.disableSetDesktopBackground,
showRelay: data.showRelay,
loginFillInfo: data.loginFillInfo,
userContextId: wgp.browsingContext.originAttributes.userContextId,
webExtContextData: data.webExtContextData,
cookieJarSettings: wgp.cookieJarSettings,
};

let popup = win.document.getElementById("contentAreaContextMenu");
let context = win.nsContextMenu.contentData.context;

// Fill in some values in the context from the WindowGlobalParent actor.
context.principal = wgp.documentPrincipal;
context.storagePrincipal = wgp.documentStoragePrincipal;
context.frameID = frameID;
context.frameOuterWindowID = wgp.outerWindowId;
context.frameBrowsingContextID = wgp.browsingContext.id;

// We don't have access to the original event here, as that happened in
// another process. Therefore we synthesize a new MouseEvent to propagate the
// inputSource to the subsequently triggered popupshowing event.
let newEvent = new PointerEvent("contextmenu", {
bubbles: true,
cancelable: true,
screenX: context.screenXDevPx / win.devicePixelRatio,
screenY: context.screenYDevPx / win.devicePixelRatio,
button: 2,
pointerType: (() => {
switch (context.inputSource) {
case MouseEvent.MOZ_SOURCE_MOUSE:
return "mouse";
case MouseEvent.MOZ_SOURCE_PEN:
return "pen";
case MouseEvent.MOZ_SOURCE_ERASER:
return "eraser";
case MouseEvent.MOZ_SOURCE_CURSOR:
return "cursor";
case MouseEvent.MOZ_SOURCE_TOUCH:
return "touch";
case MouseEvent.MOZ_SOURCE_KEYBOARD:
return "keyboard";
default:
return "";
}
})(),
});
popup.openPopupAtScreen(newEvent.screenX, newEvent.screenY, true, newEvent);
}
}
12 changes: 5 additions & 7 deletions firefox-src-part/browser/actors/LinkHandlerParent.sys.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
const lazy = {};

ChromeUtils.defineESModuleGetters(lazy, {
PlacesUIUtils: "resource:///modules/PlacesUIUtils.sys.mjs",
PlacesUtils: "resource://gre/modules/PlacesUtils.sys.mjs",
});

let gTestListeners = new Set();
Expand Down Expand Up @@ -131,7 +131,7 @@ export class LinkHandlerParent extends JSWindowActorParent {
console.error(ex);
return;
}
if (iconURI.scheme != "data") {
if (!iconURI.schemeIs("data")) {
try {
Services.scriptSecurityManager.checkLoadURIWithPrincipal(
browser.contentPrincipal,
Expand All @@ -144,13 +144,11 @@ export class LinkHandlerParent extends JSWindowActorParent {
}
if (canStoreIcon) {
try {
lazy.PlacesUIUtils.loadFavicon(
browser,
Services.scriptSecurityManager.getSystemPrincipal(),
lazy.PlacesUtils.favicons.setFaviconForPage(
Services.io.newURI(pageURL),
Services.io.newURI(originalURL),
expiration,
iconURI
iconURI,
expiration && lazy.PlacesUtils.toPRTime(expiration)
);
} catch (ex) {
console.error(ex);
Expand Down
38 changes: 35 additions & 3 deletions firefox-src-part/browser/actors/SearchSERPTelemetryChild.sys.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const lazy = {};

ChromeUtils.defineESModuleGetters(lazy, {
clearTimeout: "resource://gre/modules/Timer.sys.mjs",
SearchUtils: "resource://gre/modules/SearchUtils.sys.mjs",
setTimeout: "resource://gre/modules/Timer.sys.mjs",
});

Expand All @@ -18,6 +19,13 @@ XPCOMUtils.defineLazyPreferenceGetter(
false
);

ChromeUtils.defineLazyGetter(lazy, "logConsole", () => {
return console.createInstance({
prefix: "SearchTelemetry",
maxLogLevel: lazy.SearchUtils.loggingEnabled ? "Debug" : "Warn",
});
});

export const CATEGORIZATION_SETTINGS = {
MAX_DOMAINS_TO_CATEGORIZE: 10,
};
Expand Down Expand Up @@ -546,7 +554,16 @@ class SearchAdImpression {
#categorizeAnchors(anchors, origin) {
for (let anchor of anchors) {
if (this.#shouldInspectAnchor(anchor, origin)) {
let result = this.#findDataForAnchor(anchor);
let result;
try {
// We use a schema to ensure the values for each search provider
// aligns to what is expected, but tests don't enforce the schema
// and thus, can technically input faulty values.
result = this.#findDataForAnchor(anchor);
} catch (ex) {
lazy.logConsole.error("Could not find data for anchor:", ex);
continue;
}
if (result) {
this.#recordElementData(result.element, {
type: result.type,
Expand All @@ -555,7 +572,7 @@ class SearchAdImpression {
childElements: result.childElements,
});
}
if (result.relatedElements?.length) {
if (result?.relatedElements?.length) {
// Bug 1880413: Deprecate related elements.
// Bottom-up approach with related elements are only used for
// non-link elements related to ads, like carousel arrows.
Expand Down Expand Up @@ -735,10 +752,13 @@ class SearchAdImpression {
*
* @param {HTMLAnchorElement} anchor
* The anchor to be inspected.
* @returns {object}
* @returns {object | null}
* An object containing the element representing the root DOM element for
* the component, the type of component, how many ads were counted,
* and whether or not the count was of all the children.
* @throws {Error}
* Will throw an error if certain properties of a component are missing.
* Required properties are listed in search-telemetry-v2-schema.json.
*/
#findDataForAnchor(anchor) {
for (let component of this.#providerInfo.components) {
Expand Down Expand Up @@ -781,6 +801,12 @@ class SearchAdImpression {
continue;
}

// If a parent was found, we may want to ignore reporting the element
// to telemetry.
if (component.included.parent.skipCount) {
return null;
}

// If we've already inspected the parent, add the child element to the
// list of anchors. Don't increment the ads loaded count, as we only care
// about grouping the anchor with the correct parent.
Expand All @@ -805,6 +831,9 @@ class SearchAdImpression {
// If counting by child, get all of them at once.
if (child.countChildren) {
let proxyChildElements = parent.querySelectorAll(child.selector);
if (child.skipCount) {
return null;
}
if (proxyChildElements.length) {
return {
element: parent,
Expand All @@ -816,6 +845,9 @@ class SearchAdImpression {
};
}
} else if (parent.querySelector(child.selector)) {
if (child.skipCount) {
return null;
}
return {
element: parent,
type: child.type ?? component.type,
Expand Down
Loading

0 comments on commit 3d1199f

Please sign in to comment.