| 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 91fb9aeafcb8f1ec5b54b4f52b136cd8c598f889..f3c2d1c722de0f20f002648df97bf7ba623db7d3 100644
|
| --- a/chrome/test/data/extensions/api_test/webrequest/test_declarative.js
|
| +++ b/chrome/test/data/extensions/api_test/webrequest/test_declarative.js
|
| @@ -56,6 +56,11 @@ function getURLHttpWithHeaders() {
|
| "files/extensions/api_test/webrequest/declarative/headers.html");
|
| }
|
|
|
| +function getURLParties() {
|
| + return getServerURL(
|
| + "files/extensions/api_test/webrequest/declarative/parties.html");
|
| +}
|
| +
|
| function getURLSetCookie() {
|
| return getServerURL('set-cookie?Foo=Bar');
|
| }
|
| @@ -79,6 +84,79 @@ function getURLHttpSimpleOnB() {
|
| "b.com");
|
| }
|
|
|
| +// Shared test sections.
|
| +function firstPartyExpected() {
|
| + return [
|
| + { label: "onBeforeRequest",
|
| + event: "onBeforeRequest",
|
| + details: {
|
| + url: getURLParties(),
|
| + frameUrl: getURLParties()
|
| + }
|
| + },
|
| + { label: "onBeforeSendHeaders",
|
| + event: "onBeforeSendHeaders",
|
| + details: {url: getURLParties()}
|
| + },
|
| + { label: "onSendHeaders",
|
| + event: "onSendHeaders",
|
| + details: {url: getURLParties()}
|
| + },
|
| + { label: "onHeadersReceived",
|
| + event: "onHeadersReceived",
|
| + details: {
|
| + url: getURLParties(),
|
| + statusLine: "HTTP/1.0 200 OK"
|
| + }
|
| + },
|
| + { label: "onResponseStarted",
|
| + event: "onResponseStarted",
|
| + details: {
|
| + url: getURLParties(),
|
| + 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: getURLParties(),
|
| + 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: getURLParties()
|
| + }
|
| + },
|
| + { label: "img-onErrorOccurred",
|
| + event: "onErrorOccurred",
|
| + details: {
|
| + error: "net::ERR_BLOCKED_BY_CLIENT",
|
| + fromCache: false,
|
| + type: "image",
|
| + url: "http://non_existing_third_party.com/image.png"
|
| + }
|
| + },
|
| + ];
|
| +}
|
| +
|
| +function firstPartyExpectedOrder() {
|
| + return [
|
| + ["onBeforeRequest", "onBeforeSendHeaders", "onSendHeaders",
|
| + "onHeadersReceived", "onResponseStarted", "onCompleted"],
|
| + ["img-onBeforeRequest", "img-onErrorOccurred"]
|
| + ];
|
| +}
|
| +
|
| runTests([
|
|
|
| function testCancelRequest() {
|
| @@ -114,6 +192,42 @@ runTests([
|
| );
|
| },
|
|
|
| + // Tests that "thirdParty: true" matches third party requests.
|
| + function testThirdParty() {
|
| + ignoreUnexpected = false;
|
| + expect(firstPartyExpected(), firstPartyExpectedOrder());
|
| + onRequest.addRules(
|
| + [ {'conditions': [new RequestMatcher({thirdParty: true})],
|
| + 'actions': [new chrome.declarativeWebRequest.CancelRequest()]},],
|
| + function() {navigateAndWait(getURLParties());}
|
| + );
|
| + },
|
| +
|
| + // Tests that "thirdParty: false" matches first party requests, by cancelling
|
| + // all requests, and overriding the cancelling rule only for requests matching
|
| + // "thirdParty: false".
|
| + function testFirstParty() {
|
| + ignoreUnexpected = false;
|
| + expect(firstPartyExpected(), firstPartyExpectedOrder());
|
| + onRequest.addRules(
|
| + [ {'priority': 2,
|
| + 'conditions': [
|
| + new RequestMatcher({thirdParty: false})
|
| + ],
|
| + 'actions': [
|
| + new chrome.declarativeWebRequest.IgnoreRules({
|
| + lowerPriorityThan: 2 })
|
| + ]
|
| + },
|
| + {'priority': 1,
|
| + 'conditions': [new RequestMatcher({})],
|
| + 'actions': [new chrome.declarativeWebRequest.CancelRequest()]
|
| + },
|
| + ],
|
| + function() {navigateAndWait(getURLParties());}
|
| + );
|
| + },
|
| +
|
| function testRedirectRequest() {
|
| ignoreUnexpected = true;
|
| expect(
|
|
|