Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(447)

Side by Side Diff: chrome/test/data/extensions/api_test/webrequest/test_declarative.js

Issue 10843065: Add condition attribute for MIME media types from Content-Type header. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 27 matching lines...) Expand all
38 function getURLHttpComplex() { 38 function getURLHttpComplex() {
39 return getServerURL( 39 return getServerURL(
40 "files/extensions/api_test/webrequest/complexLoad/a.html"); 40 "files/extensions/api_test/webrequest/complexLoad/a.html");
41 } 41 }
42 42
43 function getURLHttpRedirectTest() { 43 function getURLHttpRedirectTest() {
44 return getServerURL( 44 return getServerURL(
45 "files/extensions/api_test/webrequest/declarative/a.html"); 45 "files/extensions/api_test/webrequest/declarative/a.html");
46 } 46 }
47 47
48 function getURLHttpWithHeaders() {
49 return getServerURL(
50 "files/extensions/api_test/webrequest/declarative/headers.html");
51 }
52
48 function getURLSetCookie() { 53 function getURLSetCookie() {
49 return getServerURL('set-cookie?Foo=Bar'); 54 return getServerURL('set-cookie?Foo=Bar');
50 } 55 }
51 56
52 function getURLHttpXHRData() { 57 function getURLHttpXHRData() {
53 return getServerURL("files/extensions/api_test/webrequest/xhr/data.json", 58 return getServerURL("files/extensions/api_test/webrequest/xhr/data.json",
54 "b.com"); 59 "b.com");
55 } 60 }
56 function getURLHttpSimpleOnB() { 61 function getURLHttpSimpleOnB() {
57 return getServerURL("files/extensions/api_test/webrequest/simpleLoad/a.html", 62 return getServerURL("files/extensions/api_test/webrequest/simpleLoad/a.html",
58 "b.com"); 63 "b.com");
59 } 64 }
60 65
61 runTests([ 66 runTests([
62 67
63 function testCancelRequest() { 68 function testCancelRequest() {
64 ignoreUnexpected = true; 69 ignoreUnexpected = true;
65 expect( 70 expect(
66 [ 71 [
67 { label: "onErrorOccurred", 72 { label: "onErrorOccurred",
68 event: "onErrorOccurred", 73 event: "onErrorOccurred",
69 details: { 74 details: {
70 url: getURLHttpSimple(), 75 url: getURLHttpWithHeaders(),
71 fromCache: false, 76 fromCache: false,
72 error: "net::ERR_BLOCKED_BY_CLIENT" 77 error: "net::ERR_BLOCKED_BY_CLIENT"
73 } 78 }
74 }, 79 },
75 ], 80 ],
76 [ ["onErrorOccurred"] ]); 81 [ ["onErrorOccurred"] ]);
77 onRequest.addRules( 82 onRequest.addRules(
78 [ {'conditions': [ 83 [ {'conditions': [
79 new RequestMatcher({ 84 new RequestMatcher({
80 'url': { 85 'url': {
81 'pathSuffix': ".html", 86 'pathSuffix': ".html",
82 'ports': [testServerPort, [1000, 2000]], 87 'ports': [testServerPort, [1000, 2000]],
83 'schemes': ["http"] 88 'schemes': ["http"]
84 }, 89 },
85 'resourceType': ["main_frame"]})], 90 'resourceType': ["main_frame"],
91 'contentType': ["text/html"]})],
86 'actions': [new CancelRequest()]} 92 'actions': [new CancelRequest()]}
87 ], 93 ],
88 function() {navigateAndWait(getURLHttpSimple());} 94 function() {navigateAndWait(getURLHttpWithHeaders());}
89 ); 95 );
90 }, 96 },
91 97
92 function testRedirectRequest() { 98 function testRedirectRequest() {
93 ignoreUnexpected = true; 99 ignoreUnexpected = true;
94 expect( 100 expect(
95 [ 101 [
96 { label: "onBeforeRequest-a", 102 { label: "onBeforeRequest-a",
97 event: "onBeforeRequest", 103 event: "onBeforeRequest",
98 details: { 104 details: {
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 } 376 }
371 } 377 }
372 req.open("GET", getURLHttpXHRData(), asynchronous); 378 req.open("GET", getURLHttpXHRData(), asynchronous);
373 req.send(null); 379 req.send(null);
374 }); 380 });
375 } 381 }
376 ); 382 );
377 }, 383 },
378 384
379 ]); 385 ]);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698