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

Unified Diff: chrome/test/data/extensions/api_test/webrequest/framework.js

Issue 2449913002: Support WebSocket in WebRequest API. (Closed)
Patch Set: Refactor tests; add test; update documentation. Created 3 years, 10 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 side-by-side diff with in-line comments
Download patch
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..1ae2290dc4e04cc227c9b3d9adce0fb868bc1300 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
Devlin 2017/02/14 01:21:38 When will this be?
pkalinnikov 2017/02/14 13:49:51 I was thinking to address this in a follow-up CL.
Devlin 2017/02/14 15:55:24 I don't think this should be too complicated, and
pkalinnikov 2017/02/15 19:15:00 Added new type in a separate CL.
+ // introduced for the WebSocket requests.
+ 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.

Powered by Google App Engine
This is Rietveld 408576698