Bug 1312954 - Part 8: Update speculativeConnect to speculativeConnect2 for about:newtab. r=Gijs

This commit is contained in:
Tim Huang 2017-02-02 22:17:00 -05:00
Родитель a51aff22a7
Коммит d2f929cacb
1 изменённых файлов: 12 добавлений и 1 удалений

Просмотреть файл

@ -311,10 +311,21 @@ Site.prototype = {
_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) {}
},