| 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 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 expectedEventOrder; | 9 var expectedEventOrder; |
| 10 var tabId; | 10 var tabId; |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 // webRequest API. | 62 // webRequest API. |
| 63 // extraInfoSpec: the union of all desired extraInfoSpecs for the events. | 63 // extraInfoSpec: the union of all desired extraInfoSpecs for the events. |
| 64 function expect(data, order, filter, extraInfoSpec) { | 64 function expect(data, order, filter, extraInfoSpec) { |
| 65 expectedEventData = data; | 65 expectedEventData = data; |
| 66 capturedEventData = []; | 66 capturedEventData = []; |
| 67 expectedEventOrder = order; | 67 expectedEventOrder = order; |
| 68 eventsCaptured = chrome.test.callbackAdded(); | 68 eventsCaptured = chrome.test.callbackAdded(); |
| 69 tabAndFrameUrls = {}; // Maps "{tabId}-{frameId}" to the URL of the frame. | 69 tabAndFrameUrls = {}; // Maps "{tabId}-{frameId}" to the URL of the frame. |
| 70 frameIdMap = {"-1": -1}; | 70 frameIdMap = {"-1": -1}; |
| 71 removeListeners(); | 71 removeListeners(); |
| 72 initListeners(filter || {}, extraInfoSpec || []); | 72 initListeners(filter || {urls: ["<all_urls>"]}, extraInfoSpec || []); |
| 73 // Fill in default values. | 73 // Fill in default values. |
| 74 for (var i = 0; i < expectedEventData.length; ++i) { | 74 for (var i = 0; i < expectedEventData.length; ++i) { |
| 75 if (!('method' in expectedEventData[i].details)) { | 75 if (!('method' in expectedEventData[i].details)) { |
| 76 expectedEventData[i].details.method = "GET"; | 76 expectedEventData[i].details.method = "GET"; |
| 77 } | 77 } |
| 78 if (!('tabId' in expectedEventData[i].details)) { | 78 if (!('tabId' in expectedEventData[i].details)) { |
| 79 expectedEventData[i].details.tabId = tabIdMap[tabId]; | 79 expectedEventData[i].details.tabId = tabIdMap[tabId]; |
| 80 } | 80 } |
| 81 if (!('frameId' in expectedEventData[i].details)) { | 81 if (!('frameId' in expectedEventData[i].details)) { |
| 82 expectedEventData[i].details.frameId = 0; | 82 expectedEventData[i].details.frameId = 0; |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 290 helper(chrome.webRequest.onBeforeRequest); | 290 helper(chrome.webRequest.onBeforeRequest); |
| 291 helper(chrome.webRequest.onBeforeSendHeaders); | 291 helper(chrome.webRequest.onBeforeSendHeaders); |
| 292 helper(chrome.webRequest.onAuthRequired); | 292 helper(chrome.webRequest.onAuthRequired); |
| 293 helper(chrome.webRequest.onSendHeaders); | 293 helper(chrome.webRequest.onSendHeaders); |
| 294 helper(chrome.webRequest.onHeadersReceived); | 294 helper(chrome.webRequest.onHeadersReceived); |
| 295 helper(chrome.webRequest.onResponseStarted); | 295 helper(chrome.webRequest.onResponseStarted); |
| 296 helper(chrome.webRequest.onBeforeRedirect); | 296 helper(chrome.webRequest.onBeforeRedirect); |
| 297 helper(chrome.webRequest.onCompleted); | 297 helper(chrome.webRequest.onCompleted); |
| 298 helper(chrome.webRequest.onErrorOccurred); | 298 helper(chrome.webRequest.onErrorOccurred); |
| 299 } | 299 } |
| OLD | NEW |