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

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

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

Powered by Google App Engine
This is Rietveld 408576698