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

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

Issue 1997253002: webRequest: Set frameId on beacon/ping requests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@webRequest-tabId
Patch Set: Re-use dispatchWillSendRequest Created 4 years, 7 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 unified diff | Download patch
« no previous file with comments | « no previous file | chrome/test/data/extensions/api_test/webrequest/test_types.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 // a request with the given details. If the method returns true, the event 174 // a request with the given details. If the method returns true, the event
175 // should be ignored. 175 // should be ignored.
176 function isUnexpectedDetachedRequest(name, details) { 176 function isUnexpectedDetachedRequest(name, details) {
177 // This function is responsible for marking detached requests as unexpected. 177 // This function is responsible for marking detached requests as unexpected.
178 // Non-detached requests are not this function's concern. 178 // Non-detached requests are not this function's concern.
179 if (details.tabId !== -1 || details.frameId >= 0) 179 if (details.tabId !== -1 || details.frameId >= 0)
180 return false; 180 return false;
181 181
182 // Only return true if there is no matching expectation for the given details. 182 // Only return true if there is no matching expectation for the given details.
183 return !expectedEventData.some(function(exp) { 183 return !expectedEventData.some(function(exp) {
184 var didMatchTabAndFrameId =
185 exp.details.tabId === -1 &&
186 exp.details.frameId === -1;
187
188 // Accept non-matching tabId/frameId for ping/beacon requests because these
189 // requests can continue after a frame is removed. And due to a bug, such
190 // requests have a tabId/frameId of -1.
191 // The test will fail anyway, but then with a helpful error (expectation
192 // differs from actual events) instead of an obscure test timeout.
193 // TODO(robwu): Remove this once https://crbug.com/522129 gets fixed.
194 didMatchTabAndFrameId = didMatchTabAndFrameId || details.type === 'ping';
195
184 return name === exp.event && 196 return name === exp.event &&
185 exp.details.tabId === -1 && 197 didMatchTabAndFrameId &&
186 exp.details.frameId === -1 &&
187 exp.details.method === details.method && 198 exp.details.method === details.method &&
188 exp.details.url === details.url && 199 exp.details.url === details.url &&
189 exp.details.type === details.type; 200 exp.details.type === details.type;
190 }); 201 });
191 } 202 }
192 203
193 function captureEvent(name, details, callback) { 204 function captureEvent(name, details, callback) {
194 // Ignore system-level requests like safebrowsing updates and favicon fetches 205 // Ignore system-level requests like safebrowsing updates and favicon fetches
195 // since they are unpredictable. 206 // since they are unpredictable.
196 if (details.type == "other" || 207 if (details.type == "other" ||
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 helper('onHeadersReceived'); 413 helper('onHeadersReceived');
403 helper('onResponseStarted'); 414 helper('onResponseStarted');
404 helper('onBeforeRedirect'); 415 helper('onBeforeRedirect');
405 helper('onCompleted'); 416 helper('onCompleted');
406 helper('onErrorOccurred'); 417 helper('onErrorOccurred');
407 } 418 }
408 419
409 function resetDeclarativeRules() { 420 function resetDeclarativeRules() {
410 chrome.declarativeWebRequest.onRequest.removeRules(); 421 chrome.declarativeWebRequest.onRequest.removeRules();
411 } 422 }
OLDNEW
« no previous file with comments | « no previous file | chrome/test/data/extensions/api_test/webrequest/test_types.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698