Bug 1281278 - test coverage for h2 push with brotli r=nwgh draft
authorPatrick McManus <mcmanus@ducksong.com>
Thu, 06 Apr 2017 13:40:26 -0400
changeset 558415 23f321b38bcd2d48e8337d1a26ad232294c9d225
parent 557282 facaf90aeaaf6d7cf5e2966f9f918319536bddea
child 623207 5bd9acc9d59a073664d956995f1524d9e804a119
push id52886
push userbmo:mcmanus@ducksong.com
push dateFri, 07 Apr 2017 16:32:41 +0000
reviewersnwgh
bugs1281278
milestone55.0a1
Bug 1281278 - test coverage for h2 push with brotli r=nwgh MozReview-Commit-ID: 84LZRLsefJD
netwerk/test/unit/test_http2.js
testing/xpcshell/moz-http2/moz-http2.js
--- 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);