author | Phil Ringnalda <philringnalda@gmail.com> |
Wed, 20 Jan 2016 19:40:44 -0800 | |
changeset 280800 | a6c0026d360b24f9e256df25ca301628d060f67a |
parent 280799 | 10d4e8736dbbb4f79320273906d148c448cb8e0b |
child 280801 | 6957ada1d4374578675646b4df249e402f2e6b5d |
push id | 70594 |
push user | philringnalda@gmail.com |
push date | Thu, 21 Jan 2016 03:41:01 +0000 |
treeherder | mozilla-inbound@a6c0026d360b [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
bugs | 1232901 |
milestone | 46.0a1 |
backs out | b82e4d33ec28f5ba9a964cfacfe2ec31bc063a74 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/dom/browser-element/BrowserElementParent.js +++ b/dom/browser-element/BrowserElementParent.js @@ -10,17 +10,16 @@ var Cc = Components.classes; var Cr = Components.results; /* BrowserElementParent injects script to listen for certain events in the * child. We then listen to messages from the child script and take * appropriate action here in the parent. */ Cu.import("resource://gre/modules/Services.jsm"); -Cu.import("resource://gre/modules/NetUtil.jsm"); Cu.import("resource://gre/modules/XPCOMUtils.jsm"); Cu.import("resource://gre/modules/BrowserElementPromptService.jsm"); XPCOMUtils.defineLazyGetter(this, "DOMApplicationRegistry", function () { Cu.import("resource://gre/modules/Webapps.jsm"); return DOMApplicationRegistry; }); @@ -997,27 +996,46 @@ BrowserElementParent.prototype = { aOffset, aCount) { this.extListener.onDataAvailable(aRequest, aContext, aInputStream, aOffset, aCount); }, QueryInterface: XPCOMUtils.generateQI([Ci.nsIStreamListener, Ci.nsIRequestObserver]) }; - let referrer = Services.io.newURI(_options.referrer, null, null); - let principal = - Services.scriptSecurityManager.createCodebasePrincipal( - referrer, this._frameLoader.loadContext.originAttributes); + // If we have a URI we'll use it to get the triggering principal to use, + // if not available a null principal is acceptable. + let referrer = null; + let principal = null; + if (_options.referrer) { + // newURI can throw on malformed URIs. + try { + referrer = Services.io.newURI(_options.referrer, null, null); + } + catch(e) { + debug('Malformed referrer -- ' + e); + } - let channel = NetUtil.newChannel({ - uri: url, - loadingPrincipal: principal, - securityFlags: SEC_ALLOW_CROSS_ORIGIN_DATA_INHERITS, - contentPolicyType: Ci.nsIContentPolicy.TYPE_OTHER - }); + // This simply returns null if there is no principal available + // for the requested uri. This is an acceptable fallback when + // calling newChannelFromURI2. + principal = + Services.scriptSecurityManager.createCodebasePrincipal( + referrer, this._frameLoader.loadContext.originAttributes); + } + + debug('Using principal? ' + !!principal); + + let channel = + Services.io.newChannelFromURI2(url, + null, // No document. + principal, // Loading principal + principal, // Triggering principal + Ci.nsILoadInfo.SEC_NORMAL, + Ci.nsIContentPolicy.TYPE_OTHER); // XXX We would set private browsing information prior to calling this. channel.notificationCallbacks = interfaceRequestor; // Since we're downloading our own local copy we'll want to bypass the // cache and local cache if the channel let's us specify this. let flags = Ci.nsIChannel.LOAD_CALL_CONTENT_SNIFFERS | Ci.nsIChannel.LOAD_BYPASS_CACHE; @@ -1032,17 +1050,17 @@ BrowserElementParent.prototype = { debug('Setting HTTP referrer = ' + (referrer && referrer.spec)); channel.referrer = referrer; if (channel instanceof Ci.nsIHttpChannelInternal) { channel.forceAllowThirdPartyCookie = true; } } // Set-up complete, let's get things started. - channel.asyncOpen2(new DownloadListener()); + channel.asyncOpen(new DownloadListener(), null); return req; }, getScreenshot: function(_width, _height, _mimeType) { if (!this._isAlive()) { throw Components.Exception("Dead content process", Cr.NS_ERROR_DOM_INVALID_STATE_ERR);