Bug 1713619 - Exempt chrome/resource (incl PDF.js) principals from canvas randomization/placeholders. r=lsalzman

Differential Revision: https://phabricator.services.mozilla.com/D197149
This commit is contained in:
Tom Schuster 2023-12-22 13:38:39 +00:00
parent 5622e08a8c
commit ff2bc9c19b

View File

@ -54,6 +54,11 @@ static bool IsUnrestrictedPrincipal(nsIPrincipal& aPrincipal) {
return true;
}
// Allow chrome: and resource: (this especially includes PDF.js)
if (aPrincipal.SchemeIs("chrome") || aPrincipal.SchemeIs("resource")) {
return true;
}
// Allow extension principals.
return aPrincipal.GetIsAddonOrExpandedAddonPrincipal();
}
@ -128,13 +133,6 @@ bool IsImageExtractionAllowed(dom::Document* aDocument, JSContext* aCx,
return true;
}
// Don't show canvas prompt for PDF.js
JS::AutoFilename scriptFile;
if (JS::DescribeScriptedCaller(aCx, &scriptFile) && scriptFile.get() &&
strcmp(scriptFile.get(), "resource://pdf.js/build/pdf.js") == 0) {
return true;
}
// -------------------------------------------------------------------
// Possibly block third parties