(from Waterfox Classic) Refactor addonId access in BasePrincipal and related files

This commit is contained in:
wuggy 2026-04-22 00:13:33 -07:00
commit 203d58a5cd
6 changed files with 26 additions and 13 deletions

View file

@ -1390,8 +1390,8 @@ TabActor.prototype = {
.outerWindowID;
}
// Collect the addonID from the document origin attributes.
let addonID = window.document.nodePrincipal.originAttributes.addonId;
// Collect the addonID from the document principal.
let addonID = window.document.nodePrincipal.addonId;
return {
id,

View file

@ -309,7 +309,15 @@ WebExtensionActor.prototype._shouldAddNewGlobalAsDebuggee = function (newGlobal)
const global = unwrapDebuggerObjectGlobal(newGlobal);
if (global instanceof Ci.nsIDOMWindow) {
return global.document.nodePrincipal.originAttributes.addonId == this.id;
try {
global.document;
} catch (e) {
// Sandboxes can expose a window in their prototype chain without
// having permission to access their own proto after navigation.
return false;
}
return global.document.nodePrincipal.addonId == this.id;
}
try {