summaryrefslogtreecommitdiffstats
path: root/browser/actors
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-15 03:34:50 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-15 03:34:50 +0000
commitdef92d1b8e9d373e2f6f27c366d578d97d8960c6 (patch)
tree2ef34b9ad8bb9a9220e05d60352558b15f513894 /browser/actors
parentAdding debian version 125.0.3-1. (diff)
downloadfirefox-def92d1b8e9d373e2f6f27c366d578d97d8960c6.tar.xz
firefox-def92d1b8e9d373e2f6f27c366d578d97d8960c6.zip
Merging upstream version 126.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'browser/actors')
-rw-r--r--browser/actors/AboutReaderParent.sys.mjs2
-rw-r--r--browser/actors/ContextMenuChild.sys.mjs4
-rw-r--r--browser/actors/FormValidationChild.sys.mjs2
-rw-r--r--browser/actors/FormValidationParent.sys.mjs2
-rw-r--r--browser/actors/PluginParent.sys.mjs2
-rw-r--r--browser/actors/PromptParent.sys.mjs188
-rw-r--r--browser/actors/RefreshBlockerChild.sys.mjs6
-rw-r--r--browser/actors/SearchSERPTelemetryChild.sys.mjs52
-rw-r--r--browser/actors/WebRTCChild.sys.mjs8
-rw-r--r--browser/actors/WebRTCParent.sys.mjs6
10 files changed, 85 insertions, 187 deletions
diff --git a/browser/actors/AboutReaderParent.sys.mjs b/browser/actors/AboutReaderParent.sys.mjs
index 544a257cbc..00126910ae 100644
--- a/browser/actors/AboutReaderParent.sys.mjs
+++ b/browser/actors/AboutReaderParent.sys.mjs
@@ -281,7 +281,7 @@ export class AboutReaderParent extends JSWindowActorParent {
* @return {Promise}
* @resolves JS object representing the article, or null if no article is found.
*/
- async _getArticle(url, browser) {
+ async _getArticle(url) {
return lazy.ReaderMode.downloadAndParseDocument(url).catch(e => {
if (e && e.newURL) {
// Pass up the error so we can navigate the browser in question to the new URL:
diff --git a/browser/actors/ContextMenuChild.sys.mjs b/browser/actors/ContextMenuChild.sys.mjs
index e16efdc9cd..5ecbcb22e9 100644
--- a/browser/actors/ContextMenuChild.sys.mjs
+++ b/browser/actors/ContextMenuChild.sys.mjs
@@ -371,7 +371,7 @@ export class ContextMenuChild extends JSWindowActorChild {
}
// Returns true if clicked-on link targets a resource that can be saved.
- _isLinkSaveable(aLink) {
+ _isLinkSaveable() {
// We don't do the Right Thing for news/snews yet, so turn them off
// until we do.
return (
@@ -696,7 +696,7 @@ export class ContextMenuChild extends JSWindowActorChild {
* - link
* - linkURI
*/
- _cleanContext(aEvent) {
+ _cleanContext() {
const context = this.context;
const cleanTarget = Object.create(null);
diff --git a/browser/actors/FormValidationChild.sys.mjs b/browser/actors/FormValidationChild.sys.mjs
index f5ce427d03..bb67f1f1f4 100644
--- a/browser/actors/FormValidationChild.sys.mjs
+++ b/browser/actors/FormValidationChild.sys.mjs
@@ -138,7 +138,7 @@ export class FormValidationChild extends JSWindowActorChild {
* Blur event handler in which we disconnect from the form element and
* hide the popup.
*/
- _onBlur(aEvent) {
+ _onBlur() {
if (this._element) {
this._element.removeEventListener("input", this);
this._element.removeEventListener("blur", this);
diff --git a/browser/actors/FormValidationParent.sys.mjs b/browser/actors/FormValidationParent.sys.mjs
index e95a8e86fb..a988b06f37 100644
--- a/browser/actors/FormValidationParent.sys.mjs
+++ b/browser/actors/FormValidationParent.sys.mjs
@@ -19,7 +19,7 @@ class PopupShownObserver {
this._weakContext = Cu.getWeakReference(browsingContext);
}
- observe(subject, topic, data) {
+ observe(subject, topic) {
let ctxt = this._weakContext.get();
let actor = ctxt.currentWindowGlobal?.getExistingActor("FormValidation");
if (!actor) {
diff --git a/browser/actors/PluginParent.sys.mjs b/browser/actors/PluginParent.sys.mjs
index fa93c1d5ab..14eeb38945 100644
--- a/browser/actors/PluginParent.sys.mjs
+++ b/browser/actors/PluginParent.sys.mjs
@@ -19,7 +19,7 @@ ChromeUtils.defineLazyGetter(lazy, "gNavigatorBundle", function () {
export const PluginManager = {
gmpCrashes: new Map(),
- observe(subject, topic, data) {
+ observe(subject, topic) {
switch (topic) {
case "gmp-plugin-crash":
this._registerGMPCrash(subject);
diff --git a/browser/actors/PromptParent.sys.mjs b/browser/actors/PromptParent.sys.mjs
index 4a159cbda5..83180923b9 100644
--- a/browser/actors/PromptParent.sys.mjs
+++ b/browser/actors/PromptParent.sys.mjs
@@ -9,42 +9,22 @@ ChromeUtils.defineESModuleGetters(lazy, {
PromptUtils: "resource://gre/modules/PromptUtils.sys.mjs",
BrowserUtils: "resource://gre/modules/BrowserUtils.sys.mjs",
});
-import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs";
-
-XPCOMUtils.defineLazyPreferenceGetter(
- lazy,
- "tabChromePromptSubDialog",
- "prompts.tabChromePromptSubDialog",
- false
-);
-
-XPCOMUtils.defineLazyPreferenceGetter(
- lazy,
- "contentPromptSubDialog",
- "prompts.contentPromptSubDialog",
- false
-);
ChromeUtils.defineLazyGetter(lazy, "gTabBrowserLocalization", function () {
return new Localization(["browser/tabbrowser.ftl"], true);
});
/**
- * @typedef {Object} Prompt
- * @property {Function} resolver
- * The resolve function to be called with the data from the Prompt
- * after the user closes it.
- * @property {Object} tabModalPrompt
- * The TabModalPrompt being shown to the user.
+ * @typedef {Object} Dialog
*/
/**
- * gBrowserPrompts weakly maps BrowsingContexts to a Map of their currently
- * active Prompts.
+ * gBrowserDialogs weakly maps BrowsingContexts to a Map of their currently
+ * active Dialogs.
*
- * @type {WeakMap<BrowsingContext, Prompt>}
+ * @type {WeakMap<BrowsingContext, Dialog>}
*/
-let gBrowserPrompts = new WeakMap();
+let gBrowserDialogs = new WeakMap();
export class PromptParent extends JSWindowActorParent {
didDestroy() {
@@ -54,35 +34,24 @@ export class PromptParent extends JSWindowActorParent {
}
/**
- * Registers a new Prompt to be tracked for a particular BrowsingContext.
- * We need to track a Prompt so that we can, for example, force-close the
- * TabModalPrompt if the originating subframe or tab unloads or crashes.
+ * Registers a new dialog to be tracked for a particular BrowsingContext.
+ * We need to track a dialog so that we can, for example, force-close the
+ * dialog if the originating subframe or tab unloads or crashes.
*
- * @param {Object} tabModalPrompt
- * The TabModalPrompt that will be shown to the user.
+ * @param {Dialog} dialog
+ * The dialog that will be shown to the user.
* @param {string} id
- * A unique ID to differentiate multiple Prompts coming from the same
+ * A unique ID to differentiate multiple dialogs coming from the same
* BrowsingContext.
- * @return {Promise}
- * @resolves {Object}
- * Resolves with the arguments returned from the TabModalPrompt when it
- * is dismissed.
*/
- registerPrompt(tabModalPrompt, id) {
- let prompts = gBrowserPrompts.get(this.browsingContext);
- if (!prompts) {
- prompts = new Map();
- gBrowserPrompts.set(this.browsingContext, prompts);
+ registerDialog(dialog, id) {
+ let dialogs = gBrowserDialogs.get(this.browsingContext);
+ if (!dialogs) {
+ dialogs = new Map();
+ gBrowserDialogs.set(this.browsingContext, dialogs);
}
- let promise = new Promise(resolve => {
- prompts.set(id, {
- tabModalPrompt,
- resolver: resolve,
- });
- });
-
- return promise;
+ dialogs.set(id, dialog);
}
/**
@@ -94,20 +63,18 @@ export class PromptParent extends JSWindowActorParent {
* BrowsingContext.
*/
unregisterPrompt(id) {
- let prompts = gBrowserPrompts.get(this.browsingContext);
- if (prompts) {
- prompts.delete(id);
- }
+ let dialogs = gBrowserDialogs.get(this.browsingContext);
+ dialogs?.delete(id);
}
/**
* Programmatically closes all Prompts for the current BrowsingContext.
*/
forceClosePrompts() {
- let prompts = gBrowserPrompts.get(this.browsingContext) || [];
+ let dialogs = gBrowserDialogs.get(this.browsingContext) || [];
- for (let [, prompt] of prompts) {
- prompt.tabModalPrompt && prompt.tabModalPrompt.abortPrompt();
+ for (let [, dialog] of dialogs) {
+ dialog?.abort();
}
}
@@ -127,120 +94,19 @@ export class PromptParent extends JSWindowActorParent {
}
receiveMessage(message) {
- let args = message.data;
- let id = args._remoteId;
-
switch (message.name) {
case "Prompt:Open":
if (!this.windowContext.isActiveInTab) {
return undefined;
}
- if (
- (args.modalType === Ci.nsIPrompt.MODAL_TYPE_CONTENT &&
- !lazy.contentPromptSubDialog) ||
- (args.modalType === Ci.nsIPrompt.MODAL_TYPE_TAB &&
- !lazy.tabChromePromptSubDialog)
- ) {
- return this.openContentPrompt(args, id);
- }
- return this.openPromptWithTabDialogBox(args);
+ return this.openPromptWithTabDialogBox(message.data);
}
return undefined;
}
/**
- * Opens a TabModalPrompt for a BrowsingContext, and puts the associated browser
- * in the modal state until the TabModalPrompt is closed.
- *
- * @param {Object} args
- * The arguments passed up from the BrowsingContext to be passed directly
- * to the TabModalPrompt.
- * @param {string} id
- * A unique ID to differentiate multiple Prompts coming from the same
- * BrowsingContext.
- * @return {Promise}
- * Resolves when the TabModalPrompt is dismissed.
- * @resolves {Object}
- * The arguments returned from the TabModalPrompt.
- */
- openContentPrompt(args, id) {
- let browser = this.browsingContext.top.embedderElement;
- if (!browser) {
- throw new Error("Cannot tab-prompt without a browser!");
- }
- let window = browser.ownerGlobal;
- let tabPrompt = window.gBrowser.getTabModalPromptBox(browser);
- let newPrompt;
- let needRemove = false;
-
- // If the page which called the prompt is different from the the top context
- // where we show the prompt, ask the prompt implementation to display the origin.
- // For example, this can happen if a cross origin subframe shows a prompt.
- args.showCallerOrigin =
- args.promptPrincipal &&
- !browser.contentPrincipal.equals(args.promptPrincipal);
-
- let onPromptClose = () => {
- let promptData = gBrowserPrompts.get(this.browsingContext);
- if (!promptData || !promptData.has(id)) {
- throw new Error(
- "Failed to close a prompt since it wasn't registered for some reason."
- );
- }
-
- let { resolver, tabModalPrompt } = promptData.get(id);
- // It's possible that we removed the prompt during the
- // appendPrompt call below. In that case, newPrompt will be
- // undefined. We set the needRemove flag to remember to remove
- // it right after we've finished adding it.
- if (tabModalPrompt) {
- tabPrompt.removePrompt(tabModalPrompt);
- } else {
- needRemove = true;
- }
-
- this.unregisterPrompt(id);
-
- lazy.PromptUtils.fireDialogEvent(
- window,
- "DOMModalDialogClosed",
- browser,
- this.getClosingEventDetail(args)
- );
- resolver(args);
- browser.maybeLeaveModalState();
- };
-
- try {
- browser.enterModalState();
- lazy.PromptUtils.fireDialogEvent(
- window,
- "DOMWillOpenModalDialog",
- browser,
- this.getOpenEventDetail(args)
- );
-
- args.promptActive = true;
-
- newPrompt = tabPrompt.appendPrompt(args, onPromptClose);
- let promise = this.registerPrompt(newPrompt, id);
-
- if (needRemove) {
- tabPrompt.removePrompt(newPrompt);
- }
-
- return promise;
- } catch (ex) {
- console.error(ex);
- onPromptClose(true);
- }
-
- return null;
- }
-
- /**
* Opens either a window prompt or TabDialogBox at the content or tab level
* for a BrowsingContext, and puts the associated browser in the modal state
* until the prompt is closed.
@@ -349,8 +215,9 @@ export class PromptParent extends JSWindowActorParent {
);
}
bag = lazy.PromptUtils.objectToPropBag(args);
+ let promptID = args._remoteId;
try {
- await dialogBox.open(
+ let { dialog, closedPromise } = dialogBox.open(
uri,
{
features: "resizable=no",
@@ -359,7 +226,9 @@ export class PromptParent extends JSWindowActorParent {
hideContent: args.isTopLevelCrossDomainAuth,
},
bag
- ).closedPromise;
+ );
+ this.registerDialog(dialog, promptID);
+ await closedPromise;
} finally {
if (args.isTopLevelCrossDomainAuth) {
browser.currentAuthPromptURI = null;
@@ -373,6 +242,7 @@ export class PromptParent extends JSWindowActorParent {
currentLocationsTabLabel
);
}
+ this.unregisterPrompt(promptID);
}
} else {
// Ensure we set the correct modal type at this point.
diff --git a/browser/actors/RefreshBlockerChild.sys.mjs b/browser/actors/RefreshBlockerChild.sys.mjs
index 6ba63298b1..f5e9611144 100644
--- a/browser/actors/RefreshBlockerChild.sys.mjs
+++ b/browser/actors/RefreshBlockerChild.sys.mjs
@@ -50,7 +50,7 @@ var progressListener = {
* the STATE_IS_WINDOW case, which will clear any mappings from
* blockedWindows.
*/
- onStateChange(aWebProgress, aRequest, aStateFlags, aStatus) {
+ onStateChange(aWebProgress, aRequest, aStateFlags) {
if (
aStateFlags & Ci.nsIWebProgressListener.STATE_IS_WINDOW &&
aStateFlags & Ci.nsIWebProgressListener.STATE_STOP
@@ -64,7 +64,7 @@ var progressListener = {
* onRefreshAttempted has already fired for this DOM Window, will
* send the appropriate refresh blocked data to the parent.
*/
- onLocationChange(aWebProgress, aRequest, aLocation, aFlags) {
+ onLocationChange(aWebProgress) {
let win = aWebProgress.DOMWindow;
if (this.blockedWindows.has(win)) {
let data = this.blockedWindows.get(win);
@@ -180,7 +180,7 @@ export class RefreshBlockerObserverChild extends JSProcessActorChild {
this.filtersMap = new Map();
}
- observe(subject, topic, data) {
+ observe(subject, topic) {
switch (topic) {
case "webnavigation-create":
case "chrome-webnavigation-create":
diff --git a/browser/actors/SearchSERPTelemetryChild.sys.mjs b/browser/actors/SearchSERPTelemetryChild.sys.mjs
index c760f9a19e..e845f589b0 100644
--- a/browser/actors/SearchSERPTelemetryChild.sys.mjs
+++ b/browser/actors/SearchSERPTelemetryChild.sys.mjs
@@ -1077,7 +1077,11 @@ class DomainExtractor {
break;
}
case "textContent": {
- this.#fromElementsRetrieveTextContent(elements, extractedDomains);
+ this.#fromElementsRetrieveTextContent(
+ elements,
+ extractedDomains,
+ providerName
+ );
break;
}
}
@@ -1197,8 +1201,26 @@ class DomainExtractor {
* A list of elements from the page whose text content we want to inspect.
* @param {Set<string>} extractedDomains
* The result set of domains extracted from the page.
+ * @param {string} providerName
+ * The name of the search provider.
*/
- #fromElementsRetrieveTextContent(elements, extractedDomains) {
+ #fromElementsRetrieveTextContent(elements, extractedDomains, providerName) {
+ // Not an exhaustive regex, but it fits our purpose for this method.
+ const LOOSE_URL_REGEX =
+ /^(?:https?:\/\/)?(?:www\.)?(?:[\w\-]+\.)+(?:[\w\-]{2,})/i;
+
+ // Known but acceptable limitations to this function, where the return
+ // value won't be correctly fixed up:
+ // 1) A url is embedded within other text. Ex: "xkcd.com is cool."
+ // 2) The url contains legal but unusual characters. Ex: $ ! * '
+ function fixup(textContent) {
+ return textContent
+ .toLowerCase()
+ .replaceAll(" ", "")
+ .replace(/\.$/, "")
+ .concat(".com");
+ }
+
for (let element of elements) {
if (this.#exceedsThreshold(extractedDomains.size)) {
return;
@@ -1209,18 +1231,24 @@ class DomainExtractor {
}
let domain;
- try {
- domain = new URL(textContent).hostname;
- } catch (e) {
- domain = textContent.toLowerCase().replaceAll(" ", "");
- // If the attempt to turn the text content into a URL object only fails
- // because we're missing a protocol, ".com" may already be present.
- if (!domain.endsWith(".com")) {
- domain = domain.concat(".com");
+ if (LOOSE_URL_REGEX.test(textContent)) {
+ // Creating a new URL object will throw if the protocol is missing.
+ if (!/^https?:\/\//.test(textContent)) {
+ textContent = "https://" + textContent;
+ }
+
+ try {
+ domain = new URL(textContent).hostname;
+ } catch (e) {
+ domain = fixup(textContent);
}
+ } else {
+ domain = fixup(textContent);
}
- if (!extractedDomains.has(domain)) {
- extractedDomains.add(domain);
+
+ let processedDomain = this.#processDomain(domain, providerName);
+ if (processedDomain && !extractedDomains.has(processedDomain)) {
+ extractedDomains.add(processedDomain);
}
}
}
diff --git a/browser/actors/WebRTCChild.sys.mjs b/browser/actors/WebRTCChild.sys.mjs
index 50db01709d..03ad6d389b 100644
--- a/browser/actors/WebRTCChild.sys.mjs
+++ b/browser/actors/WebRTCChild.sys.mjs
@@ -213,7 +213,7 @@ function getActorForWindow(window) {
return null;
}
-function handlePCRequest(aSubject, aTopic, aData) {
+function handlePCRequest(aSubject) {
let { windowID, innerWindowID, callID, isSecure } = aSubject;
let contentWindow = Services.wm.getOuterWindowWithId(windowID);
if (!contentWindow.pendingPeerConnectionRequests) {
@@ -235,7 +235,7 @@ function handlePCRequest(aSubject, aTopic, aData) {
}
}
-function handleGUMStop(aSubject, aTopic, aData) {
+function handleGUMStop(aSubject) {
let contentWindow = Services.wm.getOuterWindowWithId(aSubject.windowID);
let request = {
@@ -250,7 +250,7 @@ function handleGUMStop(aSubject, aTopic, aData) {
}
}
-function handleGUMRequest(aSubject, aTopic, aData) {
+function handleGUMRequest(aSubject) {
// Now that a getUserMedia request has been created, we should check
// to see if we're supposed to have any devices muted. This needs
// to occur after the getUserMedia request is made, since the global
@@ -472,7 +472,7 @@ function forgetPendingListsEventually(aContentWindow) {
aContentWindow.removeEventListener("unload", WebRTCChild.handleEvent);
}
-function updateIndicators(aSubject, aTopic, aData) {
+function updateIndicators(aSubject) {
if (
aSubject instanceof Ci.nsIPropertyBag &&
aSubject.getProperty("requestURL") == kBrowserURL
diff --git a/browser/actors/WebRTCParent.sys.mjs b/browser/actors/WebRTCParent.sys.mjs
index 09c39e7393..806fd4abcf 100644
--- a/browser/actors/WebRTCParent.sys.mjs
+++ b/browser/actors/WebRTCParent.sys.mjs
@@ -609,7 +609,7 @@ function prompt(aActor, aBrowser, aRequest) {
actionL10nIds.push({ id }, { id: "webrtc-action-always-block" });
secondaryActions = [
{
- callback(aState) {
+ callback() {
aActor.denyRequest(aRequest);
if (!isNotNowLabelEnabled) {
lazy.SitePermissions.setForPrincipal(
@@ -623,7 +623,7 @@ function prompt(aActor, aBrowser, aRequest) {
},
},
{
- callback(aState) {
+ callback() {
aActor.denyRequest(aRequest);
lazy.SitePermissions.setForPrincipal(
principal,
@@ -1029,7 +1029,7 @@ function prompt(aActor, aBrowser, aRequest) {
video.srcObject = stream;
video.stream = stream;
doc.getElementById("webRTC-preview").hidden = false;
- video.onloadedmetadata = function (e) {
+ video.onloadedmetadata = function () {
video.play();
};
},