OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 getURL = chrome.extension.getURL; | 5 var getURL = chrome.extension.getURL; |
6 var deepEq = chrome.test.checkDeepEq; | 6 var deepEq = chrome.test.checkDeepEq; |
7 var expectedEventData; | 7 var expectedEventData; |
8 var capturedEventData; | 8 var capturedEventData; |
9 var capturedUnexpectedData; | 9 var capturedUnexpectedData; |
10 var expectedEventOrder; | 10 var expectedEventOrder; |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 return name === exp.event && | 184 return name === exp.event && |
185 exp.details.tabId === -1 && | 185 exp.details.tabId === -1 && |
186 exp.details.frameId === -1 && | 186 exp.details.frameId === -1 && |
187 exp.details.method === details.method && | 187 exp.details.method === details.method && |
188 exp.details.url === details.url && | 188 exp.details.url === details.url && |
189 exp.details.type === details.type; | 189 exp.details.type === details.type; |
190 }); | 190 }); |
191 } | 191 } |
192 | 192 |
193 function captureEvent(name, details, callback) { | 193 function captureEvent(name, details, callback) { |
194 // frameId should be -1 or positive, but is sometimes -2 (MSG_ROUTING_NONE). | |
195 // TODO(robwu): This will be resolved once crbug.com/432875 is resolved. | |
196 if (details.frameId === -2) | |
197 details.frameId = -1; | |
198 | |
199 // Ignore system-level requests like safebrowsing updates and favicon fetches | 194 // Ignore system-level requests like safebrowsing updates and favicon fetches |
200 // since they are unpredictable. | 195 // since they are unpredictable. |
201 if (details.type == "other" || | 196 if (details.type == "other" || |
202 isUnexpectedDetachedRequest(name, details) || | 197 isUnexpectedDetachedRequest(name, details) || |
203 details.url.match(/\/favicon.ico$/) || | 198 details.url.match(/\/favicon.ico$/) || |
204 details.url.match(/https:\/\/dl.google.com/)) | 199 details.url.match(/https:\/\/dl.google.com/)) |
205 return; | 200 return; |
206 | 201 |
207 // Pull the extra per-event options out of the expected data. These let | 202 // Pull the extra per-event options out of the expected data. These let |
208 // us specify special return values per event. | 203 // us specify special return values per event. |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
407 helper('onHeadersReceived'); | 402 helper('onHeadersReceived'); |
408 helper('onResponseStarted'); | 403 helper('onResponseStarted'); |
409 helper('onBeforeRedirect'); | 404 helper('onBeforeRedirect'); |
410 helper('onCompleted'); | 405 helper('onCompleted'); |
411 helper('onErrorOccurred'); | 406 helper('onErrorOccurred'); |
412 } | 407 } |
413 | 408 |
414 function resetDeclarativeRules() { | 409 function resetDeclarativeRules() { |
415 chrome.declarativeWebRequest.onRequest.removeRules(); | 410 chrome.declarativeWebRequest.onRequest.removeRules(); |
416 } | 411 } |
OLD | NEW |