| 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 16 matching lines...) Expand all Loading... |
| 27 var EditResponseCookie = chrome.declarativeWebRequest.EditResponseCookie; | 27 var EditResponseCookie = chrome.declarativeWebRequest.EditResponseCookie; |
| 28 var RemoveRequestCookie = chrome.declarativeWebRequest.RemoveRequestCookie; | 28 var RemoveRequestCookie = chrome.declarativeWebRequest.RemoveRequestCookie; |
| 29 var RemoveResponseCookie = chrome.declarativeWebRequest.RemoveResponseCookie; | 29 var RemoveResponseCookie = chrome.declarativeWebRequest.RemoveResponseCookie; |
| 30 | 30 |
| 31 // Constants as functions, not to be called until after runTests. | 31 // Constants as functions, not to be called until after runTests. |
| 32 function getURLEchoUserAgent() { | 32 function getURLEchoUserAgent() { |
| 33 return getServerURL('echoheader?User-Agent'); | 33 return getServerURL('echoheader?User-Agent'); |
| 34 } | 34 } |
| 35 | 35 |
| 36 function getURLHttpSimple() { | 36 function getURLHttpSimple() { |
| 37 return getServerURL("files/extensions/api_test/webrequest/simpleLoad/a.html"); | 37 return getServerURL("extensions/api_test/webrequest/simpleLoad/a.html"); |
| 38 } | 38 } |
| 39 | 39 |
| 40 function getURLOfHTMLWithThirdParty() { | 40 function getURLOfHTMLWithThirdParty() { |
| 41 // Returns the URL of a HTML document with a third-party resource. | 41 // Returns the URL of a HTML document with a third-party resource. |
| 42 return getServerURL( | 42 return getServerURL( |
| 43 "files/extensions/api_test/webrequest/declarative/third-party.html"); | 43 "extensions/api_test/webrequest/declarative/third-party.html"); |
| 44 } | 44 } |
| 45 | 45 |
| 46 function getURLSetCookie() { | 46 function getURLSetCookie() { |
| 47 return getServerURL('set-cookie?Foo=Bar'); | 47 return getServerURL('set-cookie?Foo=Bar'); |
| 48 } | 48 } |
| 49 | 49 |
| 50 function getURLSetCookie2() { | 50 function getURLSetCookie2() { |
| 51 return getServerURL('set-cookie?passedCookie=Foo&editedCookie=Foo&' + | 51 return getServerURL('set-cookie?passedCookie=Foo&editedCookie=Foo&' + |
| 52 'deletedCookie=Foo'); | 52 'deletedCookie=Foo'); |
| 53 } | 53 } |
| 54 | 54 |
| 55 function getURLEchoCookie() { | 55 function getURLEchoCookie() { |
| 56 return getServerURL('echoheader?Cookie'); | 56 return getServerURL('echoheader?Cookie'); |
| 57 } | 57 } |
| 58 | 58 |
| 59 function getURLHttpXHRData() { | 59 function getURLHttpXHRData() { |
| 60 return getServerURL("files/extensions/api_test/webrequest/xhr/data.json", | 60 return getServerURL("extensions/api_test/webrequest/xhr/data.json", |
| 61 "b.com"); | 61 "b.com"); |
| 62 } | 62 } |
| 63 | 63 |
| 64 runTests([ | 64 runTests([ |
| 65 | 65 |
| 66 function testSetRequestHeader() { | 66 function testSetRequestHeader() { |
| 67 ignoreUnexpected = true; | 67 ignoreUnexpected = true; |
| 68 expect(); // Used for initialization. | 68 expect(); // Used for initialization. |
| 69 onRequest.addRules( | 69 onRequest.addRules( |
| 70 [{conditions: [new RequestMatcher()], | 70 [{conditions: [new RequestMatcher()], |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 function testPriorities() { | 153 function testPriorities() { |
| 154 ignoreUnexpected = true; | 154 ignoreUnexpected = true; |
| 155 expect( | 155 expect( |
| 156 [ | 156 [ |
| 157 { label: "onCompleted", | 157 { label: "onCompleted", |
| 158 event: "onCompleted", | 158 event: "onCompleted", |
| 159 details: { | 159 details: { |
| 160 url: getURLHttpSimple(), | 160 url: getURLHttpSimple(), |
| 161 statusCode: 200, | 161 statusCode: 200, |
| 162 fromCache: false, | 162 fromCache: false, |
| 163 statusLine: "HTTP/1.0 200 OK", | 163 statusLine: "HTTP/1.1 200 OK", |
| 164 ip: "127.0.0.1", | 164 ip: "127.0.0.1", |
| 165 } | 165 } |
| 166 } | 166 } |
| 167 ], | 167 ], |
| 168 [ ["onCompleted"] ]); | 168 [ ["onCompleted"] ]); |
| 169 | 169 |
| 170 onRequest.addRules( | 170 onRequest.addRules( |
| 171 [ {conditions: [new RequestMatcher({url: {pathContains: "simpleLoad"}})], | 171 [ {conditions: [new RequestMatcher({url: {pathContains: "simpleLoad"}})], |
| 172 actions: [new CancelRequest()]}, | 172 actions: [new CancelRequest()]}, |
| 173 {conditions: [new RequestMatcher({url: {pathContains: "a.html"}})], | 173 {conditions: [new RequestMatcher({url: {pathContains: "a.html"}})], |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 }, | 278 }, |
| 279 'requestHeaders': [{ nameContains: "" }], | 279 'requestHeaders': [{ nameContains: "" }], |
| 280 'excludeRequestHeaders': [{ valueContains: ["", "value123"] }] | 280 'excludeRequestHeaders': [{ valueContains: ["", "value123"] }] |
| 281 })], | 281 })], |
| 282 'actions': [new CancelRequest()]} | 282 'actions': [new CancelRequest()]} |
| 283 ], | 283 ], |
| 284 function() {navigateAndWait(getURLHttpSimple());} | 284 function() {navigateAndWait(getURLHttpSimple());} |
| 285 ); | 285 ); |
| 286 }, | 286 }, |
| 287 ]); | 287 ]); |
| OLD | NEW |