Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug 1237908] Make pdf.js use the correct principal origin attributes when loading … #7114

Merged
merged 1 commit into from
Apr 6, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions extensions/firefox/content/PdfStreamConverter.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -1083,22 +1083,26 @@ PdfStreamConverter.prototype = {
// Keep the URL the same so the browser sees it as the same.
channel.originalURI = aRequest.URI;
channel.loadGroup = aRequest.loadGroup;
channel.loadInfo.originAttributes = aRequest.loadInfo.originAttributes;

// We can use resource principal when data is fetched by the chrome
// make sure we reuse the origin attributes from the request channel to keep
// isolation consistent.
// e.g. useful for NoScript
var ssm = Cc['@mozilla.org/scriptsecuritymanager;1']
.getService(Ci.nsIScriptSecurityManager);
var uri = NetUtil.newURI(PDF_VIEWER_WEB_PAGE, null, null);
var attrs = aRequest.loadInfo.originAttributes;
var resourcePrincipal;
//#if MOZCENTRAL
resourcePrincipal = ssm.createCodebasePrincipal(uri, {});
resourcePrincipal = ssm.createCodebasePrincipal(uri, attrs);
//#else
// FF16 and below had getCodebasePrincipal, it was replaced by
// getNoAppCodebasePrincipal (bug 758258).
// FF43 then replaced getNoAppCodebasePrincipal with
// createCodebasePrincipal (bug 1165272).
if ('createCodebasePrincipal' in ssm) {
resourcePrincipal = ssm.createCodebasePrincipal(uri, {});
resourcePrincipal = ssm.createCodebasePrincipal(uri, attrs);
} else if ('getNoAppCodebasePrincipal' in ssm) {
resourcePrincipal = ssm.getNoAppCodebasePrincipal(uri);
} else {
Expand Down