commit 5a6cfc8f410c2ca81cf31b48df94dd4ea55ef81e
parent a164181254501710447cc742edd7e440d1a71aa1
Author: Stephen Thompson <sthompson@mozilla.com>
Date: Wed, 7 Jan 2026 20:26:05 +0000
Bug 2009012 - avoid window actor protocol error for CanonicalURL actor r=dwalker,tabbrowser-reviewers
TabNotesController currently asks the CanonicalURL window actor to detect the canonical URL of the page after history.pushState. The CanonicalURL actor is not supposed to run in every content process and that was acceptable, but using `WindowGlobalParent.getActor` will try and fail to instantiate the CanonicalURL actor on ineligible processes. This raises an error.
`WindowGlobalParent.getExistingActor` will return null and not raise errors if the CanonicalURL actor is not running. This is a closer fit for the intention of the code (ask the CanonicalURL actor to detect the canonical URL if applicable) and it does not raise an error.
Differential Revision: https://phabricator.services.mozilla.com/D278182
Diffstat:
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/browser/components/tabnotes/TabNotesController.sys.mjs b/browser/components/tabnotes/TabNotesController.sys.mjs
@@ -236,15 +236,18 @@ class TabNotesControllerClass {
// changed.
/** @type {CanonicalURLParent|undefined} */
let parent =
- aBrowser.browsingContext?.currentWindowGlobal.getActor(
+ aBrowser.browsingContext?.currentWindowGlobal.getExistingActor(
"CanonicalURL"
);
- parent?.sendAsyncMessage("CanonicalURL:Detect");
- lazy.logConsole.debug(
- "requesting CanonicalURL:Detect due to history.pushState",
- aLocation.spec
- );
+ if (parent) {
+ parent.sendAsyncMessage("CanonicalURL:Detect");
+ lazy.logConsole.debug(
+ "requesting CanonicalURL:Detect due to history.pushState",
+ aLocation.spec
+ );
+ }
+
return;
}