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

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

Issue 10052035: Implemented port filter for URLMatcher (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed comment Created 8 years, 8 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/docs/experimental.webRequest.html ('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.experimental.webRequest.onRequest; 5 var onRequest = chrome.experimental.webRequest.onRequest;
6 var RequestMatcher = chrome.experimental.webRequest.RequestMatcher; 6 var RequestMatcher = chrome.experimental.webRequest.RequestMatcher;
7 var CancelRequest = chrome.experimental.webRequest.CancelRequest; 7 var CancelRequest = chrome.experimental.webRequest.CancelRequest;
8 var RedirectRequest = chrome.experimental.webRequest.RedirectRequest; 8 var RedirectRequest = chrome.experimental.webRequest.RedirectRequest;
9 9
10 function getURLHttpSimple() {
11 return getServerURL("files/extensions/api_test/webrequest/simpleLoad/a.html");
12 }
13
14 function getURLHttpComplex() {
15 return getServerURL(
16 "files/extensions/api_test/webrequest/complexLoad/a.html");
17 }
18
10 runTests([ 19 runTests([
11 function testCancelRequest() { 20 function testCancelRequest() {
12 ignoreUnexpected = true; 21 ignoreUnexpected = true;
13 expect( 22 expect(
14 [ 23 [
15 { label: "onErrorOccurred", 24 { label: "onErrorOccurred",
16 event: "onErrorOccurred", 25 event: "onErrorOccurred",
17 details: { 26 details: {
18 url: getURL("simpleLoad/a.html"), 27 url: getURLHttpSimple(),
19 fromCache: false, 28 fromCache: false,
20 error: "net::ERR_BLOCKED_BY_CLIENT" 29 error: "net::ERR_BLOCKED_BY_CLIENT"
21 } 30 }
22 }, 31 },
23 ], 32 ],
24 [ ["onCompleted"] ]); 33 [ ["onCompleted"] ]);
25
26 onRequest.addRules( 34 onRequest.addRules(
27 [ {'conditions': [ 35 [ {'conditions': [
28 new RequestMatcher({'path_suffix': ".html", 36 new RequestMatcher({'path_suffix': ".html",
29 'resourceType': ["main_frame"], 37 'resourceType': ["main_frame"],
30 'schemes': ["chrome-extension"]})], 38 'schemes': ["http"],
39 'ports': [testServerPort, [1000, 2000]]})],
31 'actions': [new CancelRequest()]} 40 'actions': [new CancelRequest()]}
32 ], 41 ],
33 function() {navigateAndWait(getURL("simpleLoad/a.html"));} 42 function() {navigateAndWait(getURLHttpSimple());}
34 ); 43 );
35 }, 44 },
36 45
37 function testRedirectRequest() { 46 function testRedirectRequest() {
38 ignoreUnexpected = true; 47 ignoreUnexpected = true;
39 expect( 48 expect(
40 [ 49 [
41 { label: "onBeforeRequest-a", 50 { label: "onBeforeRequest-a",
42 event: "onBeforeRequest", 51 event: "onBeforeRequest",
43 details: { 52 details: {
44 type: "main_frame", 53 type: "main_frame",
45 url: getURL("complexLoad/a.html"), 54 url: getURLHttpComplex(),
46 frameUrl: getURL("complexLoad/a.html") 55 frameUrl: getURLHttpComplex()
47 }, 56 },
48 }, 57 },
49 { label: "onBeforeRedirect", 58 { label: "onBeforeRedirect",
50 event: "onBeforeRedirect", 59 event: "onBeforeRedirect",
51 details: { 60 details: {
52 url: getURL("complexLoad/a.html"), 61 url: getURLHttpComplex(),
53 redirectUrl: getURL("simpleLoad/a.html"), 62 redirectUrl: getURLHttpSimple(),
54 statusLine: "", 63 statusLine: "",
55 statusCode: -1, 64 statusCode: -1,
56 fromCache: false, 65 fromCache: false,
57 } 66 }
58 }, 67 },
59 { label: "onBeforeRequest-b", 68 { label: "onBeforeRequest-b",
60 event: "onBeforeRequest", 69 event: "onBeforeRequest",
61 details: { 70 details: {
62 type: "main_frame", 71 type: "main_frame",
63 url: getURL("simpleLoad/a.html"), 72 url: getURLHttpSimple(),
64 frameUrl: getURL("simpleLoad/a.html"), 73 frameUrl: getURLHttpSimple(),
65 }, 74 },
66 }, 75 },
67 { label: "onCompleted", 76 { label: "onCompleted",
68 event: "onCompleted", 77 event: "onCompleted",
69 details: { 78 details: {
70 url: getURL("simpleLoad/a.html"), 79 ip: "127.0.0.1",
80 url: getURLHttpSimple(),
71 fromCache: false, 81 fromCache: false,
72 statusCode: 200, 82 statusCode: 200,
73 statusLine: "HTTP/1.1 200 OK", 83 statusLine: "HTTP/1.0 200 OK",
74 } 84 }
75 }, 85 },
76 ], 86 ],
77 [ ["onBeforeRequest-a", "onBeforeRedirect", "onBeforeRequest-b", 87 [ ["onBeforeRequest-a", "onBeforeRedirect", "onBeforeRequest-b",
78 "onCompleted"] ]); 88 "onCompleted"] ]);
79 89
80 onRequest.addRules( 90 onRequest.addRules(
81 [ {'conditions': [new RequestMatcher({'path_suffix': ".html"})], 91 [ {'conditions': [new RequestMatcher({'path_suffix': ".html"})],
82 'actions': [ 92 'actions': [
83 new RedirectRequest({'redirectUrl': getURL("simpleLoad/a.html")})]} 93 new RedirectRequest({'redirectUrl': getURLHttpSimple()})]}
84 ], 94 ],
85 function() {navigateAndWait(getURL("complexLoad/a.html"));} 95 function() {navigateAndWait(getURLHttpComplex());}
86 ); 96 );
87 }, 97 },
88 ]); 98 ]);
OLDNEW
« no previous file with comments | « chrome/common/extensions/docs/experimental.webRequest.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698