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

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

Issue 704493002: Revert "Sdch view for net-internals" (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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 2014 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 SDCH tab against the information it should be
13 * displaying.
14 * @param {object} sdchInfo Results from a sdch manager info query.
15 */
16 function checkDisplay(sdchInfo) {
17 expectEquals(sdchInfo.sdch_enabled,
18 $(SdchView.SDCH_ENABLED_SPAN_ID).innerText === 'true');
19 expectEquals(sdchInfo.secure_scheme_support,
20 $(SdchView.SECURE_SCHEME_SUPPORT_SPAN_ID).innerText === 'true');
21 NetInternalsTest.checkTbodyRows(SdchView.BLACKLIST_TBODY_ID,
22 sdchInfo.blacklisted.length);
23 NetInternalsTest.checkTbodyRows(SdchView.DICTIONARIES_TBODY_ID,
24 sdchInfo.dictionaries.length);
25
26 // Rather than check the exact string in every position, just make sure every
27 // entry does not have 'undefined' anywhere and certain entries are not empty,
28 // which should find a fair number of potential output errors.
29 for (var row = 0; row < sdchInfo.blacklisted.length; ++row) {
30 for (var column = 0; column < 3; ++column) {
31 var text = NetInternalsTest.getTbodyText(
32 SdchView.BLACKLIST_TBODY_ID, row, column);
33 expectNotEquals(text, '');
34 expectFalse(/undefined/i.test(text));
35 }
36 }
37
38
39 for (var row = 0; row < sdchInfo.dictionaries.length; ++row) {
40 for (var column = 0; column < 6; ++column) {
41 var text = NetInternalsTest.getTbodyText(
42 SdchView.DICTIONARIES_TBODY_ID, row, column);
43 expectFalse(/undefined/i.test(text));
44 if (column === 0) {
45 // At least Domain cell should not be empty.
46 expectNotEquals(text, '');
47 }
48 }
49 }
50 }
51
52 /**
53 * A Task that loads provided page and waits for the SDCH dictionary to be
54 * downloaded. The page response headers should provide Get-Dictionary header.
55 * @extends {NetInternalsTest.Task}
56 */
57 function LoadSdchDictionaryTask() {
58 NetInternalsTest.Task.call(this);
59 }
60
61 LoadSdchDictionaryTask.prototype = {
62 __proto__: NetInternalsTest.Task.prototype,
63
64 /**
65 * Navigates to the page and starts waiting to receive the results from
66 * the browser process.
67 */
68 start: function(url) {
69 g_browser.addSdchInfoObserver(this, false)
70 NetInternalsTest.switchToView('sdch');
71 // 127.0.0.1 is not allowed to be an SDCH domain, use test domain.
72 url = url.replace('127.0.0.1', 'testdomain.com');
73 this.url_ = url;
74 console.log(url);
75 chrome.send('loadPage', [url]);
76 },
77
78 /**
79 * Callback from the BrowserBridge. Checks if |sdchInfo| has the SDCH
80 * dictionary info for the dictionary the page has advertised. If so,
81 * validates it and completes the task. If not, continues running.
82 * @param {object} sdchInfo Results of a SDCH manager info query.
83 */
84 onSdchInfoChanged: function(sdchInfo) {
85 if (this.isDone())
86 return;
87
88 checkDisplay(sdchInfo);
89
90 if (sdchInfo.dictionaries.length > 0) {
91 var testDict = sdchInfo.dictionaries.filter(function(dictionary) {
92 return dictionary.domain === 'testdomain.com';
93 });
94 if (testDict.length === 0)
95 return;
96
97 expectEquals(1, testDict.length);
98 var dict = testDict[0];
99 expectEquals('/', dict.path);
100 expectTrue(dict.url.indexOf('/files/sdch/dict') !== -1);
101
102 var tableId = SdchView.DICTIONARIES_TBODY_ID;
103 var domain = NetInternalsTest.getTbodyText(tableId, 0, 0);
104 var path = NetInternalsTest.getTbodyText(tableId, 0, 1);
105 var url = NetInternalsTest.getTbodyText(tableId, 0, 5);
106
107 expectEquals(dict.domain, domain);
108 expectEquals(dict.path, path);
109 expectEquals(dict.url, url);
110
111 this.onTaskDone(this.url_);
112 }
113 }
114 };
115
116 /**
117 * A Task that loads provided page and waits for its domain to appear in SDCH
118 * blacklist with the specified reason.
119 * @param {string} reason Blacklist reason we're waiting for.
120 * @extends {NetInternalsTest.Task}
121 */
122 function LoadPageWithDecodeErrorTask(reason) {
123 NetInternalsTest.Task.call(this);
124 this.reason_ = reason;
125 }
126
127 LoadPageWithDecodeErrorTask.prototype = {
128 __proto__: NetInternalsTest.Task.prototype,
129
130 /**
131 * Navigates to the page and starts waiting to receive the results from
132 * the browser process.
133 */
134 start: function(url) {
135 g_browser.addSdchInfoObserver(this, false)
136 NetInternalsTest.switchToView('sdch');
137 // 127.0.0.1 is not allowed to be an SDCH domain, so we need another one.
138 url = url.replace('127.0.0.1', 'testdomain.com');
139 console.log(url);
140 chrome.send('loadPage', [url]);
141 },
142
143 /**
144 * Callback from the BrowserBridge. Checks if |sdchInfo.blacklisted| contains
145 * the test domain with the reason specified on creation. If so, validates it
146 * and completes the task. If not, continues running.
147 * @param {object} sdchInfo Results of SDCH manager info query.
148 */
149 onSdchInfoChanged: function(sdchInfo) {
150 if (this.isDone())
151 return;
152
153 checkDisplay(sdchInfo);
154
155 if (sdchInfo.blacklisted.length > 0) {
156 var testDomains = sdchInfo.blacklisted.filter(function(entry) {
157 return entry.domain === 'testdomain.com';
158 });
159 if (testDomains.length === 0)
160 return;
161
162 expectEquals(1, testDomains.length);
163 var entry = testDomains[0];
164 expectEquals(this.reason_, sdchProblemCodeToString(entry.reason));
165 var tableId = SdchView.BLACKLIST_TBODY_ID;
166 var domain = NetInternalsTest.getTbodyText(tableId, 0, 0);
167 var reason = NetInternalsTest.getTbodyText(tableId, 0, 1);
168 expectEquals(entry.domain, domain);
169 expectEquals(this.reason_, reason);
170 this.onTaskDone();
171 }
172 }
173 };
174
175 /**
176 * Load a page, which results in downloading a SDCH dictionary. Make sure its
177 * data is displayed.
178 */
179 TEST_F('NetInternalsTest', 'netInternalsSdchViewFetchDictionary', function() {
180 var taskQueue = new NetInternalsTest.TaskQueue(true);
181 taskQueue.addTask(
182 new NetInternalsTest.GetTestServerURLTask('files/sdch/page.html'));
183 taskQueue.addTask(new LoadSdchDictionaryTask());
184 taskQueue.run();
185 });
186
187 /**
188 * Load a page, get the dictionary for it, and get decoding error to see
189 * the blacklist in action.
190 */
191 TEST_F('NetInternalsTest', 'netInternalsSdchViewBlacklistMeta', function() {
192 var taskQueue = new NetInternalsTest.TaskQueue(true);
193 taskQueue.addTask(
194 new NetInternalsTest.GetTestServerURLTask('files/sdch/page.html'));
195 taskQueue.addTask(new LoadSdchDictionaryTask());
196 taskQueue.addTask(
197 new NetInternalsTest.GetTestServerURLTask('files/sdch/non-sdch.html'));
198 taskQueue.addTask(new LoadPageWithDecodeErrorTask('META_REFRESH_RECOVERY'));
199 taskQueue.run();
200 });
201
202 /**
203 * Load a page, which is said to be SDCH-encoded, though we don't expect it.
204 */
205 TEST_F('NetInternalsTest', 'netInternalsSdchViewBlacklistNonSdch', function() {
206 var taskQueue = new NetInternalsTest.TaskQueue(true);
207 taskQueue.addTask(
208 new NetInternalsTest.GetTestServerURLTask('files/sdch/non-sdch.html'));
209 taskQueue.addTask(
210 new LoadPageWithDecodeErrorTask('PASSING_THROUGH_NON_SDCH'));
211 taskQueue.run();
212 });
213
214 })(); // Anonymous namespace
OLDNEW
« no previous file with comments | « chrome/test/data/webui/net_internals/net_internals_test.js ('k') | net/base/net_info_source_list.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698