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

Side by Side Diff: chrome/test/data/extensions/api_test/webrequest/test_simple.html

Issue 8775046: Convert another batch of extension tests to manifest_version 2 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years 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
OLDNEW
1 <script src="framework.js"> 1 <!--
2 </script> 2 * Copyright (c) 2011 The Chromium Authors. All rights reserved. Use of this
3 <script> 3 * source code is governed by a BSD-style license that can be found in the
4 // Constants as functions, not to be called until after runTests. 4 * LICENSE file.
5 function getURLHttpSimpleLoad() { 5 -->
6 return getServerURL('files/extensions/api_test/webrequest/simpleLoad/a.html'); 6 <script src="framework.js"></script>
7 } 7 <script src="test_simple.js"></script>
8
9 function getURLHttpSimpleLoadRedirect() {
10 return getServerURL('server-redirect?'+getURLHttpSimpleLoad());
11 }
12
13 // A URL from b.com, which we don't have permission to access.
14 function getURLNotVisible() {
15 return getServerURL('files/extensions/api_test/webrequest/simpleLoad/b.html',
16 'b.com');
17 }
18
19 runTests([
20 // Navigates to a blank page.
21 function simpleLoad() {
22 expect(
23 [ // events
24 { label: "a-onBeforeRequest",
25 event: "onBeforeRequest",
26 details: {
27 url: getURL("simpleLoad/a.html"),
28 frameUrl: getURL("simpleLoad/a.html")
29 }
30 },
31 { label: "a-onResponseStarted",
32 event: "onResponseStarted",
33 details: {
34 url: getURL("simpleLoad/a.html"),
35 statusCode: 200,
36 fromCache: false,
37 statusLine: "HTTP/1.1 200 OK",
38 // Request to chrome-extension:// url has no IP.
39 }
40 },
41 { label: "a-onCompleted",
42 event: "onCompleted",
43 details: {
44 url: getURL("simpleLoad/a.html"),
45 statusCode: 200,
46 fromCache: false,
47 statusLine: "HTTP/1.1 200 OK",
48 // Request to chrome-extension:// url has no IP.
49 }
50 },
51 ],
52 [ // event order
53 ["a-onBeforeRequest", "a-onResponseStarted", "a-onCompleted"] ]);
54 navigateAndWait(getURL("simpleLoad/a.html"));
55 },
56
57 // Navigates to a blank page via HTTP. Only HTTP requests get the
58 // onBeforeSendHeaders event.
59 function simpleLoadHttp() {
60 expect(
61 [ // events
62 { label: "onBeforeRequest-1",
63 event: "onBeforeRequest",
64 details: {
65 url: getURLHttpSimpleLoadRedirect(),
66 frameUrl: getURLHttpSimpleLoadRedirect()
67 }
68 },
69 { label: "onBeforeSendHeaders-1",
70 event: "onBeforeSendHeaders",
71 details: {
72 url: getURLHttpSimpleLoadRedirect(),
73 requestHeadersValid: true
74 }
75 },
76 { label: "onSendHeaders-1",
77 event: "onSendHeaders",
78 details: {
79 url: getURLHttpSimpleLoadRedirect(),
80 requestHeadersValid: true
81 }
82 },
83 { label: "onHeadersReceived-1",
84 event: "onHeadersReceived",
85 details: {
86 url: getURLHttpSimpleLoadRedirect(),
87 responseHeadersExist: true,
88 statusLine: "HTTP/1.0 301 Moved Permanently"
89 }
90 },
91 { label: "onBeforeRedirect",
92 event: "onBeforeRedirect",
93 details: {
94 url: getURLHttpSimpleLoadRedirect(),
95 redirectUrl: getURLHttpSimpleLoad(),
96 statusCode: 301,
97 responseHeadersExist: true,
98 ip: "127.0.0.1",
99 fromCache: false,
100 statusLine: "HTTP/1.0 301 Moved Permanently"
101 }
102 },
103 { label: "onBeforeRequest-2",
104 event: "onBeforeRequest",
105 details: {
106 url: getURLHttpSimpleLoad(),
107 frameUrl: getURLHttpSimpleLoad()
108 }
109 },
110 { label: "onBeforeSendHeaders-2",
111 event: "onBeforeSendHeaders",
112 details: {
113 url: getURLHttpSimpleLoad(),
114 requestHeadersValid: true
115 }
116 },
117 { label: "onSendHeaders-2",
118 event: "onSendHeaders",
119 details: {
120 url: getURLHttpSimpleLoad(),
121 requestHeadersValid: true
122 }
123 },
124 { label: "onHeadersReceived-2",
125 event: "onHeadersReceived",
126 details: {
127 url: getURLHttpSimpleLoad(),
128 responseHeadersExist: true,
129 statusLine: "HTTP/1.0 200 OK",
130 }
131 },
132 { label: "onResponseStarted",
133 event: "onResponseStarted",
134 details: {
135 url: getURLHttpSimpleLoad(),
136 statusCode: 200,
137 responseHeadersExist: true,
138 ip: "127.0.0.1",
139 fromCache: false,
140 statusLine: "HTTP/1.0 200 OK",
141 }
142 },
143 { label: "onCompleted",
144 event: "onCompleted",
145 details: {
146 url: getURLHttpSimpleLoad(),
147 statusCode: 200,
148 ip: "127.0.0.1",
149 fromCache: false,
150 responseHeadersExist: true,
151 statusLine: "HTTP/1.0 200 OK"
152 }
153 }
154 ],
155 [ // event order
156 ["onBeforeRequest-1", "onBeforeSendHeaders-1", "onSendHeaders-1",
157 "onHeadersReceived-1", "onBeforeRedirect",
158 "onBeforeRequest-2", "onBeforeSendHeaders-2", "onSendHeaders-2",
159 "onHeadersReceived-2", "onResponseStarted", "onCompleted"] ],
160 {}, // filter
161 ["requestHeaders", "responseHeaders"]);
162 navigateAndWait(getURLHttpSimpleLoadRedirect());
163 },
164
165 // Navigates to a non-existing page.
166 function nonExistingLoad() {
167 expect(
168 [ // events
169 { label: "onBeforeRequest",
170 event: "onBeforeRequest",
171 details: {
172 url: getURL("does_not_exist.html"),
173 frameUrl: getURL("does_not_exist.html")
174 }
175 },
176 { label: "onErrorOccurred",
177 event: "onErrorOccurred",
178 details: {
179 url: getURL("does_not_exist.html"),
180 fromCache: false,
181 error: "net::ERR_FILE_NOT_FOUND",
182 // Request to chrome-extension:// url has no IP.
183 }
184 },
185 ],
186 [ // event order
187 ["onBeforeRequest", "onErrorOccurred"] ]);
188 navigateAndWait(getURL("does_not_exist.html"));
189 },
190
191 // Navigates to a page that we don't have access to, then a blank page.
192 // We should not see the first navigation.
193 function simpleLoadNonVisible() {
194 expect(
195 [ // events
196 { label: "a-onBeforeRequest",
197 event: "onBeforeRequest",
198 details: {
199 url: getURL("simpleLoad/a.html"),
200 frameUrl: getURL("simpleLoad/a.html")
201 }
202 },
203 { label: "a-onResponseStarted",
204 event: "onResponseStarted",
205 details: {
206 url: getURL("simpleLoad/a.html"),
207 statusCode: 200,
208 fromCache: false,
209 statusLine: "HTTP/1.1 200 OK",
210 // Request to chrome-extension:// url has no IP.
211 }
212 },
213 { label: "a-onCompleted",
214 event: "onCompleted",
215 details: {
216 url: getURL("simpleLoad/a.html"),
217 statusCode: 200,
218 fromCache: false,
219 statusLine: "HTTP/1.1 200 OK",
220 // Request to chrome-extension:// url has no IP.
221 }
222 },
223 ],
224 [ // event order
225 ["a-onBeforeRequest", "a-onResponseStarted", "a-onCompleted"] ]);
226 navigateAndWait(getURLNotVisible(), function() {
227 navigateAndWait(getURL("simpleLoad/a.html"));
228 });
229 },
230 ]);
231 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698