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 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 [ {'conditions': [ | 178 [ {'conditions': [ |
179 new RequestMatcher({ | 179 new RequestMatcher({ |
180 'url': { | 180 'url': { |
181 'pathSuffix': ".html", | 181 'pathSuffix': ".html", |
182 'ports': [testServerPort, [1000, 2000]], | 182 'ports': [testServerPort, [1000, 2000]], |
183 'schemes': ["http"] | 183 'schemes': ["http"] |
184 }, | 184 }, |
185 'resourceType': ["main_frame"], | 185 'resourceType': ["main_frame"], |
186 'contentType': ["text/plain"], | 186 'contentType': ["text/plain"], |
187 'excludeContentType': ["image/png"], | 187 'excludeContentType': ["image/png"], |
188 'responseHeaders': [{ nameContains: ["content", "type"] } ], | 188 'responseHeaders': [{ nameContains: ["content", "type"] }], |
189 'excludeResponseHeaders': [{ valueContains: "nonsense" }] })], | 189 'excludeResponseHeaders': [{ valueContains: "nonsense" }] })], |
190 'actions': [new CancelRequest()]} | 190 'actions': [new CancelRequest()]} |
191 ], | 191 ], |
192 function() {navigateAndWait(getURLHttpWithHeaders());} | 192 function() {navigateAndWait(getURLHttpWithHeaders());} |
193 ); | 193 ); |
194 }, | 194 }, |
195 | 195 |
196 // Tests that "thirdPartyForCookies: true" matches third party requests. | 196 // Tests that "thirdPartyForCookies: true" matches third party requests. |
197 function testThirdParty() { | 197 function testThirdParty() { |
198 ignoreUnexpected = false; | 198 ignoreUnexpected = false; |
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
612 chrome.test.fail("Redirect was not prevented. Status: " + | 612 chrome.test.fail("Redirect was not prevented. Status: " + |
613 this.status + ", responseText: " + this.responseText); | 613 this.status + ", responseText: " + this.responseText); |
614 } | 614 } |
615 } | 615 } |
616 req.open("GET", getURLHttpXHRData(), asynchronous); | 616 req.open("GET", getURLHttpXHRData(), asynchronous); |
617 req.send(null); | 617 req.send(null); |
618 }); | 618 }); |
619 } | 619 } |
620 ); | 620 ); |
621 }, | 621 }, |
| 622 |
| 623 function testRequestHeaders() { |
| 624 ignoreUnexpected = true; |
| 625 expect( |
| 626 [ |
| 627 { label: "onErrorOccurred", |
| 628 event: "onErrorOccurred", |
| 629 details: { |
| 630 url: getURLHttpSimple(), |
| 631 fromCache: false, |
| 632 error: "net::ERR_BLOCKED_BY_CLIENT" |
| 633 } |
| 634 }, |
| 635 ], |
| 636 [ ["onErrorOccurred"] ]); |
| 637 onRequest.addRules( |
| 638 [ {'conditions': [ |
| 639 new RequestMatcher({ |
| 640 'url': { |
| 641 'pathSuffix': ".html", |
| 642 'ports': [testServerPort, [1000, 2000]], |
| 643 'schemes': ["http"] |
| 644 }, |
| 645 'requestHeaders': [{ nameContains: "" }], |
| 646 'excludeRequestHeaders': [{ valueContains: ["", "value123"] }] |
| 647 })], |
| 648 'actions': [new CancelRequest()]} |
| 649 ], |
| 650 function() {navigateAndWait(getURLHttpSimple());} |
| 651 ); |
| 652 }, |
622 ]); | 653 ]); |
OLD | NEW |