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

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

Issue 2760733002: Check for already existing entry when adding to SiteProcessMap. (Closed)
Patch Set: Restore ordering of test cases in webRequestBlocking. Created 3 years, 9 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 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 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 pass = chrome.test.callbackPass; 5 var pass = chrome.test.callbackPass;
6 6
7 // Constants as functions, not to be called until after runTests. 7 // Constants as functions, not to be called until after runTests.
8 function getURLEchoUserAgent() { 8 function getURLEchoUserAgent() {
9 return getServerURL('echoheader?User-Agent'); 9 return getServerURL('echoheader?User-Agent');
10 } 10 }
(...skipping 18 matching lines...) Expand all
29 for (var i = 0; i < str.length; ++i) { 29 for (var i = 0; i < str.length; ++i) {
30 result[i] = str.charCodeAt(i); 30 result[i] = str.charCodeAt(i);
31 } 31 }
32 return result; 32 return result;
33 } 33 }
34 34
35 runTests([ 35 runTests([
36 // Navigates to a page with subresources, with a blocking handler that 36 // Navigates to a page with subresources, with a blocking handler that
37 // cancels the page request. The page will not load, and we should not 37 // cancels the page request. The page will not load, and we should not
38 // see the subresources. 38 // see the subresources.
39 function complexLoadCancelled() {
40 expect(
41 [ // events
42 { label: "onBeforeRequest",
43 event: "onBeforeRequest",
44 details: {
45 type: "main_frame",
46 url: getURL("complexLoad/b.html"),
47 frameUrl: getURL("complexLoad/b.html")
48 },
49 retval: {cancel: true}
50 },
51 // Cancelling is considered an error.
52 { label: "onErrorOccurred",
53 event: "onErrorOccurred",
54 details: {
55 url: getURL("complexLoad/b.html"),
56 fromCache: false,
57 error: "net::ERR_BLOCKED_BY_CLIENT"
58 // Request to chrome-extension:// url has no IP.
59 }
60 },
61 ],
62 [ // event order
63 ["onBeforeRequest", "onErrorOccurred"]
64 ],
65 {urls: ["<all_urls>"]}, // filter
66 ["blocking"]);
67 navigateAndWait(getURL("complexLoad/b.html"));
68 },
69
70 // Navigates to a page with subresources, with a blocking handler that
71 // cancels the page request. The page will not load, and we should not
72 // see the subresources.
39 function simpleLoadCancelledOnReceiveHeaders() { 73 function simpleLoadCancelledOnReceiveHeaders() {
40 expect( 74 expect(
41 [ // events 75 [ // events
42 { label: "onBeforeRequest", 76 { label: "onBeforeRequest",
43 event: "onBeforeRequest", 77 event: "onBeforeRequest",
44 details: { 78 details: {
45 method: "GET", 79 method: "GET",
46 type: "main_frame", 80 type: "main_frame",
47 url: getURLHttpSimpleLoad(), 81 url: getURLHttpSimpleLoad(),
48 frameUrl: getURLHttpSimpleLoad() 82 frameUrl: getURLHttpSimpleLoad()
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 ], 118 ],
85 [ // event order 119 [ // event order
86 ["onBeforeRequest", "onBeforeSendHeaders", "onSendHeaders", 120 ["onBeforeRequest", "onBeforeSendHeaders", "onSendHeaders",
87 "onHeadersReceived", "onErrorOccurred"] 121 "onHeadersReceived", "onErrorOccurred"]
88 ], 122 ],
89 {urls: ["<all_urls>"]}, // filter 123 {urls: ["<all_urls>"]}, // filter
90 ["blocking"]); 124 ["blocking"]);
91 navigateAndWait(getURLHttpSimpleLoad()); 125 navigateAndWait(getURLHttpSimpleLoad());
92 }, 126 },
93 127
94 // Navigates to a page with subresources, with a blocking handler that
95 // cancels the page request. The page will not load, and we should not
96 // see the subresources.
97 // TODO(nasko): This test was reordered in order to accommodate an
98 // unrelated failure (https://crbug.com/700514). Once that failure is fixed,
99 // the reordering should be reverted.
100 function complexLoadCancelled() {
101 expect(
102 [ // events
103 { label: "onBeforeRequest",
104 event: "onBeforeRequest",
105 details: {
106 type: "main_frame",
107 url: getURL("complexLoad/b.html"),
108 frameUrl: getURL("complexLoad/b.html")
109 },
110 retval: {cancel: true}
111 },
112 // Cancelling is considered an error.
113 { label: "onErrorOccurred",
114 event: "onErrorOccurred",
115 details: {
116 url: getURL("complexLoad/b.html"),
117 fromCache: false,
118 error: "net::ERR_BLOCKED_BY_CLIENT"
119 // Request to chrome-extension:// url has no IP.
120 }
121 },
122 ],
123 [ // event order
124 ["onBeforeRequest", "onErrorOccurred"]
125 ],
126 {urls: ["<all_urls>"]}, // filter
127 ["blocking"]);
128 navigateAndWait(getURL("complexLoad/b.html"));
129 },
130
131 // Navigates to a page and provides invalid header information. The request 128 // Navigates to a page and provides invalid header information. The request
132 // should continue as if the headers were not changed. 129 // should continue as if the headers were not changed.
133 function simpleLoadIgnoreOnBeforeSendHeadersInvalidHeaders() { 130 function simpleLoadIgnoreOnBeforeSendHeadersInvalidHeaders() {
134 expect( 131 expect(
135 [ // events 132 [ // events
136 { label: "onBeforeRequest", 133 { label: "onBeforeRequest",
137 event: "onBeforeRequest", 134 event: "onBeforeRequest",
138 details: { 135 details: {
139 method: "GET", 136 method: "GET",
140 type: "main_frame", 137 type: "main_frame",
(...skipping 996 matching lines...) Expand 10 before | Expand all | Expand 10 after
1137 [ // event order 1134 [ // event order
1138 ["onBeforeRequest-1", "onBeforeRedirect", "onBeforeRequest-2", 1135 ["onBeforeRequest-1", "onBeforeRedirect", "onBeforeRequest-2",
1139 "onBeforeSendHeaders", "onSendHeaders", "onHeadersReceived", 1136 "onBeforeSendHeaders", "onSendHeaders", "onHeadersReceived",
1140 "onResponseStarted", "onCompleted", 1137 "onResponseStarted", "onCompleted",
1141 "onBeforeRequest-3", "onErrorOccurred"], 1138 "onBeforeRequest-3", "onErrorOccurred"],
1142 ], 1139 ],
1143 {urls: ["<all_urls>"], types: ['image']}, // filter 1140 {urls: ["<all_urls>"], types: ['image']}, // filter
1144 ["blocking"]); 1141 ["blocking"]);
1145 navigateAndWait(frameUrl); 1142 navigateAndWait(frameUrl);
1146 } 1143 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698