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

Side by Side Diff: chrome/test/data/predictor/fetch_cross_site.js

Issue 1881463003: Add a browsertest suite for net predictor (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: EXPECT that we get the right number of accepted connections after waiting 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
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 // This script file should be requested with the following query params:
6 // subresourceHost: The base url of the embedded test server to request
7 // subresources from.
8 // numCORSResources: The number of resources to request (between 0 and 3).
9 var queryString = window.location.search.substring(1);
10 var vars = queryString.split("&");
11 var parsedParams = {};
12 vars.forEach(function(v) {
13 var key_value = v.split('=');
14 parsedParams[key_value[0]] = key_value[1];
15 });
16 var subresourceHost = parsedParams['subresourceHost'];
17 var numCORSResources = parseInt(parsedParams['numCORSResources'], 10);
18 var sendImmediately = parseInt(parsedParams['sendImmediately'], 10);
19 var subresourceList = [
20 'predictor/empty.js',
21 'predictor/empty1.js',
22 'predictor/empty2.js',
23 ];
24 var CORSSubresources = subresourceList.slice(0, numCORSResources);
25
26 var numOK = 0;
27 function logResponse(r) {
28 // Opaque responses are not necessarily network errors. We get them when we
29 // make cross origin requests with no-cors.
30 if (r.status == 200 || r.type == "opaque") {
31 numOK++;
32 if (numOK == numCORSResources) {
33 window.domAutomationController.send(true);
34 }
35 } else {
36 window.domAutomationController.send(false);
37 }
38 }
39
40 function startFetchesAndWaitForReply() {
41 CORSSubresources.forEach(function(r) {
42 fetch(subresourceHost + r, {mode: 'cors', method: 'get'}).then(logResponse);
43 });
44 }
45
46 if (sendImmediately) {
47 startFetchesAndWaitForReply();
48 }
OLDNEW
« no previous file with comments | « chrome/test/data/predictor/empty2.js.mock-http-headers ('k') | chrome/test/data/predictor/predictor_cross_site.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698