blob: e9b5590ecf2786c83cdbc189b6a07fda18e692b0 [file] [log] [blame]
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src="resources/cached-script.js"></script>
<script src="../resources/inspector-test.js"></script>
<script>
function test()
{
let suite = InspectorTest.createAsyncSuite("Resource.ResponseSource.MemoryCache");
function addReloadTestCase({name, description, expression, pattern, ignoreCache, statusCode, responseSource}) {
suite.addTestCase({
name, description,
test(resolve, reject) {
let listener = WI.Resource.addEventListener(WI.Resource.Event.ResponseReceived, (event) => {
let resource = event.target;
if (!pattern.test(resource.url))
return;
InspectorTest.expectThat(resource instanceof WI.Resource, "Resource should exist.");
InspectorTest.expectEqual(resource.statusCode, statusCode, `statusCode should be ${statusCode}`);
InspectorTest.expectEqual(resource.responseSource, responseSource, `responseSource should be ${String(responseSource)}`);
WI.Resource.removeEventListener(WI.Resource.Event.ResponseReceived, listener);
resolve();
});
InspectorTest.reloadPage({ignoreCache, revalidateAllResources: true});
}
});
}
addReloadTestCase({
name: "Resource.ResponseSource.MemoryCache",
description: "Load a resource from the memory cache by reloading this page.",
pattern: /cached-script\.js$/,
ignoreCache: false,
responseSource: WI.Resource.ResponseSource.MemoryCache,
statusCode: 304,
});
suite.runTestCasesAndFinish();
}
</script>
</head>
<body onload="runTest()">
<p>Test for `Resource.ResponseSource.MemoryCache`.</p>
</body>
</html>