Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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. | |
| 73 function simpleLoadCancelledOnReceiveHeaders() { | 39 function simpleLoadCancelledOnReceiveHeaders() { |
| 74 expect( | 40 expect( |
| 75 [ // events | 41 [ // events |
| 76 { label: "onBeforeRequest", | 42 { label: "onBeforeRequest", |
| 77 event: "onBeforeRequest", | 43 event: "onBeforeRequest", |
| 78 details: { | 44 details: { |
| 79 method: "GET", | 45 method: "GET", |
| 80 type: "main_frame", | 46 type: "main_frame", |
| 81 url: getURLHttpSimpleLoad(), | 47 url: getURLHttpSimpleLoad(), |
| 82 frameUrl: getURLHttpSimpleLoad() | 48 frameUrl: getURLHttpSimpleLoad() |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 118 ], | 84 ], |
| 119 [ // event order | 85 [ // event order |
| 120 ["onBeforeRequest", "onBeforeSendHeaders", "onSendHeaders", | 86 ["onBeforeRequest", "onBeforeSendHeaders", "onSendHeaders", |
| 121 "onHeadersReceived", "onErrorOccurred"] | 87 "onHeadersReceived", "onErrorOccurred"] |
| 122 ], | 88 ], |
| 123 {urls: ["<all_urls>"]}, // filter | 89 {urls: ["<all_urls>"]}, // filter |
| 124 ["blocking"]); | 90 ["blocking"]); |
| 125 navigateAndWait(getURLHttpSimpleLoad()); | 91 navigateAndWait(getURLHttpSimpleLoad()); |
| 126 }, | 92 }, |
| 127 | 93 |
| 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. | |
|
Devlin
2017/03/16 18:38:14
add something like:
TODO(nasko): This test was reo
nasko
2017/03/16 18:47:49
Done.
| |
| 97 function complexLoadCancelled() { | |
| 98 expect( | |
| 99 [ // events | |
| 100 { label: "onBeforeRequest", | |
| 101 event: "onBeforeRequest", | |
| 102 details: { | |
| 103 type: "main_frame", | |
| 104 url: getURL("complexLoad/b.html"), | |
| 105 frameUrl: getURL("complexLoad/b.html") | |
| 106 }, | |
| 107 retval: {cancel: true} | |
| 108 }, | |
| 109 // Cancelling is considered an error. | |
| 110 { label: "onErrorOccurred", | |
| 111 event: "onErrorOccurred", | |
| 112 details: { | |
| 113 url: getURL("complexLoad/b.html"), | |
| 114 fromCache: false, | |
| 115 error: "net::ERR_BLOCKED_BY_CLIENT" | |
| 116 // Request to chrome-extension:// url has no IP. | |
| 117 } | |
| 118 }, | |
| 119 ], | |
| 120 [ // event order | |
| 121 ["onBeforeRequest", "onErrorOccurred"] | |
| 122 ], | |
| 123 {urls: ["<all_urls>"]}, // filter | |
| 124 ["blocking"]); | |
| 125 navigateAndWait(getURL("complexLoad/b.html")); | |
| 126 }, | |
| 127 | |
| 128 // Navigates to a page and provides invalid header information. The request | 128 // Navigates to a page and provides invalid header information. The request |
| 129 // should continue as if the headers were not changed. | 129 // should continue as if the headers were not changed. |
| 130 function simpleLoadIgnoreOnBeforeSendHeadersInvalidHeaders() { | 130 function simpleLoadIgnoreOnBeforeSendHeadersInvalidHeaders() { |
| 131 expect( | 131 expect( |
| 132 [ // events | 132 [ // events |
| 133 { label: "onBeforeRequest", | 133 { label: "onBeforeRequest", |
| 134 event: "onBeforeRequest", | 134 event: "onBeforeRequest", |
| 135 details: { | 135 details: { |
| 136 method: "GET", | 136 method: "GET", |
| 137 type: "main_frame", | 137 type: "main_frame", |
| (...skipping 996 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1134 [ // event order | 1134 [ // event order |
| 1135 ["onBeforeRequest-1", "onBeforeRedirect", "onBeforeRequest-2", | 1135 ["onBeforeRequest-1", "onBeforeRedirect", "onBeforeRequest-2", |
| 1136 "onBeforeSendHeaders", "onSendHeaders", "onHeadersReceived", | 1136 "onBeforeSendHeaders", "onSendHeaders", "onHeadersReceived", |
| 1137 "onResponseStarted", "onCompleted", | 1137 "onResponseStarted", "onCompleted", |
| 1138 "onBeforeRequest-3", "onErrorOccurred"], | 1138 "onBeforeRequest-3", "onErrorOccurred"], |
| 1139 ], | 1139 ], |
| 1140 {urls: ["<all_urls>"], types: ['image']}, // filter | 1140 {urls: ["<all_urls>"], types: ['image']}, // filter |
| 1141 ["blocking"]); | 1141 ["blocking"]); |
| 1142 navigateAndWait(frameUrl); | 1142 navigateAndWait(frameUrl); |
| 1143 } | 1143 } |
| OLD | NEW |