Bug 1281278 - test coverage for h2 push with brotli r=nwgh
MozReview-Commit-ID: 84LZRLsefJD
--- a/netwerk/test/unit/test_http2.js
+++ b/netwerk/test/unit/test_http2.js
@@ -723,16 +723,18 @@ Http2PushApiListener.prototype = {
// nsIHttpPushListener
onPush: function onPush(associatedChannel, pushChannel) {
do_check_eq(associatedChannel.originalURI.spec, "https://localhost:" + serverPort + "/pushapi1");
do_check_eq (pushChannel.getRequestHeader("x-pushed-request"), "true");
pushChannel.asyncOpen2(this);
if (pushChannel.originalURI.spec == "https://localhost:" + serverPort + "/pushapi1/2") {
pushChannel.cancel(Components.results.NS_ERROR_ABORT);
+ } else if (pushChannel.originalURI.spec == "https://localhost:" + serverPort + "/pushapi1/3") {
+ do_check_true(pushChannel.getRequestHeader("Accept-Encoding").includes("br"));
}
},
// normal Channel listeners
onStartRequest: function pushAPIOnStart(request, ctx) {
},
onDataAvailable: function pushAPIOnDataAvailable(request, ctx, stream, offset, cnt) {
@@ -769,17 +771,17 @@ Http2PushApiListener.prototype = {
}
};
// pushAPI testcase 1 expects
// 1 to pull /pushapi1 with 0
// 2 to see /pushapi1/1 with 1
// 3 to see /pushapi1/1 with 1 (again)
// 4 to see /pushapi1/2 that it will cancel
-// 5 to see /pushapi1/3 with 3
+// 5 to see /pushapi1/3 with 3 with brotli
function test_http2_pushapi_1() {
var chan = makeChan("https://localhost:" + serverPort + "/pushapi1");
chan.loadGroup = loadGroup;
var listener = new Http2PushApiListener();
chan.notificationCallbacks = listener;
chan.asyncOpen2(listener);
}
--- a/testing/xpcshell/moz-http2/moz-http2.js
+++ b/testing/xpcshell/moz-http2/moz-http2.js
@@ -339,24 +339,25 @@ function handleRequest(req, res) {
'subresource' : '2',
'content-length' : 1,
'X-Connection-Http2': 'yes'
});
push2.end('2');
push3 = res.push(
{ hostname: 'localhost:' + serverPort, port: serverPort, path : '/pushapi1/3', method : 'GET',
- headers: {'x-pushed-request': 'true'}});
+ headers: {'x-pushed-request': 'true', 'Accept-Encoding' : 'br'}});
push3.writeHead(200, {
'pushed' : 'yes',
- 'content-length' : 1,
+ 'content-length' : 6,
'subresource' : '3',
+ 'content-encoding' : 'br',
'X-Connection-Http2': 'yes'
});
- push3.end('3');
+ push3.end(new Buffer([0x8b, 0x00, 0x80, 0x33, 0x0a, 0x03])); // '3\n'
content = '0';
}
else if (u.pathname === "/big") {
content = generateContent(128 * 1024);
var hash = crypto.createHash('md5');
hash.update(content);