Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 99 [ {'conditions': [ | 99 [ {'conditions': [ |
| 100 new RequestMatcher({ | 100 new RequestMatcher({ |
| 101 'url': { | 101 'url': { |
| 102 'pathSuffix': ".html", | 102 'pathSuffix': ".html", |
| 103 'ports': [testServerPort, [1000, 2000]], | 103 'ports': [testServerPort, [1000, 2000]], |
| 104 'schemes': ["http"] | 104 'schemes': ["http"] |
| 105 }, | 105 }, |
| 106 'resourceType': ["main_frame"], | 106 'resourceType': ["main_frame"], |
| 107 'contentType': ["text/plain"], | 107 'contentType': ["text/plain"], |
| 108 'excludeContentType': ["image/png"], | 108 'excludeContentType': ["image/png"], |
| 109 'responseHeaders': [{ nameContains: ["content", "type"] } ], | 109 'responseHeaders': [{ nameContains: ["content", "type"] }], |
| 110 'excludeResponseHeaders': [{ valueContains: "nonsense" }] })], | 110 'excludeResponseHeaders': [{ valueContains: "nonsense" }] })], |
| 111 'actions': [new CancelRequest()]} | 111 'actions': [new CancelRequest()]} |
| 112 ], | 112 ], |
| 113 function() {navigateAndWait(getURLHttpWithHeaders());} | 113 function() {navigateAndWait(getURLHttpWithHeaders());} |
| 114 ); | 114 ); |
| 115 }, | 115 }, |
| 116 | 116 |
| 117 function testRedirectRequest() { | 117 function testRedirectRequest() { |
| 118 ignoreUnexpected = true; | 118 ignoreUnexpected = true; |
| 119 expect( | 119 expect( |
| (...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 497 chrome.test.fail("Redirect was not prevented. Status: " + | 497 chrome.test.fail("Redirect was not prevented. Status: " + |
| 498 this.status + ", responseText: " + this.responseText); | 498 this.status + ", responseText: " + this.responseText); |
| 499 } | 499 } |
| 500 } | 500 } |
| 501 req.open("GET", getURLHttpXHRData(), asynchronous); | 501 req.open("GET", getURLHttpXHRData(), asynchronous); |
| 502 req.send(null); | 502 req.send(null); |
| 503 }); | 503 }); |
| 504 } | 504 } |
| 505 ); | 505 ); |
| 506 }, | 506 }, |
| 507 | |
| 508 function testRequestHeaders() { | |
| 509 ignoreUnexpected = true; | |
| 510 expect( | |
| 511 [ | |
| 512 { label: "onErrorOccurred", | |
| 513 event: "onErrorOccurred", | |
| 514 details: { | |
| 515 url: getURLHttpWithHeaders(), | |
| 516 fromCache: false, | |
| 517 error: "net::ERR_BLOCKED_BY_CLIENT" | |
| 518 } | |
| 519 }, | |
| 520 ], | |
| 521 [ ["onErrorOccurred"] ]); | |
| 522 onRequest.addRules( | |
| 523 [ {'conditions': [ | |
| 524 new RequestMatcher({ | |
| 525 'url': { | |
| 526 'pathSuffix': ".html", | |
| 527 'ports': [testServerPort, [1000, 2000]], | |
| 528 'schemes': ["http"] | |
| 529 }, | |
| 530 'requestHeaders': [{ nameContains: "" }], | |
| 531 'excludeRequestHeaders': [{ valueContains: ["", "value123"] }] | |
| 532 })], | |
| 533 'actions': [new CancelRequest()]} | |
| 534 ], | |
| 535 function() {navigateAndWait(getURLHttpWithHeaders());} | |
|
battre
2012/10/05 12:50:03
This URL returns a response with specific headers.
battre
2012/10/05 15:45:49
As discussed, I think that the unit tests in combi
vabr (Chromium)
2012/10/05 15:56:53
OK. I at least changed the URL to something more s
| |
| 536 ); | |
| 537 }, | |
| 507 ]); | 538 ]); |
| OLD | NEW |