Bug 1883909 - P3. Workaround to support detect page navigation for the same-origin iframe. r=credential-management-reviewers,jneuberger,sgalich

When a page navigation event is received in the top-level frame, the same-origin iframe
is able to know that because they are in the same process.

However, the plan is to remove `FormAutofillContent`, which means we
will not be able to use "per process" module to communicate directly.

So instead, we should solve the issue by the child talks to the parent,
and then the parent talks to its childern. But before implementing the
solution mentioned above, we still use `FormAutofillContent` to workaround it.

Differential Revision: https://phabricator.services.mozilla.com/D203767
This commit is contained in:
Dimi 2024-03-13 13:26:06 +00:00
parent fa00f3f249
commit fac318fe3d

View file

@ -236,7 +236,7 @@ export class FormAutofillChild extends JSWindowActorChild {
* @returns {boolean} whether the navigation affects the active window * @returns {boolean} whether the navigation affects the active window
*/ */
isActiveWindowNavigation() { isActiveWindowNavigation() {
const activeWindow = this.activeHandler?.window; const activeWindow = lazy.FormAutofillContent.activeHandler?.window;
const navigatedWindow = this.document.defaultView; const navigatedWindow = this.document.defaultView;
if (!activeWindow || !navigatedWindow) { if (!activeWindow || !navigatedWindow) {
@ -266,7 +266,10 @@ export class FormAutofillChild extends JSWindowActorChild {
return; return;
} }
const activeElement = this.activeFieldDetail?.elementWeakRef.deref(); // TODO: We should not use FormAutofillContent and let the
// parent decides which child to notify
const activeChild = lazy.FormAutofillContent.activeAutofillChild;
const activeElement = activeChild.activeFieldDetail?.elementWeakRef.deref();
if (!activeElement) { if (!activeElement) {
return; return;
} }
@ -275,7 +278,7 @@ export class FormAutofillChild extends JSWindowActorChild {
// We only capture the form of the active field right now, // We only capture the form of the active field right now,
// this means that we might miss some fields (see bug 1871356) // this means that we might miss some fields (see bug 1871356)
this.formSubmitted(activeElement, formSubmissionReason); activeChild.formSubmitted(activeElement, formSubmissionReason);
} }
/** /**