[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [tor-browser] 281/311: Bug 1752270 - Test for receiving 408 response r=necko-reviewers, kershaw a=dmeehan



This is an automated email from the git hooks/post-receive script.

pierov pushed a commit to branch geckoview-99.0.1-11.0-1
in repository tor-browser.

commit bee2f44cc4ef8df7faf0d62905b046ac9868c7ee
Author: Dragana Damjanovic <dd.mozilla@xxxxxxxxx>
AuthorDate: Tue Mar 22 21:12:20 2022 +0000

    Bug 1752270 - Test for receiving 408 response r=necko-reviewers,kershaw a=dmeehan
    
    With H1, the connection is restarted.
    With H2 and H3, the channel gets NS_ERROR_ABORT from Http2Session::Shutdown
    
    Differential Revision: https://phabricator.services.mozilla.com/D139395
---
 netwerk/test/unit/test_http_408_retry.js | 63 ++++++++++++++++++++++++++++++++
 netwerk/test/unit/xpcshell.ini           |  2 +
 2 files changed, 65 insertions(+)

diff --git a/netwerk/test/unit/test_http_408_retry.js b/netwerk/test/unit/test_http_408_retry.js
new file mode 100644
index 0000000000000..421d3a52665e9
--- /dev/null
+++ b/netwerk/test/unit/test_http_408_retry.js
@@ -0,0 +1,63 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+"use strict";
+
+async function loadURL(uri, flags) {
+  let chan = NetUtil.newChannel({
+    uri,
+    loadUsingSystemPrincipal: true,
+  }).QueryInterface(Ci.nsIHttpChannel);
+  chan.loadFlags = Ci.nsIChannel.LOAD_INITIAL_DOCUMENT_URI;
+
+  return new Promise(resolve => {
+    chan.asyncOpen(
+      new ChannelListener((req, buff) => resolve({ req, buff }), null, flags)
+    );
+  });
+}
+
+add_task(async function test() {
+  let certdb = Cc["@mozilla.org/security/x509certdb;1"].getService(
+    Ci.nsIX509CertDB
+  );
+  addCertFromFile(certdb, "http2-ca.pem", "CTu,u,u");
+
+  async function check408retry(server) {
+    info(`Testing ${server.constructor.name}`);
+    await server.execute(`global.server_name = "${server.constructor.name}";`);
+    await server.registerPathHandler("/test", (req, resp) => {
+      let oldSock = global.socket;
+      global.socket = resp.socket;
+      if (global.socket == oldSock) {
+        resp.writeHead(408);
+        resp.end("stuff");
+        return;
+      }
+      resp.writeHead(200);
+      resp.end(global.server_name);
+    });
+
+    async function load() {
+      let { req, buff } = await loadURL(
+        `${server.origin()}/test`,
+        CL_ALLOW_UNKNOWN_CL
+      );
+      equal(req.status, Cr.NS_OK);
+      equal(req.QueryInterface(Ci.nsIHttpChannel).responseStatus, 200);
+      equal(buff, server.constructor.name);
+      equal(
+        req.QueryInterface(Ci.nsIHttpChannel).protocolVersion,
+        server.constructor.name == "NodeHTTP2Server" ? "h2" : "http/1.1"
+      );
+    }
+
+    info("first load");
+    await load();
+    info("second load");
+    await load();
+  }
+
+  await with_node_servers([NodeHTTPServer, NodeHTTPSServer], check408retry);
+});
diff --git a/netwerk/test/unit/xpcshell.ini b/netwerk/test/unit/xpcshell.ini
index 4240eeb44cf83..33483cbd6522d 100644
--- a/netwerk/test/unit/xpcshell.ini
+++ b/netwerk/test/unit/xpcshell.ini
@@ -605,3 +605,5 @@ skip-if =
   os == "android"
   !socketprocess_networking
 run-sequentially = node server exceptions dont replay well
+[test_http_408_retry.js]
+skip-if = os == "android" # head_servers.js isn't aware of Android hosts yet

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits