Bug 1334693 - Test http2 push and origin attributes. r=mcmanus

MozReview-Commit-ID: 8qrhjyyV6Uc

--HG--
extra : rebase_source : a7b25bf4d9fc3abedac7959b0efc3271ea0994a7
This commit is contained in:
Jonathan Hao 2017-03-08 18:17:10 +08:00
parent 7bd0555dbc
commit 56383b67ab
2 changed files with 69 additions and 8 deletions

View File

@ -148,7 +148,9 @@ Http2HeaderListener.prototype.onDataAvailable = function(request, ctx, stream, o
read_stream(stream, cnt);
};
var Http2PushListener = function() {};
var Http2PushListener = function(shouldBePushed) {
this.shouldBePushed = shouldBePushed;
};
Http2PushListener.prototype = new Http2CheckListener();
@ -158,7 +160,7 @@ Http2PushListener.prototype.onDataAvailable = function(request, ctx, stream, off
if (request.originalURI.spec == "https://localhost:" + serverPort + "/push.js" ||
request.originalURI.spec == "https://localhost:" + serverPort + "/push2.js" ||
request.originalURI.spec == "https://localhost:" + serverPort + "/push5.js") {
do_check_eq(request.getResponseHeader("pushed"), "yes");
do_check_eq(request.getResponseHeader("pushed"), this.shouldBePushed ? "yes" : "no");
}
read_stream(stream, cnt);
};
@ -492,42 +494,42 @@ function test_http2_cookie_crumbling() {
function test_http2_push1() {
var chan = makeChan("https://localhost:" + serverPort + "/push");
chan.loadGroup = loadGroup;
var listener = new Http2PushListener();
var listener = new Http2PushListener(true);
chan.asyncOpen2(listener);
}
function test_http2_push2() {
var chan = makeChan("https://localhost:" + serverPort + "/push.js");
chan.loadGroup = loadGroup;
var listener = new Http2PushListener();
var listener = new Http2PushListener(true);
chan.asyncOpen2(listener);
}
function test_http2_push3() {
var chan = makeChan("https://localhost:" + serverPort + "/push2");
chan.loadGroup = loadGroup;
var listener = new Http2PushListener();
var listener = new Http2PushListener(true);
chan.asyncOpen2(listener);
}
function test_http2_push4() {
var chan = makeChan("https://localhost:" + serverPort + "/push2.js");
chan.loadGroup = loadGroup;
var listener = new Http2PushListener();
var listener = new Http2PushListener(true);
chan.asyncOpen2(listener);
}
function test_http2_push5() {
var chan = makeChan("https://localhost:" + serverPort + "/push5");
chan.loadGroup = loadGroup;
var listener = new Http2PushListener();
var listener = new Http2PushListener(true);
chan.asyncOpen2(listener);
}
function test_http2_push6() {
var chan = makeChan("https://localhost:" + serverPort + "/push5.js");
chan.loadGroup = loadGroup;
var listener = new Http2PushListener();
var listener = new Http2PushListener(true);
chan.asyncOpen2(listener);
}
@ -899,6 +901,54 @@ function test_http2_empty_data() {
chan.asyncOpen2(listener);
}
function test_http2_push_firstparty1() {
var chan = makeChan("https://localhost:" + serverPort + "/push");
chan.loadGroup = loadGroup;
chan.loadInfo.originAttributes = { firstPartyDomain: "foo.com" };
var listener = new Http2PushListener(true);
chan.asyncOpen2(listener);
}
function test_http2_push_firstparty2() {
var chan = makeChan("https://localhost:" + serverPort + "/push.js");
chan.loadGroup = loadGroup;
chan.loadInfo.originAttributes = { firstPartyDomain: "bar.com" };
var listener = new Http2PushListener(false);
chan.asyncOpen2(listener);
}
function test_http2_push_firstparty3() {
var chan = makeChan("https://localhost:" + serverPort + "/push.js");
chan.loadGroup = loadGroup;
chan.loadInfo.originAttributes = { firstPartyDomain: "foo.com" };
var listener = new Http2PushListener(true);
chan.asyncOpen2(listener);
}
function test_http2_push_userContext1() {
var chan = makeChan("https://localhost:" + serverPort + "/push");
chan.loadGroup = loadGroup;
chan.loadInfo.originAttributes = { userContextId: 1 };
var listener = new Http2PushListener(true);
chan.asyncOpen2(listener);
}
function test_http2_push_userContext2() {
var chan = makeChan("https://localhost:" + serverPort + "/push.js");
chan.loadGroup = loadGroup;
chan.loadInfo.originAttributes = { userContextId: 2 };
var listener = new Http2PushListener(false);
chan.asyncOpen2(listener);
}
function test_http2_push_userContext3() {
var chan = makeChan("https://localhost:" + serverPort + "/push.js");
chan.loadGroup = loadGroup;
chan.loadInfo.originAttributes = { userContextId: 1 };
var listener = new Http2PushListener(true);
chan.asyncOpen2(listener);
}
function test_complete() {
resetPrefs();
do_test_pending();
@ -951,6 +1001,12 @@ var tests = [ test_http2_post_big
, test_http2_h11required_session
, test_http2_retry_rst
, test_http2_wrongsuite
, test_http2_push_firstparty1
, test_http2_push_firstparty2
, test_http2_push_firstparty3
, test_http2_push_userContext1
, test_http2_push_userContext2
, test_http2_push_userContext3
// cleanup
, test_complete

View File

@ -277,6 +277,11 @@ function handleRequest(req, res) {
content = '<head> <script src="push.js"/></head>body text';
}
else if (u.pathname === "/push.js") {
content = '// comments';
res.setHeader("pushed", "no");
}
else if (u.pathname === "/push2") {
push = res.push('/push2.js');
push.writeHead(200, {