Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(888)

Side by Side Diff: chrome/test/data/extensions/api_test/webrequest/test_complex.html

Issue 8775046: Convert another batch of extension tests to manifest_version 2 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 <script src="framework.js"> 1 <!--
2 </script> 2 * Copyright (c) 2011 The Chromium Authors. All rights reserved. Use of this
3 <script> 3 * source code is governed by a BSD-style license that can be found in the
4 function getURLHttpXHR() { 4 * LICENSE file.
5 return getServerURL('files/extensions/api_test/webrequest/xhr/a.html'); 5 -->
6 } 6 <script src="framework.js"></script>
7 function getURLHttpXHRData() { 7 <script src="test_complex.js"></script>
8 return getServerURL('files/extensions/api_test/webrequest/xhr/data.json');
9 }
10
11 runTests([
12 // Navigates to a page with subresources.
13 function complexLoad() {
14 expect(
15 [ // events
16 { label: "a.html-onBeforeRequest",
17 event: "onBeforeRequest",
18 details: {
19 type: "main_frame",
20 url: getURL("complexLoad/a.html"),
21 frameUrl: getURL("complexLoad/a.html")
22 }
23 },
24 { label: "b.html-onBeforeRequest",
25 event: "onBeforeRequest",
26 details: {
27 type: "sub_frame",
28 url: getURL("complexLoad/b.html"),
29 frameUrl: getURL("complexLoad/b.html"),
30 frameId: 1,
31 parentFrameId: 0,
32 }
33 },
34 { label: "b.jpg-onBeforeRequest",
35 event: "onBeforeRequest",
36 details: {
37 type: "image",
38 url: getURL("complexLoad/b.jpg"),
39 frameUrl: getURL("complexLoad/b.html"),
40 frameId: 1,
41 parentFrameId: 0,
42 }
43 },
44 { label: "a.html-onResponseStarted",
45 event: "onResponseStarted",
46 details: {
47 type: "main_frame",
48 url: getURL("complexLoad/a.html"),
49 fromCache: false,
50 statusCode: 200,
51 statusLine: "HTTP/1.1 200 OK",
52 // Request to chrome-extension:// url has no IP.
53 }
54 },
55 { label: "b.html-onResponseStarted",
56 event: "onResponseStarted",
57 details: {
58 type: "sub_frame",
59 url: getURL("complexLoad/b.html"),
60 fromCache: false,
61 statusCode: 200,
62 statusLine: "HTTP/1.1 200 OK",
63 frameId: 1,
64 parentFrameId: 0,
65 // Request to chrome-extension:// url has no IP.
66 }
67 },
68 { label: "b.jpg-onResponseStarted",
69 event: "onResponseStarted",
70 details: {
71 type: "image",
72 url: getURL("complexLoad/b.jpg"),
73 fromCache: false,
74 statusCode: 200,
75 statusLine: "HTTP/1.1 200 OK",
76 frameId: 1,
77 parentFrameId: 0,
78 // Request to chrome-extension:// url has no IP.
79 }
80 },
81 { label: "a.html-onCompleted",
82 event: "onCompleted",
83 details: {
84 type: "main_frame",
85 url: getURL("complexLoad/a.html"),
86 fromCache: false,
87 statusCode: 200,
88 statusLine: "HTTP/1.1 200 OK",
89 // Request to chrome-extension:// url has no IP.
90 }
91 },
92 { label: "b.html-onCompleted",
93 event: "onCompleted",
94 details: {
95 type: "sub_frame",
96 url: getURL("complexLoad/b.html"),
97 fromCache: false,
98 statusCode: 200,
99 statusLine: "HTTP/1.1 200 OK",
100 frameId: 1,
101 parentFrameId: 0,
102 // Request to chrome-extension:// url has no IP.
103 }
104 },
105 { label: "b.jpg-onCompleted",
106 event: "onCompleted",
107 details: {
108 type: "image",
109 url: getURL("complexLoad/b.jpg"),
110 fromCache: false,
111 statusCode: 200,
112 statusLine: "HTTP/1.1 200 OK",
113 frameId: 1,
114 parentFrameId: 0,
115 // Request to chrome-extension:// url has no IP.
116 }
117 },
118 ],
119 [ // event order
120 ["a.html-onBeforeRequest", "a.html-onResponseStarted",
121 "b.html-onBeforeRequest", "b.html-onResponseStarted",
122 "b.jpg-onBeforeRequest", "b.jpg-onResponseStarted" ],
123 ["a.html-onResponseStarted", "a.html-onCompleted"],
124 ["b.html-onResponseStarted", "b.html-onCompleted"],
125 ["b.jpg-onResponseStarted", "b.jpg-onCompleted"] ]
126 );
127 navigateAndWait(getURL("complexLoad/a.html"));
128 },
129
130 // Loads several resources, but should only see the complexLoad main_frame
131 // and image due to the filter.
132 function complexLoadFiltered() {
133 expect(
134 [ // events
135 { label: "a-onBeforeRequest",
136 event: "onBeforeRequest",
137 details: {
138 type: "main_frame",
139 url: getURL("complexLoad/a.html"),
140 frameUrl: getURL("complexLoad/a.html")
141 }
142 },
143 { label: "b-onBeforeRequest",
144 event: "onBeforeRequest",
145 details: {
146 type: "image",
147 url: getURL("complexLoad/b.jpg"),
148 // As we do not listed to sub-frames we do not know the frameUrl.
149 frameUrl: "unknown frame URL",
150 frameId: 1,
151 parentFrameId: 0,
152 }
153 },
154 { label: "a-onResponseStarted",
155 event: "onResponseStarted",
156 details: {
157 type: "main_frame",
158 url: getURL("complexLoad/a.html"),
159 fromCache: false,
160 statusCode: 200,
161 statusLine: "HTTP/1.1 200 OK",
162 // Request to chrome-extension:// url has no IP.
163 }
164 },
165 { label: "b-onResponseStarted",
166 event: "onResponseStarted",
167 details: {
168 type: "image",
169 url: getURL("complexLoad/b.jpg"),
170 fromCache: false,
171 statusCode: 200,
172 statusLine: "HTTP/1.1 200 OK",
173 frameId: 1,
174 parentFrameId: 0,
175 // Request to chrome-extension:// url has no IP.
176 }
177 },
178 { label: "a-onCompleted",
179 event: "onCompleted",
180 details: {
181 type: "main_frame",
182 url: getURL("complexLoad/a.html"),
183 fromCache: false,
184 statusCode: 200,
185 statusLine: "HTTP/1.1 200 OK",
186 // Request to chrome-extension:// url has no IP.
187 }
188 },
189 { label: "b-onCompleted",
190 event: "onCompleted",
191 details: {
192 type: "image",
193 url: getURL("complexLoad/b.jpg"),
194 fromCache: false,
195 statusCode: 200,
196 statusLine: "HTTP/1.1 200 OK",
197 frameId: 1,
198 parentFrameId: 0,
199 // Request to chrome-extension:// url has no IP.
200 }
201 },
202 ],
203 [ // event order
204 ["a-onBeforeRequest", "a-onResponseStarted",
205 "b-onBeforeRequest", "b-onResponseStarted"],
206 ["a-onResponseStarted", "a-onCompleted"],
207 ["b-onResponseStarted", "b-onCompleted"] ],
208 { // filters
209 urls: [getURL("complexLoad/*")],
210 types: ["main_frame", "image"],
211 tabId: tabId
212 });
213 chrome.tabs.create({ url: getURL("simpleLoad/a.html") },
214 function(newTab) {
215 chrome.tabs.remove(newTab.id);
216 navigateAndWait(getURL("complexLoad/a.html"));
217 });
218 },
219
220 // Navigates to a page to generates an XHR.
221 function xhrLoad() {
222 expect(
223 [ // events
224 { label: "onBeforeRequest-1",
225 event: "onBeforeRequest",
226 details: {
227 type: "main_frame",
228 url: getURLHttpXHR(),
229 frameUrl: getURLHttpXHR()
230 }
231 },
232 { label: "onBeforeSendHeaders-1",
233 event: "onBeforeSendHeaders",
234 details: {
235 type: "main_frame",
236 url: getURLHttpXHR(),
237 }
238 },
239 { label: "onSendHeaders-1",
240 event: "onSendHeaders",
241 details: {
242 type: "main_frame",
243 url: getURLHttpXHR(),
244 }
245 },
246 { label: "onHeadersReceived-1",
247 event: "onHeadersReceived",
248 details: {
249 type: "main_frame",
250 url: getURLHttpXHR(),
251 statusLine: "HTTP/1.0 200 OK",
252 }
253 },
254 { label: "onResponseStarted-1",
255 event: "onResponseStarted",
256 details: {
257 type: "main_frame",
258 url: getURLHttpXHR(),
259 statusCode: 200,
260 ip: "127.0.0.1",
261 fromCache: false,
262 statusLine: "HTTP/1.0 200 OK",
263 }
264 },
265 { label: "onCompleted-1",
266 event: "onCompleted",
267 details: {
268 type: "main_frame",
269 url: getURLHttpXHR(),
270 statusCode: 200,
271 ip: "127.0.0.1",
272 fromCache: false,
273 statusLine: "HTTP/1.0 200 OK",
274 }
275 },
276 { label: "onBeforeRequest-2",
277 event: "onBeforeRequest",
278 details: {
279 type: "xmlhttprequest",
280 url: getURLHttpXHRData(),
281 frameUrl: getURLHttpXHR()
282 }
283 },
284 { label: "onBeforeSendHeaders-2",
285 event: "onBeforeSendHeaders",
286 details: {
287 type: "xmlhttprequest",
288 url: getURLHttpXHRData(),
289 }
290 },
291 { label: "onSendHeaders-2",
292 event: "onSendHeaders",
293 details: {
294 type: "xmlhttprequest",
295 url: getURLHttpXHRData(),
296 }
297 },
298 { label: "onHeadersReceived-2",
299 event: "onHeadersReceived",
300 details: {
301 type: "xmlhttprequest",
302 url: getURLHttpXHRData(),
303 statusLine: "HTTP/1.0 200 OK",
304 }
305 },
306 { label: "onResponseStarted-2",
307 event: "onResponseStarted",
308 details: {
309 type: "xmlhttprequest",
310 url: getURLHttpXHRData(),
311 statusCode: 200,
312 ip: "127.0.0.1",
313 fromCache: false,
314 statusLine: "HTTP/1.0 200 OK",
315 }
316 },
317 { label: "onCompleted-2",
318 event: "onCompleted",
319 details: {
320 type: "xmlhttprequest",
321 url: getURLHttpXHRData(),
322 statusCode: 200,
323 ip: "127.0.0.1",
324 fromCache: false,
325 statusLine: "HTTP/1.0 200 OK",
326 }
327 }
328 ],
329 [ // event order
330 ["onBeforeRequest-1", "onBeforeSendHeaders-1", "onSendHeaders-1",
331 "onHeadersReceived-1", "onResponseStarted-1", "onCompleted-1",
332 "onBeforeRequest-2", "onBeforeSendHeaders-2", "onSendHeaders-2",
333 "onHeadersReceived-2", "onResponseStarted-2", "onCompleted-2"] ],
334 {}, []);
335 navigateAndWait(getURLHttpXHR());
336 },
337 ]);
338 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698