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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 function getURLHttpComplex() { | 44 function getURLHttpComplex() { |
45 return getServerURL( | 45 return getServerURL( |
46 "files/extensions/api_test/webrequest/complexLoad/a.html"); | 46 "files/extensions/api_test/webrequest/complexLoad/a.html"); |
47 } | 47 } |
48 | 48 |
49 function getURLHttpRedirectTest() { | 49 function getURLHttpRedirectTest() { |
50 return getServerURL( | 50 return getServerURL( |
51 "files/extensions/api_test/webrequest/declarative/a.html"); | 51 "files/extensions/api_test/webrequest/declarative/a.html"); |
52 } | 52 } |
53 | 53 |
| 54 function getURLHttpWithHeaders() { |
| 55 return getServerURL( |
| 56 "files/extensions/api_test/webrequest/declarative/headers.html"); |
| 57 } |
| 58 |
54 function getURLSetCookie() { | 59 function getURLSetCookie() { |
55 return getServerURL('set-cookie?Foo=Bar'); | 60 return getServerURL('set-cookie?Foo=Bar'); |
56 } | 61 } |
57 | 62 |
58 function getURLSetCookie2() { | 63 function getURLSetCookie2() { |
59 return getServerURL('set-cookie?passedCookie=Foo&editedCookie=Foo&' + | 64 return getServerURL('set-cookie?passedCookie=Foo&editedCookie=Foo&' + |
60 'deletedCookie=Foo'); | 65 'deletedCookie=Foo'); |
61 } | 66 } |
62 | 67 |
63 function getURLEchoCookie() { | 68 function getURLEchoCookie() { |
(...skipping 12 matching lines...) Expand all Loading... |
76 | 81 |
77 runTests([ | 82 runTests([ |
78 | 83 |
79 function testCancelRequest() { | 84 function testCancelRequest() { |
80 ignoreUnexpected = true; | 85 ignoreUnexpected = true; |
81 expect( | 86 expect( |
82 [ | 87 [ |
83 { label: "onErrorOccurred", | 88 { label: "onErrorOccurred", |
84 event: "onErrorOccurred", | 89 event: "onErrorOccurred", |
85 details: { | 90 details: { |
86 url: getURLHttpSimple(), | 91 url: getURLHttpWithHeaders(), |
87 fromCache: false, | 92 fromCache: false, |
88 error: "net::ERR_BLOCKED_BY_CLIENT" | 93 error: "net::ERR_BLOCKED_BY_CLIENT" |
89 } | 94 } |
90 }, | 95 }, |
91 ], | 96 ], |
92 [ ["onErrorOccurred"] ]); | 97 [ ["onErrorOccurred"] ]); |
93 onRequest.addRules( | 98 onRequest.addRules( |
94 [ {'conditions': [ | 99 [ {'conditions': [ |
95 new RequestMatcher({ | 100 new RequestMatcher({ |
96 'url': { | 101 'url': { |
97 'pathSuffix': ".html", | 102 'pathSuffix': ".html", |
98 'ports': [testServerPort, [1000, 2000]], | 103 'ports': [testServerPort, [1000, 2000]], |
99 'schemes': ["http"] | 104 'schemes': ["http"] |
100 }, | 105 }, |
101 'resourceType': ["main_frame"]})], | 106 'resourceType': ["main_frame"], |
| 107 'contentType': ["text/html"]})], |
102 'actions': [new CancelRequest()]} | 108 'actions': [new CancelRequest()]} |
103 ], | 109 ], |
104 function() {navigateAndWait(getURLHttpSimple());} | 110 function() {navigateAndWait(getURLHttpWithHeaders());} |
105 ); | 111 ); |
106 }, | 112 }, |
107 | 113 |
108 function testRedirectRequest() { | 114 function testRedirectRequest() { |
109 ignoreUnexpected = true; | 115 ignoreUnexpected = true; |
110 expect( | 116 expect( |
111 [ | 117 [ |
112 { label: "onBeforeRequest-a", | 118 { label: "onBeforeRequest-a", |
113 event: "onBeforeRequest", | 119 event: "onBeforeRequest", |
114 details: { | 120 details: { |
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
461 this.status + ", responseText: " + this.responseText); | 467 this.status + ", responseText: " + this.responseText); |
462 } | 468 } |
463 } | 469 } |
464 req.open("GET", getURLHttpXHRData(), asynchronous); | 470 req.open("GET", getURLHttpXHRData(), asynchronous); |
465 req.send(null); | 471 req.send(null); |
466 }); | 472 }); |
467 } | 473 } |
468 ); | 474 ); |
469 }, | 475 }, |
470 ]); | 476 ]); |
OLD | NEW |