Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / http / tests / inspector / network / network-disable-cache-memory.html
1 <html>
2 <head>
3 <script src="../inspector-test.js"></script>
4 <script src="../network-test.js"></script>
5 <script>
6 function scheduleScriptLoad() {
7     window.setTimeout(loadScript, 0);
8 }
9
10 function loadScript() {
11     var script = document.createElement("script");
12     script.type = "text/javascript";
13     script.src = "resources/random-script.php";
14     document.head.appendChild(script);
15 }
16
17 function test()
18 {
19     var content1;
20     var content2;
21     var content3;
22
23     function loadScriptAndGetContent(callback)
24     {
25         InspectorTest.recordNetwork();
26         InspectorTest.addConsoleSniffer(scriptLoaded);
27         InspectorTest.evaluateInPage("scheduleScriptLoad()");
28
29         function scriptLoaded()
30         {
31             var request = InspectorTest.networkRequests().pop();
32             request.requestContent(contentLoaded);
33         }
34
35         function contentLoaded()
36         {
37             var request = InspectorTest.networkRequests().pop();
38             callback(request.content);
39         }
40     }
41
42     loadScriptAndGetContent(step1);
43
44     function step1(content)
45     {
46         content1 = content;
47         InspectorTest.reloadPage(step2);
48     }
49
50     function step2(msg)
51     {
52         loadScriptAndGetContent(step3);
53     }
54
55     function step3(content)
56     {
57         content2 = content;
58         NetworkAgent.setCacheDisabled(true, step4);
59     }
60
61     function step4(msg)
62     {
63         InspectorTest.reloadPage(step5);
64     }
65
66     function step5(msg)
67     {
68         loadScriptAndGetContent(step6);
69     }
70
71     function step6(content)
72     {
73         content3 = content;
74
75         InspectorTest.assertTrue(content1 === content2, "First and second scripts should be equal.");
76         InspectorTest.assertTrue(content2 !== content3, "Second and third scripts should differ.");
77         NetworkAgent.setCacheDisabled(false, step7);
78     }
79
80     function step7(msg)
81     {
82         InspectorTest.completeTest();
83     }
84 }
85 </script>
86 </head>
87 <body onload="runTest()">
88     <p>Tests disabling cache from inspector.</p>
89 </body>
90 </html>
91