bool WebExtensionContentScript::Matches(const DocInfo& aDoc) const { if (!mFrameID.IsNull()) { if (aDoc.FrameID() != mFrameID.Value()) { return false; } } else { if (!mAllFrames && !aDoc.IsTopLevel()) { return false; } } if (!mMatchAboutBlank && aDoc.URL().InheritsPrincipal()) { return false; } // Top-level about:blank is a special case. We treat it as a match if // matchAboutBlank is true and it has the null principal. In all other // cases, we test the URL of the principal that it inherits. if (mMatchAboutBlank && aDoc.IsTopLevel() && aDoc.URL().Spec().EqualsLiteral("about:blank") && aDoc.Principal() && aDoc.Principal()->GetIsNullPrincipal()) { return true; } // With the exception of top-level about:blank documents with null // principals, we never match documents that have non-codebase principals, // including those with null principals or system principals. if (aDoc.Principal() && !aDoc.Principal()->GetIsCodebasePrincipal()) { return false; } // Content scripts are not allowed on pages that have elevated // privileges via mozAddonManager (see bug 1280234) if (AddonManagerWebAPI::IsValidSite(aDoc.PrincipalURL().URI())) { return false; } if (mHasActiveTabPermission && aDoc.ShouldMatchActiveTabPermission()) { return true; } return MatchesURI(aDoc.PrincipalURL()); }