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

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

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

Powered by Google App Engine
This is Rietveld 408576698