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> | 4 <script> |
5 function sendSyncScriptRequest() | 5 function sendSyncScriptRequest() |
6 { | 6 { |
7 var iframe = document.createElement("iframe"); | 7 var iframe = document.createElement("iframe"); |
8 document.body.appendChild(iframe); | 8 document.body.appendChild(iframe); |
9 iframe.contentDocument.write('<html><body><script src="http://localhost:8000
/inspector/network/resources/empty-script.js?sync"></s' + 'cript>;</body></html>
'); | 9 iframe.contentDocument.write('<html><body><script src="http://localhost:8000
/inspector/network/resources/empty-script.js?sync"></s' + 'cript>;</body></html>
'); |
10 } | 10 } |
(...skipping 15 matching lines...) Expand all Loading... |
26 function sendXHRAsync() | 26 function sendXHRAsync() |
27 { | 27 { |
28 var xhr = new XMLHttpRequest(); | 28 var xhr = new XMLHttpRequest(); |
29 xhr.open("GET", "resources/empty.html?xhr-async"); | 29 xhr.open("GET", "resources/empty.html?xhr-async"); |
30 xhr.send(); | 30 xhr.send(); |
31 } | 31 } |
32 | 32 |
33 function sendImageRequest() | 33 function sendImageRequest() |
34 { | 34 { |
35 var img = document.createElement("img"); | 35 var img = document.createElement("img"); |
36 img.src = "resources/abe.png?image"; | 36 img.src = "resources/abe.png"; |
37 document.body.appendChild(img); | 37 document.body.appendChild(img); |
38 } | 38 } |
39 | 39 |
40 function sendStyleRequest() | 40 function sendStyleRequest() |
41 { | 41 { |
42 var link = document.createElement("link"); | 42 var link = document.createElement("link"); |
43 link.rel = "stylesheet"; | 43 link.rel = "stylesheet"; |
44 link.href = "resources/style.css?style"; | 44 link.href = "resources/style.css"; |
45 document.head.appendChild(link); | 45 document.head.appendChild(link); |
46 } | 46 } |
47 | 47 |
48 function sendScriptRequestPrecededByImage() | 48 function sendScriptRequestPrecededByImage() |
49 { | 49 { |
50 var iframe = document.createElement("iframe"); | 50 var iframe = document.createElement("iframe"); |
51 document.body.appendChild(iframe); | 51 document.body.appendChild(iframe); |
52 iframe.srcdoc = '<html><body><img src="resources/abe.png?precedingScript">' | 52 iframe.srcdoc = '<html><body><img src="resources/abe.png?preceding">' |
53 + '<script src="http://localhost:8000/inspector/network/resources/empty-
script.js?precededByImage"></s' | 53 + '<script src="http://localhost:8000/inspector/network/resources/empty-
script.js?preceded"></s' |
54 + 'cript>;</body></html>'; | 54 + 'cript>;</body></html>'; |
55 } | 55 } |
56 | 56 |
57 function sendScriptRequestPrecededByPreloadedImage() | 57 function sendScriptRequestPrecededByPreloadedImage() |
58 { | 58 { |
59 var iframe = document.createElement("iframe"); | 59 var iframe = document.createElement("iframe"); |
60 document.body.appendChild(iframe); | 60 document.body.appendChild(iframe); |
61 iframe.srcdoc = '<html><body><link href="resources/abe.png?preloaded" rel=pr
eload as=image>' | 61 iframe.srcdoc = '<html><body><link href="resources/abe.png?precedingPreload"
rel=preload as=image>' |
62 + '<script src="http://localhost:8000/inspector/network/resources/empty-
script.js?precededByPreloadedImage"></s' | 62 + '<script src="http://localhost:8000/inspector/network/resources/empty-
script.js?precededByPreload"></s' |
63 + 'cript><img src="resources/abe.png?followingPreload"></body></html>'; | 63 + 'cript><img src="resources/abe.png?precedingPreload"></body></html>'; |
64 } | |
65 | |
66 function sendScriptsFromDocumentWriteAfterImage() | |
67 { | |
68 var iframe = document.createElement("iframe"); | |
69 document.body.appendChild(iframe); | |
70 iframe.srcdoc = '<html><body><img src="resources/abe.png?precedingDocWrite">
' | |
71 + '<script src="resources/docwrite.js"></s' | |
72 + 'cript></body></html>'; | |
73 } | 64 } |
74 | 65 |
75 function createIFrame() | 66 function createIFrame() |
76 { | 67 { |
77 var iframe = document.createElement("iframe"); | 68 var iframe = document.createElement("iframe"); |
78 iframe.src = "resources/empty.html?iframe"; | 69 iframe.src = "resources/empty.html?iframe"; |
79 document.head.appendChild(iframe); | 70 document.head.appendChild(iframe); |
80 } | 71 } |
81 | 72 |
82 function test() | 73 function test() |
83 { | 74 { |
84 var actions = [ | 75 var actions = [ |
85 {"fn": "sendSyncScriptRequest", "requests": 1}, | 76 "sendSyncScriptRequest", |
86 {"fn": "sendAsyncScriptRequest", "requests": 1}, | 77 "sendAsyncScriptRequest", |
87 {"fn": "sendScriptRequestPrecededByImage", "requests": 2}, | 78 "sendScriptRequestPrecededByImage", |
88 {"fn": "sendScriptRequestPrecededByPreloadedImage", "requests": 3}, | 79 "sendScriptRequestPrecededByPreloadedImage", |
89 {"fn": "sendXHRSync", "requests": 1}, | 80 "sendXHRSync", |
90 {"fn": "sendXHRAsync", "requests": 1}, | 81 "sendXHRAsync", |
91 {"fn": "sendImageRequest", "requests": 1}, | 82 "sendImageRequest", |
92 {"fn": "sendStyleRequest", "requests": 1}, | 83 "sendStyleRequest", |
93 {"fn": "createIFrame", "requests": 1}, | 84 "createIFrame" |
94 {"fn": "sendScriptsFromDocumentWriteAfterImage", "requests": 5}, | |
95 ]; | 85 ]; |
96 InspectorTest.networkManager.addEventListener(SDK.NetworkManager.Events.Requ
estStarted, onRequestStarted); | 86 InspectorTest.networkManager.addEventListener(SDK.NetworkManager.Events.Requ
estStarted, onRequestStarted); |
97 | 87 |
98 var nextAction = 0; | 88 var nextAction = 0; |
99 var expectedRequestCount = 0; | 89 performNextRequest(); |
100 performNextAction(); | |
101 | 90 |
102 function performNextAction() | 91 function performNextRequest() |
103 { | 92 { |
104 if (nextAction >= actions.length) { | 93 if (nextAction >= actions.length) { |
105 InspectorTest.networkManager.removeEventListener(SDK.NetworkManager.
Events.RequestStarted, onRequestStarted); | 94 InspectorTest.networkManager.removeEventListener(SDK.NetworkManager.
Events.RequestStarted, onRequestStarted); |
106 InspectorTest.completeTest(); | 95 InspectorTest.completeTest(); |
107 return; | 96 return; |
108 } | 97 } |
109 InspectorTest.addResult(actions[nextAction].fn); | 98 InspectorTest.evaluateInPage(actions[nextAction++] + "()"); |
110 expectedRequestCount = actions[nextAction].requests; | |
111 InspectorTest.evaluateInPage(actions[nextAction++].fn + "()"); | |
112 } | 99 } |
113 function onRequestStarted(event) | 100 function onRequestStarted(event) |
114 { | 101 { |
115 var request = event.data; | 102 var request = event.data; |
116 InspectorTest.addResult("Request: " + request.name() + " priority: " + r
equest.initialPriority()); | 103 InspectorTest.addResult("Request: " + request.name() + " priority: " + r
equest.initialPriority()); |
117 expectedRequestCount--; | 104 if (request.name().indexOf("preceded") == -1) |
118 if (expectedRequestCount < 1) | 105 performNextRequest(); |
119 performNextAction(); | |
120 } | 106 } |
121 } | 107 } |
122 </script> | 108 </script> |
123 </head> | 109 </head> |
124 <body onload="runTest()"> | 110 <body onload="runTest()"> |
125 <p>Tests resource priorities.</p> | 111 <p>Tests resource priorities.</p> |
126 </body> | 112 </body> |
127 </html> | 113 </html> |
OLD | NEW |