Bug 1334690 - Test that AlternateService is isolated by origin attributes. r=mcmanus

MozReview-Commit-ID: 3e6eiB5roVt

--HG--
extra : rebase_source : 57e16386780d3bf52e5557f3570a8835eb99e361
This commit is contained in:
Jonathan Hao 2017-02-16 17:50:55 +08:00
Родитель c31d2de030
Коммит 020a6ee9a8
1 изменённых файлов: 70 добавлений и 1 удалений

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

@ -145,6 +145,7 @@ var loadWithoutClearingMappings = false;
var nextTest; var nextTest;
var expectPass = true; var expectPass = true;
var waitFor = 0; var waitFor = 0;
var originAttributes = {};
var Listener = function() {}; var Listener = function() {};
Listener.prototype = { Listener.prototype = {
@ -222,6 +223,7 @@ function doTest()
Ci.nsIChannel.LOAD_INITIAL_DOCUMENT_URI; Ci.nsIChannel.LOAD_INITIAL_DOCUMENT_URI;
} }
loadWithoutClearingMappings = false; loadWithoutClearingMappings = false;
chan.loadInfo.originAttributes = originAttributes;
chan.asyncOpen2(listener); chan.asyncOpen2(listener);
} }
@ -367,8 +369,75 @@ function doTest11()
xaltsvc = h2FooRoute; xaltsvc = h2FooRoute;
expectPass = true; expectPass = true;
waitFor = 500; waitFor = 500;
nextTest = testsDone; nextTest = doTest12;
do_test_pending(); do_test_pending();
doTest(); doTest();
} }
// Test 12-15:
// Insert a cache of http://foo served from h2=:port with origin attributes.
function doTest12()
{
dump("doTest12()\n");
origin = httpFooOrigin;
xaltsvc = h2Route;
originAttributes = {
userContextId: 1,
firstPartyDomain: "a.com",
};
nextTest = doTest13;
do_test_pending();
doTest();
xaltsvc = h2FooRoute;
}
// Make sure we get a cache miss with a different userContextId.
function doTest13()
{
dump("doTest13()\n");
origin = httpFooOrigin;
xaltsvc = 'NA';
originAttributes = {
userContextId: 2,
firstPartyDomain: "a.com",
};
loadWithoutClearingMappings = true;
nextTest = doTest14;
do_test_pending();
doTest();
}
// Make sure we get a cache miss with a different firstPartyDomain.
function doTest14()
{
dump("doTest14()\n");
origin = httpFooOrigin;
xaltsvc = 'NA';
originAttributes = {
userContextId: 1,
firstPartyDomain: "b.com",
};
loadWithoutClearingMappings = true;
nextTest = doTest15;
do_test_pending();
doTest();
}
//
// Make sure we get a cache hit with the same origin attributes.
function doTest15()
{
dump("doTest15()\n");
origin = httpFooOrigin;
xaltsvc = 'NA';
originAttributes = {
userContextId: 1,
firstPartyDomain: "a.com",
};
loadWithoutClearingMappings = true;
nextTest = testsDone;
do_test_pending();
doTest();
// This ensures a cache hit.
xaltsvc = h2FooRoute;
}