summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/fetch/api/request/request-constructor-init-body-override.any.js
blob: 27bb991871a8a183436ab14613147aba6fc8c231 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
promise_test(async function () {
    const req1 = new Request("https://example.com/", {
        body: "req1",
        method: "POST",
    });

    const text1 = await req1.text();
    assert_equals(
        text1,
        "req1",
        "The body of the first request should be 'req1'."
    );

    const req2 = new Request(req1, { body: "req2" });
    const bodyText = await req2.text();
    assert_equals(
        bodyText,
        "req2",
        "The body of the second request should be overridden to 'req2'."
    );
}, "Check that the body of a new request can be overridden when created from an existing Request object");