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

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

Issue 7607003: Split ExtensionWebRequestApiTest.WebRequestEvents into multiple tests to (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 <script src="framework.js">
2 </script>
3 <script>
4 // Constants as functions, not to be called until after runTests.
5 function getURLHttpSimpleLoad() {
6 return getServerURL('files/extensions/api_test/webrequest/simpleLoad/a.html');
7 }
8
9 function getURLHttpSimpleLoadRedirect() {
10 return getServerURL('server-redirect?'+getURLHttpSimpleLoad());
11 }
12
13 runTests([
14 // Navigates to a blank page.
15 function simpleLoad() {
16 expect(
17 [ // events
18 { label: "a-onBeforeRequest",
19 event: "onBeforeRequest",
20 details: {
21 method: "GET",
22 tabId: tabId,
23 type: "main_frame",
24 url: getURL("simpleLoad/a.html"),
25 frameUrl: getURL("simpleLoad/a.html")
26 }
27 },
28 { label: "a-onResponseStarted",
29 event: "onResponseStarted",
30 details: {
31 url: getURL("simpleLoad/a.html"),
32 statusCode: 200,
33 fromCache: false
34 // Request to chrome-extension:// url has no IP.
35 }
36 },
37 { label: "a-onCompleted",
38 event: "onCompleted",
39 details: {
40 url: getURL("simpleLoad/a.html"),
41 statusCode: 200,
42 fromCache: false
43 // Request to chrome-extension:// url has no IP.
44 }
45 },
46 ],
47 [ // event order
48 ["a-onBeforeRequest", "a-onResponseStarted", "a-onCompleted"] ]);
49 navigateAndWait(getURL("simpleLoad/a.html"));
50 },
51
52 // Navigates to a blank page via HTTP. Only HTTP requests get the
53 // onBeforeSendHeaders event.
54 function simpleLoadHttp() {
55 expect(
56 [ // events
57 { label: "onBeforeRequest-1",
58 event: "onBeforeRequest",
59 details: {
60 method: "GET",
61 tabId: tabId,
62 type: "main_frame",
63 url: getURLHttpSimpleLoadRedirect(),
64 frameUrl: getURLHttpSimpleLoadRedirect()
65 }
66 },
67 { label: "onBeforeSendHeaders-1",
68 event: "onBeforeSendHeaders",
69 details: {
70 url: getURLHttpSimpleLoadRedirect(),
71 requestHeadersValid: true
72 }
73 },
74 { label: "onSendHeaders-1",
75 event: "onSendHeaders",
76 details: {
77 url: getURLHttpSimpleLoadRedirect(),
78 requestHeadersValid: true
79 }
80 },
81 { label: "onBeforeRedirect",
82 event: "onBeforeRedirect",
83 details: {
84 url: getURLHttpSimpleLoadRedirect(),
85 redirectUrl: getURLHttpSimpleLoad(),
86 statusCode: 301,
87 responseHeadersExist: true,
88 ip: "127.0.0.1",
89 fromCache: false,
90 statusLine: "HTTP/1.0 301 Moved Permanently"
91 }
92 },
93 { label: "onBeforeRequest-2",
94 event: "onBeforeRequest",
95 details: {
96 method: "GET",
97 tabId: tabId,
98 type: "main_frame",
99 url: getURLHttpSimpleLoad(),
100 frameUrl: getURLHttpSimpleLoad()
101 }
102 },
103 { label: "onBeforeSendHeaders-2",
104 event: "onBeforeSendHeaders",
105 details: {
106 url: getURLHttpSimpleLoad(),
107 requestHeadersValid: true
108 }
109 },
110 { label: "onSendHeaders-2",
111 event: "onSendHeaders",
112 details: {
113 url: getURLHttpSimpleLoad(),
114 requestHeadersValid: true
115 }
116 },
117 { label: "onResponseStarted",
118 event: "onResponseStarted",
119 details: {
120 url: getURLHttpSimpleLoad(),
121 statusCode: 200,
122 responseHeadersExist: true,
123 ip: "127.0.0.1",
124 fromCache: false,
125 statusLine: "HTTP/1.0 200 OK",
126 }
127 },
128 { label: "onCompleted",
129 event: "onCompleted",
130 details: {
131 url: getURLHttpSimpleLoad(),
132 statusCode: 200,
133 ip: "127.0.0.1",
134 fromCache: false,
135 responseHeadersExist: true,
136 statusLine: "HTTP/1.0 200 OK"
137 }
138 }
139 ],
140 [ // event order
141 ["onBeforeRequest-1", "onBeforeSendHeaders-1", "onSendHeaders-1",
142 "onBeforeRedirect",
143 "onBeforeRequest-2", "onBeforeSendHeaders-2", "onSendHeaders-2",
144 "onResponseStarted", "onCompleted"] ],
145 {}, // filter
146 ["requestHeaders", "responseHeaders", "statusLine"]);
147 navigateAndWait(getURLHttpSimpleLoadRedirect());
148 },
149
150 // Navigates to a non-existing page.
151 function nonExistingLoad() {
152 expect(
153 [ // events
154 { label: "onBeforeRequest",
155 event: "onBeforeRequest",
156 details: {
157 method: "GET",
158 tabId: tabId,
159 type: "main_frame",
160 url: getURL("does_not_exist.html"),
161 frameUrl: getURL("does_not_exist.html")
162 }
163 },
164 { label: "onErrorOccurred",
165 event: "onErrorOccurred",
166 details: {
167 url: getURL("does_not_exist.html"),
168 fromCache: false,
169 error: "net::ERR_FILE_NOT_FOUND",
170 // Request to chrome-extension:// url has no IP.
171 }
172 },
173 ],
174 [ // event order
175 ["onBeforeRequest", "onErrorOccurred"] ]);
176 navigateAndWait(getURL("does_not_exist.html"));
177 },
178 ]);
179 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698