3 <script src="../inspector-test.js"></script>
4 <script src="../network-test.js"></script>
7 function loadFirstImage() {
8 if (!window.internals) {
9 console.log("This test can not be run as window.internals is not available.");
12 // Make sure there is no enough space to save content in resource agent's storage.
13 internals.setInspectorResourcesDataSizeLimits(100, 100);
16 image.onload = firstImageLoaded;
17 document.body.appendChild(image);
18 image.src = "resources/resource.php?type=image&random=1&size=400";
21 function firstImageLoaded()
23 console.log("Done1.");
26 function loadSecondImage() {
27 image.onload = secondImageLoaded;
28 image.src = "resources/resource.php?type=image&random=1&size=200";
31 function secondImageLoaded()
33 console.log("Done2.");
39 InspectorTest.recordNetwork();
40 InspectorTest.addConsoleSniffer(step2);
41 InspectorTest.evaluateInPage("loadFirstImage()");
45 imageRequest = InspectorTest.networkRequests().pop();
46 imageRequest.requestContent(step3);
51 InspectorTest.addResult(imageRequest.url);
52 InspectorTest.addResult("request.type: " + imageRequest.resourceType());
53 InspectorTest.addResult("request.content.length after requesting content: " + imageRequest.content.length);
54 InspectorTest.assertTrue(imageRequest.content.length > 0, "No content before destroying CachedResource.");
56 InspectorTest.addResult("Releasing cached resource.");
57 // Loading another image to the same image element so that the original image cached resource is released.
58 InspectorTest.addConsoleSniffer(step4);
59 InspectorTest.evaluateInPage("loadSecondImage()");
64 // Disable-enable cache to force MemoryCache::evictResources().
65 NetworkAgent.setCacheDisabled(true, step5);
70 // In Oilpan, Resource objects are not destructed until GC.
71 InspectorTest.evaluateInPage("GCController.collectAll()");
72 NetworkAgent.setCacheDisabled(false, step6);
77 // Re-request content now that CachedResource should have been destroyed.
78 delete imageRequest._content;
79 imageRequest.requestContent(step7);
84 InspectorTest.addResult("request.content after requesting content: " + imageRequest.content);
85 InspectorTest.assertTrue(!imageRequest.content, "Content available after CachedResource was destroyed.");
86 InspectorTest.resetInspectorResourcesData(step8);
91 InspectorTest.completeTest();
96 <body onload="runTest()">
97 <p>Tests cached resource content is discarded when cached resource is destroyed if content size is too big for the resource agent's data storage.</p>
98 <a href="https://bugs.webkit.org/show_bug.cgi?id=92108">Bug 92108</a>