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

Side by Side Diff: chrome/test/data/webui/net_internals/http_pipeline_view.js

Issue 275953002: Remove HTTP pipelining support. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix line endings Created 6 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 | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 // Include test fixture.
6 GEN_INCLUDE(['net_internals_test.js']);
7
8 // Anonymous namespace
9 (function() {
10
11 /**
12 * Checks the display on the HTTP Pipelining tab against the information it
13 * should be displaying.
14 * @param {object} httpPipelineStatus Results from a http pipeline status query.
15 */
16 function checkDisplay(httpPipelineStatus) {
17 expectEquals(httpPipelineStatus.pipelining_enabled,
18 $(HttpPipelineView.ENABLED_SPAN_ID).innerText == "true");
19 }
20
21 /**
22 * Finds an entry with the specified host name and port in the
23 * |pipelinedHostInfo| cache, and returns its index.
24 * @param {object} pipelinedHostInfo Results to search.
25 * @param {string} hostname The host name of the host to find.
26 * @param {int} port The port of the host to find.
27 * @return {int} Index of the specified host. -1 if not found.
28 */
29 function findEntry(pipelinedHostInfo, hostname, port) {
30 var expected = hostname + ":" + port;
31 for (var i = 0; i < pipelinedHostInfo.length; ++i) {
32 if (pipelinedHostInfo[i].host == expected)
33 return i;
34 }
35 return -1;
36 }
37
38 /**
39 * A Task that adds a pipeline capability to the known hosts map and waits for
40 * it to appear in the data we receive from the browser.
41 * @param {string} hostname Name of host address we're waiting for.
42 * @param {int} port Port of the host we're waiting for.
43 * @param {string} capability The capability to set.
44 * @extends {NetInternalsTest.Task}
45 */
46 function AddPipelineCapabilityTask(hostname, port, capability) {
47 this.hostname_ = hostname;
48 this.port_ = port;
49 this.capability_ = capability;
50 NetInternalsTest.Task.call(this);
51 }
52
53 AddPipelineCapabilityTask.prototype = {
54 __proto__: NetInternalsTest.Task.prototype,
55
56 /**
57 * Adds an entry to the host map and starts waiting to receive the results
58 * from the browser process.
59 */
60 start: function() {
61 var addPipelineCapabilityParams = [
62 this.hostname_,
63 this.port_,
64 this.capability_
65 ];
66 chrome.send('addDummyHttpPipelineFeedback', addPipelineCapabilityParams);
67 g_browser.addHttpPipeliningStatusObserver(this, false);
68 },
69
70 /**
71 * Callback from the BrowserBridge. Checks if |httpPipelineStatus| has the
72 * known host specified on creation. If so, validates it and completes the
73 * task. If not, continues running.
74 * @param {object} httpPipelineStatus Result of a http pipeline status query.
75 */
76 onHttpPipeliningStatusChanged: function(httpPipelineStatus) {
77 if (!this.isDone()) {
78 checkDisplay(httpPipelineStatus);
79
80 var index = findEntry(httpPipelineStatus.pipelined_host_info,
81 this.hostname_, this.port_);
82 if (index >= 0) {
83 var entry = httpPipelineStatus.pipelined_host_info[index];
84 expectEquals(this.capability_, entry.capability);
85
86 var hostPortText = NetInternalsTest.getTbodyText(
87 HttpPipelineView.KNOWN_HOSTS_TABLE_ID, index, 0);
88 expectEquals(this.hostname_ + ":" + this.port_, hostPortText);
89 var capabilityText = NetInternalsTest.getTbodyText(
90 HttpPipelineView.KNOWN_HOSTS_TABLE_ID, index, 1);
91 expectEquals(this.capability_, capabilityText);
92
93 this.onTaskDone();
94 }
95 }
96 }
97 };
98
99 /**
100 * Adds a capable pipelining host.
101 */
102 TEST_F('NetInternalsTest', 'netInternalsHttpPipelineViewCapable', function() {
103 // Since this is called before we switch to the HTTP Pipelining view, we'll
104 // never see the original pipelining state.
105 chrome.send('enableHttpPipelining', [true]);
106
107 NetInternalsTest.switchToView('httpPipeline');
108 var taskQueue = new NetInternalsTest.TaskQueue(true);
109 taskQueue.addTask(new AddPipelineCapabilityTask(
110 'somewhere.com', 80, 'capable'));
111 taskQueue.run(true);
112 });
113
114 /**
115 * Adds an incapable pipelining host.
116 */
117 TEST_F('NetInternalsTest', 'netInternalsHttpPipelineViewIncapable', function() {
118 // Since this is called before we switch to the HTTP Pipelining view, we'll
119 // never see the original pipelining state.
120 chrome.send('enableHttpPipelining', [true]);
121
122 NetInternalsTest.switchToView('httpPipeline');
123 var taskQueue = new NetInternalsTest.TaskQueue(true);
124 taskQueue.addTask(new AddPipelineCapabilityTask(
125 'elsewhere.com', 1234, 'incapable'));
126 taskQueue.run(true);
127 });
128
129 /**
130 * Checks with pipelining disabled.
131 * TODO(mmenke): Make this test wait to receive pipelining state. Currently
132 * just checks the default state, before data is received.
133 */
134 TEST_F('NetInternalsTest', 'netInternalsHttpPipelineViewDisabled', function() {
135 NetInternalsTest.switchToView('httpPipeline');
136 var expected_status = { pipelining_enabled: false }
137 checkDisplay(expected_status);
138 testDone();
139 });
140
141 })(); // Anonymous namespace
OLDNEW
« no previous file with comments | « chrome/test/data/http_pipelining/alphabet.txt.mock-http-headers ('k') | chrome/test/data/webui/net_internals/log_util.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698