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

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

Issue 10386172: Implemented declarative redirects to transparent image and empty document. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix error caused by rebasing Created 8 years, 7 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/test/data/extensions/api_test/webrequest/declarative/a.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.declarativeWebRequest.onRequest; 5 var onRequest = chrome.declarativeWebRequest.onRequest;
6 var RequestMatcher = chrome.declarativeWebRequest.RequestMatcher; 6 var RequestMatcher = chrome.declarativeWebRequest.RequestMatcher;
7 var CancelRequest = chrome.declarativeWebRequest.CancelRequest; 7 var CancelRequest = chrome.declarativeWebRequest.CancelRequest;
8 var RedirectRequest = chrome.declarativeWebRequest.RedirectRequest; 8 var RedirectRequest = chrome.declarativeWebRequest.RedirectRequest;
9 var RedirectToTransparentImage =
10 chrome.declarativeWebRequest.RedirectToTransparentImage;
11 var RedirectToEmptyDocument =
12 chrome.declarativeWebRequest.RedirectToEmptyDocument;
9 13
10 function getURLHttpSimple() { 14 function getURLHttpSimple() {
11 return getServerURL("files/extensions/api_test/webrequest/simpleLoad/a.html"); 15 return getServerURL("files/extensions/api_test/webrequest/simpleLoad/a.html");
12 } 16 }
13 17
14 function getURLHttpComplex() { 18 function getURLHttpComplex() {
15 return getServerURL( 19 return getServerURL(
16 "files/extensions/api_test/webrequest/complexLoad/a.html"); 20 "files/extensions/api_test/webrequest/complexLoad/a.html");
17 } 21 }
18 22
23 function getURLHttpRedirectTest() {
24 return getServerURL(
25 "files/extensions/api_test/webrequest/declarative/a.html");
26 }
27
19 runTests([ 28 runTests([
20 function testCancelRequest() { 29 function testCancelRequest() {
21 ignoreUnexpected = true; 30 ignoreUnexpected = true;
22 expect( 31 expect(
23 [ 32 [
24 { label: "onErrorOccurred", 33 { label: "onErrorOccurred",
25 event: "onErrorOccurred", 34 event: "onErrorOccurred",
26 details: { 35 details: {
27 url: getURLHttpSimple(), 36 url: getURLHttpSimple(),
28 fromCache: false, 37 fromCache: false,
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 "onCompleted"] ]); 100 "onCompleted"] ]);
92 101
93 onRequest.addRules( 102 onRequest.addRules(
94 [ {'conditions': [new RequestMatcher({'url': {'pathSuffix': ".html"}})], 103 [ {'conditions': [new RequestMatcher({'url': {'pathSuffix': ".html"}})],
95 'actions': [ 104 'actions': [
96 new RedirectRequest({'redirectUrl': getURLHttpSimple()})]} 105 new RedirectRequest({'redirectUrl': getURLHttpSimple()})]}
97 ], 106 ],
98 function() {navigateAndWait(getURLHttpComplex());} 107 function() {navigateAndWait(getURLHttpComplex());}
99 ); 108 );
100 }, 109 },
110
111 function testRedirectRequest2() {
112 ignoreUnexpected = true;
113 expect(
114 [
115 { label: "onCompleted",
116 event: "onCompleted",
117 details: {
118 ip: "127.0.0.1",
119 url: getURLHttpRedirectTest(),
120 fromCache: false,
121 statusCode: 200,
122 statusLine: "HTTP/1.0 200 OK",
123 }
124 },
125 // We cannot wait for onCompleted signals because these are not sent
126 // for data:// URLs.
127 { label: "onBeforeRedirect-1",
128 event: "onBeforeRedirect",
129 details: {
130 url: getServerURL(
131 "files/extensions/api_test/webrequest/declarative/image.png"),
132 redirectUrl: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEA" +
133 "AAABCAYAAAAfFcSJAAAACklEQVR4nGMAAQAABQABDQottAAAAABJRU5ErkJ" +
134 "ggg==",
135 fromCache: false,
136 statusCode: -1,
137 statusLine: "",
138 type: "image",
139 }
140 },
141 { label: "onBeforeRedirect-2",
142 event: "onBeforeRedirect",
143 details: {
144 frameId: 1,
145 parentFrameId: 0,
146 url: getServerURL(
147 "files/extensions/api_test/webrequest/declarative/frame.html"),
148 redirectUrl: "data:text/html,",
149 fromCache: false,
150 statusCode: -1,
151 statusLine: "",
152 type: "sub_frame",
153 }
154 },
155 ],
156 [ ["onCompleted"], ["onBeforeRedirect-1"], ["onBeforeRedirect-2"] ]);
157
158 onRequest.addRules(
159 [ {'conditions': [
160 new RequestMatcher({'url': {'pathSuffix': "image.png"}})],
161 'actions': [new RedirectToTransparentImage()]},
162 {'conditions': [
163 new RequestMatcher({'url': {'pathSuffix': "frame.html"}})],
164 'actions': [new RedirectToEmptyDocument()]},
165 ],
166 function() {navigateAndWait(getURLHttpRedirectTest());}
167 );
168 },
101 ]); 169 ]);
OLDNEW
« no previous file with comments | « chrome/test/data/extensions/api_test/webrequest/declarative/a.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698