Chromium Code Reviews| Index: chrome/test/data/extensions/api_test/webrequest/framework.js |
| diff --git a/chrome/test/data/extensions/api_test/webrequest/framework.js b/chrome/test/data/extensions/api_test/webrequest/framework.js |
| index 461ee561896b5e2b930c0f9bc90c3a00faea25f4..6c272090c280cbf42a2d8211304ae6e5dd036d44 100644 |
| --- a/chrome/test/data/extensions/api_test/webrequest/framework.js |
| +++ b/chrome/test/data/extensions/api_test/webrequest/framework.js |
| @@ -11,6 +11,7 @@ var expectedEventOrder; |
| var tabId; |
| var tabIdMap; |
| var frameIdMap; |
| +var testWebSocketPort; |
| var testServerPort; |
| var testServer = "www.a.com"; |
| var defaultScheme = "http"; |
| @@ -36,17 +37,24 @@ var ignoreUnexpected = false; |
| // information whether they were expected. |
| var logAllRequests = false; |
| +// Runs the |tests| using the |tab| as a default tab. |
| +function runTestsForTab(tests, tab) { |
| + tabId = tab.id; |
| + tabIdMap = {"-1": -1}; |
| + tabIdMap[tabId] = 0; |
| + chrome.test.getConfig(function(config) { |
| + testServerPort = config.testServer.port; |
| + testWebSocketPort = config.testWebSocketPort; |
| + chrome.test.runTests(tests); |
| + }); |
| +} |
| + |
| +// Creates an "about:blank" tab and runs |tests| with this tab as default. |
| function runTests(tests) { |
| var waitForAboutBlank = function(_, info, tab) { |
| if (info.status == "complete" && tab.url == "about:blank") { |
| - tabId = tab.id; |
| - tabIdMap = {"-1": -1}; |
| - tabIdMap[tabId] = 0; |
| chrome.tabs.onUpdated.removeListener(waitForAboutBlank); |
| - chrome.test.getConfig(function(config) { |
| - testServerPort = config.testServer.port; |
| - chrome.test.runTests(tests); |
| - }); |
| + runTestsForTab(tests, tab); |
| } |
| }; |
| chrome.tabs.onUpdated.addListener(waitForAboutBlank); |
| @@ -204,11 +212,15 @@ function isUnexpectedDetachedRequest(name, details) { |
| function captureEvent(name, details, callback) { |
| // Ignore system-level requests like safebrowsing updates and favicon fetches |
| // since they are unpredictable. |
| - if ((details.type == "other" && !details.url.includes('dont-ignore-me')) || |
| + // TODO(pkalinnikov): Remove the startsWith('ws') check once a new type gets |
| + // introduced for the WebSocket requests. |
|
Devlin
2017/02/21 16:10:44
This is done, right?
pkalinnikov
2017/02/21 19:18:16
Done.
|
| + if ((details.type == "other" && !details.url.includes('dont-ignore-me') && |
| + !details.url.startsWith('ws')) || |
| isUnexpectedDetachedRequest(name, details) || |
| details.url.match(/\/favicon.ico$/) || |
| - details.url.match(/https:\/\/dl.google.com/)) |
| + details.url.match(/https:\/\/dl.google.com/)) { |
| return; |
| + } |
| // Pull the extra per-event options out of the expected data. These let |
| // us specify special return values per event. |
| @@ -338,7 +350,7 @@ function initListeners(filter, extraInfoSpec) { |
| }; |
| listeners['onHeadersReceived'].push(onHeadersReceived); |
| - var onAuthRequired = function(details) { |
| + var onAuthRequired = function(details, callback) { |
| return captureEvent("onAuthRequired", details, callback); |
| }; |
| listeners['onAuthRequired'].push(onAuthRequired); |