Bug 1312954 - Part 8: Updating speculativeConnect to speculativeConnect2 for about:newtab. r?Gijs
--- a/browser/base/content/newtab/sites.js
+++ b/browser/base/content/newtab/sites.js
@@ -305,20 +305,31 @@ Site.prototype = {
},
/**
* Speculatively opens a connection to the current site.
*/
_speculativeConnect: function Site_speculativeConnect() {
let sc = Services.io.QueryInterface(Ci.nsISpeculativeConnect);
let uri = Services.io.newURI(this.url);
+
+ if (!uri.schemeIs("http") && !uri.schemeIs("https")) {
+ return;
+ }
+
try {
// This can throw for certain internal URLs, when they wind up in
// about:newtab. Be sure not to propagate the error.
- sc.speculativeConnect(uri, null);
+
+ // We use the URI's codebase principal here to open its speculative
+ // connection.
+ let originAttributes = document.docShell.getOriginAttributes();
+ let principal = Services.scriptSecurityManager
+ .createCodebasePrincipal(uri, originAttributes);
+ sc.speculativeConnect2(uri, principal, null);
} catch (e) {}
},
/**
* Record interaction with site using telemetry.
*/
_recordSiteClicked: function Site_recordSiteClicked(aIndex) {
if (Services.prefs.prefHasUserValue("browser.newtabpage.rows") ||