tor-browser

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

request-constructor-init-body-override.any.js (1103B)


      1 promise_test(async function () {
      2    const req1 = new Request("https://example.com/", {
      3        body: "req1",
      4        method: "POST",
      5    });
      6 
      7    const text1 = await req1.text();
      8    assert_equals(
      9        text1,
     10        "req1",
     11        "The body of the first request should be 'req1'."
     12    );
     13 
     14    const req2 = new Request(req1, { body: "req2" });
     15    const bodyText = await req2.text();
     16    assert_equals(
     17        bodyText,
     18        "req2",
     19        "The body of the second request should be overridden to 'req2'."
     20    );
     21 
     22 }, "Check that the body of a new request can be overridden when created from an existing Request object");
     23 
     24 promise_test(async function () {
     25    const req1 = new Request("https://example.com/", {
     26        body: "req1",
     27        method: "POST",
     28    });
     29 
     30    const req2 = new Request("https://example.com/", req1);
     31    const bodyText = await req2.text();
     32    assert_equals(
     33        bodyText,
     34        "req1",
     35        "The body of the second request should be the same as the first."
     36    );
     37 }, "Check that the body of a new request can be duplicated from an existing Request object");