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

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

Issue 11414230: Declarative Web Request: firstPartyForCookiesUrl (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added event order Created 8 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 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 var onRequest = chrome.declarativeWebRequest.onRequest; 5 var onRequest = chrome.declarativeWebRequest.onRequest;
6 var AddResponseHeader = 6 var AddResponseHeader =
7 chrome.declarativeWebRequest.AddResponseHeader; 7 chrome.declarativeWebRequest.AddResponseHeader;
8 var RequestMatcher = chrome.declarativeWebRequest.RequestMatcher; 8 var RequestMatcher = chrome.declarativeWebRequest.RequestMatcher;
9 var CancelRequest = chrome.declarativeWebRequest.CancelRequest; 9 var CancelRequest = chrome.declarativeWebRequest.CancelRequest;
10 var RedirectByRegEx = chrome.declarativeWebRequest.RedirectByRegEx; 10 var RedirectByRegEx = chrome.declarativeWebRequest.RedirectByRegEx;
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 }, 270 },
271 {'priority': 1, 271 {'priority': 1,
272 'conditions': [new RequestMatcher({})], 272 'conditions': [new RequestMatcher({})],
273 'actions': [new chrome.declarativeWebRequest.CancelRequest()] 273 'actions': [new chrome.declarativeWebRequest.CancelRequest()]
274 }, 274 },
275 ], 275 ],
276 function() {navigateAndWait(getURLThirdParty());} 276 function() {navigateAndWait(getURLThirdParty());}
277 ); 277 );
278 }, 278 },
279 279
280 // Tests "firstPartyForCookiesUrl" by using it to override a cancelling rule.
281 function testFirstPartyForCookiesUrl() {
282 ignoreUnexpected = false;
283 expect(
Jeffrey Yasskin 2012/12/18 03:09:58 Where is expect() defined? What do its parameters
vabr (Chromium) 2013/01/21 10:57:48 The function expect is part of the test framework:
284 [
285 { label: "onBeforeRequest",
286 event: "onBeforeRequest",
287 details: {
288 url: getURLThirdParty(),
289 frameUrl: getURLThirdParty()
290 }
291 },
292 { label: "onBeforeSendHeaders",
Jeffrey Yasskin 2012/12/18 03:09:58 If the label is the same as the event in almost al
vabr (Chromium) 2013/01/21 10:57:48 I can understand your concerns, but I believe thos
293 event: "onBeforeSendHeaders",
294 details: {url: getURLThirdParty()}
295 },
296 { label: "onSendHeaders",
297 event: "onSendHeaders",
298 details: {url: getURLThirdParty()}
299 },
300 { label: "onHeadersReceived",
301 event: "onHeadersReceived",
302 details: {
303 url: getURLThirdParty(),
304 statusLine: "HTTP/1.0 200 OK"
305 }
306 },
307 { label: "onResponseStarted",
308 event: "onResponseStarted",
309 details: {
310 url: getURLThirdParty(),
311 fromCache: false,
312 ip: "127.0.0.1",
313 statusCode: 200,
314 statusLine: "HTTP/1.0 200 OK"
315 }
316 },
317 { label: "onCompleted",
318 event: "onCompleted",
319 details: {
320 fromCache: false,
321 ip: "127.0.0.1",
322 url: getURLThirdParty(),
323 statusCode: 200,
324 statusLine: "HTTP/1.0 200 OK"
325 }
326 },
327 { label: "img-onBeforeRequest",
328 event: "onBeforeRequest",
329 details: {
330 type: "image",
331 url: "http://non_existing_third_party.com/image.png",
332 frameUrl: getURLThirdParty()
333 }
334 },
335 { label: "img-onBeforeSendHeaders",
336 event: "onBeforeSendHeaders",
337 details: {
338 type: "image",
339 url: "http://non_existing_third_party.com/image.png",
340 }
341 },
342 { label: "img-onErrorOccurred",
343 event: "onErrorOccurred",
344 details: {
345 url: "http://non_existing_third_party.com/image.png",
346 type: "image",
347 fromCache: false,
348 error: "net::ERR_BLOCKED_BY_CLIENT"
349 }
350 },
351 ],
352 [ ["onBeforeRequest", "onBeforeSendHeaders", "onSendHeaders",
353 "onHeadersReceived", "onResponseStarted", "onCompleted"],
354 ["img-onBeforeRequest", "img-onBeforeSendHeaders",
355 "img-onErrorOccurred"] ]);
356 onRequest.addRules(
357 [ // This rule cancels the request with a 3rd party URL just before it is
358 // sent. This is necessary, because sending it would generate different
359 // HTTP 4xx codes on different platforms, making it impossible to
360 // present a single list of expected events.
361 {'priority': 3,
362 'conditions': [new RequestMatcher({
363 'url': { 'hostEquals': 'non_existing_third_party.com' },
364 'stages': ["onBeforeSendHeaders"]
365 })],
366 'actions': [new chrome.declarativeWebRequest.CancelRequest()]
367 },
368 {'priority': 2,
369 'conditions': [
370 new RequestMatcher({
371 firstPartyForCookiesUrl: {
372 hostEquals: testServer
373 }
374 })
375 ],
376 'actions': [
377 new chrome.declarativeWebRequest.IgnoreRules({
378 lowerPriorityThan: 2 })
379 ]
380 },
381 // This rule cancels everyhting, and sooner that the very first rule
Jeffrey Yasskin 2012/12/18 03:09:58 sp: everyhting. s/that/than/
vabr (Chromium) 2013/01/21 10:57:48 Done.
382 // would. The test is reduced to making sure this (3rd) rule was ignored
383 // as a consequence of the 2nd rule.
384 {'priority': 1,
385 'conditions': [new RequestMatcher({
386 'stages': ["onBeforeRequest"]
387 })],
388 'actions': [new chrome.declarativeWebRequest.CancelRequest()]
389 },
390 ],
391 function() {navigateAndWait(getURLThirdParty());}
392 );
393 },
394
280 function testRedirectRequest() { 395 function testRedirectRequest() {
281 ignoreUnexpected = true; 396 ignoreUnexpected = true;
282 expect( 397 expect(
283 [ 398 [
284 { label: "onBeforeRequest-a", 399 { label: "onBeforeRequest-a",
285 event: "onBeforeRequest", 400 event: "onBeforeRequest",
286 details: { 401 details: {
287 type: "main_frame", 402 type: "main_frame",
288 url: getURLHttpComplex(), 403 url: getURLHttpComplex(),
289 frameUrl: getURLHttpComplex() 404 frameUrl: getURLHttpComplex()
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after
694 }, 809 },
695 'requestHeaders': [{ nameContains: "" }], 810 'requestHeaders': [{ nameContains: "" }],
696 'excludeRequestHeaders': [{ valueContains: ["", "value123"] }] 811 'excludeRequestHeaders': [{ valueContains: ["", "value123"] }]
697 })], 812 })],
698 'actions': [new CancelRequest()]} 813 'actions': [new CancelRequest()]}
699 ], 814 ],
700 function() {navigateAndWait(getURLHttpSimple());} 815 function() {navigateAndWait(getURLHttpSimple());}
701 ); 816 );
702 }, 817 },
703 ]); 818 ]);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698