OLD | NEW |
1 <html> | 1 <html> |
2 <head> | 2 <head> |
3 <script src="../inspector-test.js"></script> | 3 <script src="../inspector-test.js"></script> |
4 <script src="../resources-test.js"></script> | 4 <script src="../resources-test.js"></script> |
5 <script src="resource-tree-test.js"></script> | 5 <script src="resource-tree-test.js"></script> |
6 <script> | 6 <script> |
7 function loadStylesheet() | 7 function loadStylesheet() |
8 { | 8 { |
9 var styleElement = document.createElement("link"); | 9 var styleElement = document.createElement("link"); |
10 styleElement.rel = "stylesheet"; | 10 styleElement.rel = "stylesheet"; |
11 styleElement.href = "resources/styles-initial.css"; | 11 styleElement.href = "resources/styles-initial.css"; |
12 document.head.appendChild(styleElement); | 12 document.head.appendChild(styleElement); |
13 } | 13 } |
14 | 14 |
15 function test() | 15 function test() |
16 { | 16 { |
17 InspectorTest.addSniffer(WebInspector.ResourceTreeFrame.prototype, "_addRequ
est", requestAdded, true); | 17 InspectorTest.addSniffer(WebInspector.ResourceTreeFrame.prototype, "_addRequ
est", requestAdded, true); |
18 InspectorTest.addSniffer(InspectorTest.PageAgent, "getResourceContent", page
AgentGetResourceContentCalled, true); | 18 InspectorTest.addSniffer(InspectorTest.PageAgent, "getResourceContent", page
AgentGetResourceContentCalled, true); |
19 InspectorTest.evaluateInPage("loadStylesheet()"); | 19 InspectorTest.evaluateInPage("loadStylesheet()"); |
20 var contentWasRequested = false; | 20 var contentWasRequested = false; |
21 var resource; | 21 var resource; |
22 | 22 |
23 function requestAdded(request) | 23 function requestAdded(request) |
24 { | 24 { |
25 if (request.url.indexOf("styles-initial") === -1) | 25 if (request.url.indexOf("styles-initial") === -1) |
26 return; | 26 return; |
27 resource = InspectorTest.resourceMatchingURL("styles-initial"); | 27 resource = InspectorTest.resourceMatchingURL("styles-initial"); |
28 if (!resource || !resource.request || contentWasRequested) | 28 if (!resource || !resource.request || contentWasRequested) { |
29 return; | 29 InspectorTest.addResult("Cannot find resource"); |
| 30 InspectorTest.completeTest(); |
| 31 } |
30 resource.requestContent(contentLoaded); | 32 resource.requestContent(contentLoaded); |
31 contentWasRequested = true; | 33 contentWasRequested = true; |
32 } | 34 } |
33 | 35 |
34 function pageAgentGetResourceContentCalled() | 36 function pageAgentGetResourceContentCalled() |
35 { | 37 { |
36 InspectorTest.assertTrue(resource.request.finished); | 38 if (!resource.request.finished) { |
| 39 InspectorTest.addResult("Request must be finished before calling get
ResourceContent"); |
| 40 InspectorTest.completeTest(); |
| 41 } |
37 } | 42 } |
38 | 43 |
39 function contentLoaded(content) | 44 function contentLoaded(content) |
40 { | 45 { |
41 InspectorTest.addResult("Resource url: " + resource.url); | 46 InspectorTest.addResult("Resource url: " + resource.url); |
42 InspectorTest.addResult("Resource content: " + content); | 47 InspectorTest.addResult("Resource content: " + content); |
43 InspectorTest.completeTest(); | 48 InspectorTest.completeTest(); |
44 } | 49 } |
45 } | 50 } |
46 </script> | 51 </script> |
47 </head> | 52 </head> |
48 <body onload="runTest()"> | 53 <body onload="runTest()"> |
49 <p>Tests resource content is correctly loaded if Resource.requestContent was cal
led before network request was finished.</p> | 54 <p>Tests resource content is correctly loaded if Resource.requestContent was cal
led before network request was finished.</p> |
50 <a href="https://bugs.webkit.org/show_bug.cgi?id=90153">Bug 90153</a> | 55 <a href="https://bugs.webkit.org/show_bug.cgi?id=90153">Bug 90153</a> |
51 </body> | 56 </body> |
52 </html> | 57 </html> |
OLD | NEW |