Chromium Code Reviews| Index: chrome/test/data/extensions/api_test/webrequest/test_declarative.js |
| diff --git a/chrome/test/data/extensions/api_test/webrequest/test_declarative.js b/chrome/test/data/extensions/api_test/webrequest/test_declarative.js |
| index 92709cfb1a15ad0e6f9f5d3ae24488591d4807bd..5dd122045873fe791a85c05759936f49343e0aa4 100644 |
| --- a/chrome/test/data/extensions/api_test/webrequest/test_declarative.js |
| +++ b/chrome/test/data/extensions/api_test/webrequest/test_declarative.js |
| @@ -277,6 +277,121 @@ runTests([ |
| ); |
| }, |
| + // Tests "firstPartyForCookiesUrl" by using it to override a cancelling rule. |
| + function testFirstPartyForCookiesUrl() { |
| + ignoreUnexpected = false; |
| + expect( |
|
Jeffrey Yasskin
2012/12/18 03:09:58
Where is expect() defined? What do its parameters
vabr (Chromium)
2013/01/21 10:57:48
The function expect is part of the test framework:
|
| + [ |
| + { label: "onBeforeRequest", |
| + event: "onBeforeRequest", |
| + details: { |
| + url: getURLThirdParty(), |
| + frameUrl: getURLThirdParty() |
| + } |
| + }, |
| + { label: "onBeforeSendHeaders", |
|
Jeffrey Yasskin
2012/12/18 03:09:58
If the label is the same as the event in almost al
vabr (Chromium)
2013/01/21 10:57:48
I can understand your concerns, but I believe thos
|
| + event: "onBeforeSendHeaders", |
| + details: {url: getURLThirdParty()} |
| + }, |
| + { label: "onSendHeaders", |
| + event: "onSendHeaders", |
| + details: {url: getURLThirdParty()} |
| + }, |
| + { label: "onHeadersReceived", |
| + event: "onHeadersReceived", |
| + details: { |
| + url: getURLThirdParty(), |
| + statusLine: "HTTP/1.0 200 OK" |
| + } |
| + }, |
| + { label: "onResponseStarted", |
| + event: "onResponseStarted", |
| + details: { |
| + url: getURLThirdParty(), |
| + fromCache: false, |
| + ip: "127.0.0.1", |
| + statusCode: 200, |
| + statusLine: "HTTP/1.0 200 OK" |
| + } |
| + }, |
| + { label: "onCompleted", |
| + event: "onCompleted", |
| + details: { |
| + fromCache: false, |
| + ip: "127.0.0.1", |
| + url: getURLThirdParty(), |
| + statusCode: 200, |
| + statusLine: "HTTP/1.0 200 OK" |
| + } |
| + }, |
| + { label: "img-onBeforeRequest", |
| + event: "onBeforeRequest", |
| + details: { |
| + type: "image", |
| + url: "http://non_existing_third_party.com/image.png", |
| + frameUrl: getURLThirdParty() |
| + } |
| + }, |
| + { label: "img-onBeforeSendHeaders", |
| + event: "onBeforeSendHeaders", |
| + details: { |
| + type: "image", |
| + url: "http://non_existing_third_party.com/image.png", |
| + } |
| + }, |
| + { label: "img-onErrorOccurred", |
| + event: "onErrorOccurred", |
| + details: { |
| + url: "http://non_existing_third_party.com/image.png", |
| + type: "image", |
| + fromCache: false, |
| + error: "net::ERR_BLOCKED_BY_CLIENT" |
| + } |
| + }, |
| + ], |
| + [ ["onBeforeRequest", "onBeforeSendHeaders", "onSendHeaders", |
| + "onHeadersReceived", "onResponseStarted", "onCompleted"], |
| + ["img-onBeforeRequest", "img-onBeforeSendHeaders", |
| + "img-onErrorOccurred"] ]); |
| + onRequest.addRules( |
| + [ // This rule cancels the request with a 3rd party URL just before it is |
| + // sent. This is necessary, because sending it would generate different |
| + // HTTP 4xx codes on different platforms, making it impossible to |
| + // present a single list of expected events. |
| + {'priority': 3, |
| + 'conditions': [new RequestMatcher({ |
| + 'url': { 'hostEquals': 'non_existing_third_party.com' }, |
| + 'stages': ["onBeforeSendHeaders"] |
| + })], |
| + 'actions': [new chrome.declarativeWebRequest.CancelRequest()] |
| + }, |
| + {'priority': 2, |
| + 'conditions': [ |
| + new RequestMatcher({ |
| + firstPartyForCookiesUrl: { |
| + hostEquals: testServer |
| + } |
| + }) |
| + ], |
| + 'actions': [ |
| + new chrome.declarativeWebRequest.IgnoreRules({ |
| + lowerPriorityThan: 2 }) |
| + ] |
| + }, |
| + // This rule cancels everyhting, and sooner that the very first rule |
|
Jeffrey Yasskin
2012/12/18 03:09:58
sp: everyhting. s/that/than/
vabr (Chromium)
2013/01/21 10:57:48
Done.
|
| + // would. The test is reduced to making sure this (3rd) rule was ignored |
| + // as a consequence of the 2nd rule. |
| + {'priority': 1, |
| + 'conditions': [new RequestMatcher({ |
| + 'stages': ["onBeforeRequest"] |
| + })], |
| + 'actions': [new chrome.declarativeWebRequest.CancelRequest()] |
| + }, |
| + ], |
| + function() {navigateAndWait(getURLThirdParty());} |
| + ); |
| + }, |
| + |
| function testRedirectRequest() { |
| ignoreUnexpected = true; |
| expect( |