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

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

Issue 154473002: Support redirectUrl at onHeadersReceived in WebRequest / DWR API (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix WebRequestRulesRegistrySimpleTest.StageChecker test Created 6 years, 9 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
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 387 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 new RequestMatcher({url: {pathSuffix: "image.png"}})], 398 new RequestMatcher({url: {pathSuffix: "image.png"}})],
399 actions: [new RedirectToTransparentImage()]}, 399 actions: [new RedirectToTransparentImage()]},
400 {conditions: [ 400 {conditions: [
401 new RequestMatcher({url: {pathSuffix: "frame.html"}})], 401 new RequestMatcher({url: {pathSuffix: "frame.html"}})],
402 actions: [new RedirectToEmptyDocument()]}, 402 actions: [new RedirectToEmptyDocument()]},
403 ], 403 ],
404 function() {navigateAndWait(getURLHttpRedirectTest());} 404 function() {navigateAndWait(getURLHttpRedirectTest());}
405 ); 405 );
406 }, 406 },
407 407
408 // Tests that a request is redirected during the onHeadersReceived stage
409 // when the conditions include a RequestMatcher with a contentType.
410 function testRedirectRequestByContentType() {
411 ignoreUnexpected = true;
412 expect(
413 [
414 { label: "onBeforeRequest-a",
415 event: "onBeforeRequest",
416 details: {
417 type: "main_frame",
418 url: getURLHttpWithHeaders(),
419 frameUrl: getURLHttpWithHeaders()
420 },
421 },
422 { label: "onBeforeRedirect",
423 event: "onBeforeRedirect",
424 details: {
425 url: getURLHttpWithHeaders(),
426 redirectUrl: getURLHttpSimple(),
427 statusLine: "HTTP/1.1 302 Found",
428 statusCode: 302,
429 fromCache: false,
430 ip: "127.0.0.1",
431 }
432 },
433 { label: "onBeforeRequest-b",
434 event: "onBeforeRequest",
435 details: {
436 type: "main_frame",
437 url: getURLHttpSimple(),
438 frameUrl: getURLHttpSimple(),
439 },
440 },
441 { label: "onCompleted",
442 event: "onCompleted",
443 details: {
444 ip: "127.0.0.1",
445 url: getURLHttpSimple(),
446 fromCache: false,
447 statusCode: 200,
448 statusLine: "HTTP/1.1 200 OK",
449 }
450 },
451 ],
452 [ ["onBeforeRequest-a", "onBeforeRedirect", "onBeforeRequest-b",
453 "onCompleted"] ]);
454
455 onRequest.addRules(
456 [ {'conditions': [new RequestMatcher({'contentType': ["text/plain"]})],
457 'actions': [
458 new RedirectRequest({'redirectUrl': getURLHttpSimple()})]}
459 ],
460 function() {navigateAndWait(getURLHttpWithHeaders());}
461 );
462 },
463
408 function testRedirectByRegEx() { 464 function testRedirectByRegEx() {
409 ignoreUnexpected = true; 465 ignoreUnexpected = true;
410 expect( 466 expect(
411 [ 467 [
412 { label: "onCompleted", 468 { label: "onCompleted",
413 event: "onCompleted", 469 event: "onCompleted",
414 details: { 470 details: {
415 ip: "127.0.0.1", 471 ip: "127.0.0.1",
416 url: getURLHttpSimpleB(), 472 url: getURLHttpSimpleB(),
417 fromCache: false, 473 fromCache: false,
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
452 'urlMatches': 'simple[A-Z].*a\.html$', 508 'urlMatches': 'simple[A-Z].*a\.html$',
453 'schemes': ["http"] 509 'schemes': ["http"]
454 }, 510 },
455 })], 511 })],
456 'actions': [new CancelRequest()]} 512 'actions': [new CancelRequest()]}
457 ], 513 ],
458 function() {navigateAndWait(getURLHttpSimple());} 514 function() {navigateAndWait(getURLHttpSimple());}
459 ); 515 );
460 }, 516 },
461 ]); 517 ]);
OLDNEW
« no previous file with comments | « chrome/test/data/extensions/api_test/webrequest/test_blocking.js ('k') | content/shell/browser/shell_network_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698