blob: 02c2a6e2cf273dea2dfc9689f24438ce14bb088a [file] [log] [blame]
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src="../resources/inspector-test.js"></script>
<script>
function test()
{
let suite = InspectorTest.createAsyncSuite("Network.interceptRequestWithResponse");
suite.addTestCase({
name: "Network.interceptRequest.Subresource with response",
description: "Subresource uses request interception with response",
async test() {
let localResourceOverride = WI.LocalResourceOverride.create("http://127.0.0.1:8000/inspector/network/resources/override.js", WI.LocalResourceOverride.InterceptType.ResponseSkippingNetwork, {
responseMIMEType: "text/javascript",
responseContent: `alert("OVERRIDDEN override.js TEXT"); TestPage.dispatchEventToFrontend("OverrideContentDidLoad");`,
responseBase64Encoded: false,
responseStatus: 200,
responseStatusText: "OK",
responseHeaders: {},
});
WI.networkManager.addLocalResourceOverride(localResourceOverride);
await Promise.all([
InspectorTest.awaitEvent("OverrideContentDidLoad"),
InspectorTest.reloadPage({ignoreCache: false, revalidateAllResources: true}),
]);
WI.networkManager.removeLocalResourceOverride(localResourceOverride);
}
});
suite.runTestCasesAndFinish();
}
</script>
</head>
<body onload="runTest()">
<p>Test request interception with response for the subresource load.</p>
<script src="resources/override.js"></script>
</body>
</html>