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

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

Issue 10910179: Event matching by regular expression matching on URLs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ascii artiste Created 8 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « chrome/common/extensions/matcher/url_matcher_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 245
246 onRequest.addRules( 246 onRequest.addRules(
247 [ {conditions: [new RequestMatcher({url: {pathSuffix: ".html"}})], 247 [ {conditions: [new RequestMatcher({url: {pathSuffix: ".html"}})],
248 actions: [ 248 actions: [
249 new RedirectByRegEx({from: "^(.*)/a.html$", to: "$1/b.html"})]} 249 new RedirectByRegEx({from: "^(.*)/a.html$", to: "$1/b.html"})]}
250 ], 250 ],
251 function() {navigateAndWait(getURLHttpSimple());} 251 function() {navigateAndWait(getURLHttpSimple());}
252 ); 252 );
253 }, 253 },
254 254
255 function testRegexFilter() {
256 ignoreUnexpected = true;
257 expect(
258 [
259 { label: "onErrorOccurred",
260 event: "onErrorOccurred",
261 details: {
262 url: getURLHttpSimple(),
263 fromCache: false,
264 error: "net::ERR_BLOCKED_BY_CLIENT"
265 }
266 },
267 ],
268 [ ["onErrorOccurred"] ]);
269 onRequest.addRules(
270 [ {'conditions': [
271 new RequestMatcher({
272 'url': {
273 'urlMatches': 'simple[A-Z].*a\.html$',
274 'schemes': ["http"]
275 },
276 })],
277 'actions': [new CancelRequest()]}
278 ],
279 function() {navigateAndWait(getURLHttpSimple());}
280 );
281 },
282
255 function testSetRequestHeader() { 283 function testSetRequestHeader() {
256 ignoreUnexpected = true; 284 ignoreUnexpected = true;
257 expect(); // Used for initialization. 285 expect(); // Used for initialization.
258 onRequest.addRules( 286 onRequest.addRules(
259 [{conditions: [new RequestMatcher()], 287 [{conditions: [new RequestMatcher()],
260 actions: [new SetRequestHeader({name: "User-Agent", value: "FoobarUA"})] 288 actions: [new SetRequestHeader({name: "User-Agent", value: "FoobarUA"})]
261 }], 289 }],
262 function() { 290 function() {
263 // Check the page content for our modified User-Agent string. 291 // Check the page content for our modified User-Agent string.
264 navigateAndWait(getURLEchoUserAgent(), function() { 292 navigateAndWait(getURLEchoUserAgent(), function() {
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
470 this.status + ", responseText: " + this.responseText); 498 this.status + ", responseText: " + this.responseText);
471 } 499 }
472 } 500 }
473 req.open("GET", getURLHttpXHRData(), asynchronous); 501 req.open("GET", getURLHttpXHRData(), asynchronous);
474 req.send(null); 502 req.send(null);
475 }); 503 });
476 } 504 }
477 ); 505 );
478 }, 506 },
479 ]); 507 ]);
OLDNEW
« no previous file with comments | « chrome/common/extensions/matcher/url_matcher_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698