Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / chrome / test / data / extensions / api_test / webrequest / test_simple.js
blob5a2218dc838d5ee753837db70b87d6ddc8133e8a
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 // Constants as functions, not to be called until after runTests.
6 function getURLHttpSimpleLoad() {
7 return getServerURL('extensions/api_test/webrequest/simpleLoad/a.html');
10 function getURLHttpSimpleLoadRedirect() {
11 return getServerURL('server-redirect?'+getURLHttpSimpleLoad());
14 runTests([
15 // Navigates to a blank page.
16 function simpleLoad() {
17 expect(
18 [ // events
19 { label: "a-onBeforeRequest",
20 event: "onBeforeRequest",
21 details: {
22 url: getURL("simpleLoad/a.html"),
23 frameUrl: getURL("simpleLoad/a.html")
26 { label: "a-onResponseStarted",
27 event: "onResponseStarted",
28 details: {
29 url: getURL("simpleLoad/a.html"),
30 statusCode: 200,
31 fromCache: false,
32 statusLine: "HTTP/1.1 200 OK",
33 // Request to chrome-extension:// url has no IP.
36 { label: "a-onCompleted",
37 event: "onCompleted",
38 details: {
39 url: getURL("simpleLoad/a.html"),
40 statusCode: 200,
41 fromCache: false,
42 statusLine: "HTTP/1.1 200 OK",
43 // Request to chrome-extension:// url has no IP.
47 [ // event order
48 ["a-onBeforeRequest", "a-onResponseStarted", "a-onCompleted"] ]);
49 navigateAndWait(getURL("simpleLoad/a.html"));
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 url: getURLHttpSimpleLoadRedirect(),
61 frameUrl: getURLHttpSimpleLoadRedirect()
64 { label: "onBeforeSendHeaders-1",
65 event: "onBeforeSendHeaders",
66 details: {
67 url: getURLHttpSimpleLoadRedirect(),
68 requestHeadersValid: true
71 { label: "onSendHeaders-1",
72 event: "onSendHeaders",
73 details: {
74 url: getURLHttpSimpleLoadRedirect(),
75 requestHeadersValid: true
78 { label: "onHeadersReceived-1",
79 event: "onHeadersReceived",
80 details: {
81 url: getURLHttpSimpleLoadRedirect(),
82 responseHeadersExist: true,
83 statusLine: "HTTP/1.1 301 Moved Permanently",
84 statusCode: 301
87 { label: "onBeforeRedirect",
88 event: "onBeforeRedirect",
89 details: {
90 url: getURLHttpSimpleLoadRedirect(),
91 redirectUrl: getURLHttpSimpleLoad(),
92 statusCode: 301,
93 responseHeadersExist: true,
94 ip: "127.0.0.1",
95 fromCache: false,
96 statusLine: "HTTP/1.1 301 Moved Permanently"
99 { label: "onBeforeRequest-2",
100 event: "onBeforeRequest",
101 details: {
102 url: getURLHttpSimpleLoad(),
103 frameUrl: getURLHttpSimpleLoad()
106 { label: "onBeforeSendHeaders-2",
107 event: "onBeforeSendHeaders",
108 details: {
109 url: getURLHttpSimpleLoad(),
110 requestHeadersValid: true
113 { label: "onSendHeaders-2",
114 event: "onSendHeaders",
115 details: {
116 url: getURLHttpSimpleLoad(),
117 requestHeadersValid: true
120 { label: "onHeadersReceived-2",
121 event: "onHeadersReceived",
122 details: {
123 url: getURLHttpSimpleLoad(),
124 responseHeadersExist: true,
125 statusLine: "HTTP/1.1 200 OK",
126 statusCode: 200
129 { label: "onResponseStarted",
130 event: "onResponseStarted",
131 details: {
132 url: getURLHttpSimpleLoad(),
133 statusCode: 200,
134 responseHeadersExist: true,
135 ip: "127.0.0.1",
136 fromCache: false,
137 statusLine: "HTTP/1.1 200 OK",
140 { label: "onCompleted",
141 event: "onCompleted",
142 details: {
143 url: getURLHttpSimpleLoad(),
144 statusCode: 200,
145 ip: "127.0.0.1",
146 fromCache: false,
147 responseHeadersExist: true,
148 statusLine: "HTTP/1.1 200 OK"
152 [ // event order
153 ["onBeforeRequest-1", "onBeforeSendHeaders-1", "onSendHeaders-1",
154 "onHeadersReceived-1", "onBeforeRedirect",
155 "onBeforeRequest-2", "onBeforeSendHeaders-2", "onSendHeaders-2",
156 "onHeadersReceived-2", "onResponseStarted", "onCompleted"] ],
157 {urls: ["<all_urls>"]}, // filter
158 ["requestHeaders", "responseHeaders"]);
159 navigateAndWait(getURLHttpSimpleLoadRedirect());
162 // Navigates to a non-existing page.
163 function nonExistingLoad() {
164 expect(
165 [ // events
166 { label: "onBeforeRequest",
167 event: "onBeforeRequest",
168 details: {
169 url: getURL("does_not_exist.html"),
170 frameUrl: getURL("does_not_exist.html")
173 { label: "onErrorOccurred",
174 event: "onErrorOccurred",
175 details: {
176 url: getURL("does_not_exist.html"),
177 fromCache: false,
178 error: "net::ERR_FILE_NOT_FOUND",
179 // Request to chrome-extension:// url has no IP.
183 [ // event order
184 ["onBeforeRequest", "onErrorOccurred"] ]);
185 navigateAndWait(getURL("does_not_exist.html"));