blob: 3e71ce6218c8b1b45bb96d64bda41a9898dd69f1 [file] [log] [blame]
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src="../../http/tests/inspector/resources/protocol-test.js"></script>
<script>
function loadSubresource(query) {
fetch(`resources/data.json?error=${query}`)
.catch(() => {});
}
function test()
{
let suite = ProtocolTest.createAsyncSuite("Network.interceptRequestWithError");
InspectorProtocol.sendCommand("Network.enable");
InspectorProtocol.sendCommand("Network.setInterceptionEnabled", {enabled: true});
InspectorProtocol.sendCommand("Network.addInterception", {
url: "resources/data\.json",
stage: /* Network.NetworkStage */ "request",
isRegex: true,
});
function addTestCase({name, errorType}) {
suite.addTestCase({
name,
async test() {
ProtocolTest.log("Triggering load...");
let [requestInterceptedEvent] = await Promise.all([
InspectorProtocol.awaitEvent({event: "Network.requestIntercepted"}),
ProtocolTest.evaluateInPage(`loadSubresource("${errorType}")`),
]);
ProtocolTest.log("Intercepting with error...");
let [loadingDidFailEvent] = await Promise.all([
InspectorProtocol.awaitEvent({event: "Network.loadingFailed"}),
InspectorProtocol.awaitCommand({
method: "Network.interceptRequestWithError",
params: {
requestId: requestInterceptedEvent.params.requestId,
errorType,
},
}),
]);
ProtocolTest.log("FAILURE TEXT: " + loadingDidFailEvent.params.errorText);
},
});
}
addTestCase({
name: "Network.interceptRequestWithError.General",
errorType: /* Network.ResourceErrorType */ "General",
});
addTestCase({
name: "Network.interceptRequestWithError.Access",
errorType: /* Network.ResourceErrorType */ "AccessControl",
});
addTestCase({
name: "Network.interceptRequestWithError.Canceled",
errorType: /* Network.ResourceErrorType */ "Cancellation",
});
addTestCase({
name: "Network.interceptRequestWithError.Timeout",
errorType: /* Network.ResourceErrorType */ "Timeout",
});
suite.runTestCasesAndFinish();
}
</script>
</head>
<body onload="runTest()">
<p>Tests for Network.interceptRequestWithError.</p>
</body>
</html>