tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

status-code.window.js (1703B)


      1 [
      2  {
      3    input: "",
      4    expected: null
      5  },
      6  {
      7    input: "BLAH",
      8    expected: null
      9  },
     10  {
     11    input: "0 OK",
     12    expected: {
     13      status: 0,
     14      statusText: "OK"
     15    }
     16  },
     17  {
     18    input: "1 OK",
     19    expected: {
     20      status: 1,
     21      statusText: "OK"
     22    }
     23  },
     24  {
     25    input: "99 NOT OK",
     26    expected: {
     27      status: 99,
     28      statusText: "NOT OK"
     29    }
     30  },
     31  {
     32    input: "077 77",
     33    expected: {
     34      status: 77,
     35      statusText: "77"
     36    }
     37  },
     38  {
     39    input: "099 HELLO",
     40    expected: {
     41      status: 99,
     42      statusText: "HELLO"
     43    }
     44  },
     45  {
     46    input: "200",
     47    expected: {
     48      status: 200,
     49      statusText: ""
     50    }
     51  },
     52  {
     53    input: "999 DOES IT MATTER",
     54    expected: {
     55      status: 999,
     56      statusText: "DOES IT MATTER"
     57    }
     58  },
     59  {
     60    input: "1000 BOO",
     61    expected: null
     62  },
     63  {
     64    input: "0200 BOO",
     65    expected: null
     66  },
     67  {
     68    input: "65736 NOT 200 OR SOME SUCH",
     69    expected: null
     70  },
     71  {
     72    input: "131072 HI",
     73    expected: null
     74  },
     75  {
     76    input: "-200 TEST",
     77    expected: null
     78  },
     79  {
     80    input: "0xA",
     81    expected: null
     82  },
     83  {
     84    input: "C8",
     85    expected: null
     86  }
     87 ].forEach(({ description, input, expected }) => {
     88  promise_test(async t => {
     89    if (expected !== null) {
     90      const response = await fetch("resources/status-code.py?input=" + input);
     91      assert_equals(response.status, expected.status);
     92      assert_equals(response.statusText, expected.statusText);
     93      assert_equals(response.headers.get("header-parsing"), "is sad");
     94    } else {
     95      await promise_rejects_js(t, TypeError, fetch("resources/status-code.py?input=" + input));
     96    }
     97  }, `HTTP/1.1 ${input} ${expected === null ? "(network error)" : ""}`);
     98 });