blob: ab1fcb228f9659ebb5d104ff10143ae1e78202f5 [file] [log] [blame]
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src="../resources/inspector-test.js"></script>
<script>
function createXHRResource() {
let request = new XMLHttpRequest();
request.open("POST", "resources/", true);
request.send("utf8=👍");
}
function test()
{
let suite = InspectorTest.createAsyncSuite("XHRWithRequestDataEncoding");
suite.addTestCase({
name: "XHRWithRequestDataIsEncodedCorrectly",
description: "XHR with request data is encoded correctly.",
test(resolve, reject) {
InspectorTest.evaluateInPage(`createXHRResource()`);
WI.Frame.singleFireEventListener(WI.Frame.Event.ResourceWasAdded, (event) => {
let resource = event.data.resource;
InspectorTest.expectThat(resource instanceof WI.Resource, "Resource should be created.");
InspectorTest.expectThat(resource.requestData === "utf8=👍", "Request data should have expected content.");
resource.awaitEvent(WI.Resource.Event.LoadingDidFinish)
.then((event) => { InspectorTest.pass("Resource load should finish.") })
.then(resolve, reject);
resource.awaitEvent(WI.Resource.Event.LoadingDidFail)
.then(() => { InspectorTest.fail("Resource should not have failed to load.") })
.then(reject, reject);
});
}
});
suite.runTestCasesAndFinish();
}
</script>
</head>
<body onload="runTest()">
<p>Tests XHR network resource payload is shown with correct encoding.</p>
</body>
</html>