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

Side by Side Diff: chrome/browser/ui/webui/net_internals_ui_browsertest.cc

Issue 9166009: Move about:net-internals webui files into a subdirectory + OWNERS (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Update year Created 8 years, 11 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
« no previous file with comments | « chrome/browser/ui/webui/net_internals_ui.cc ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "base/bind.h"
6 #include "base/bind_helpers.h"
7 #include "base/command_line.h"
8 #include "base/file_path.h"
9 #include "base/utf_string_conversions.h"
10 #include "base/values.h"
11 #include "chrome/browser/prerender/prerender_final_status.h"
12 #include "chrome/browser/prerender/prerender_manager.h"
13 #include "chrome/browser/prerender/prerender_manager_factory.h"
14 #include "chrome/browser/profiles/profile.h"
15 #include "chrome/browser/ui/browser.h"
16 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
17 #include "chrome/browser/ui/webui/web_ui_browsertest.h"
18 #include "chrome/common/chrome_switches.h"
19 #include "chrome/common/url_constants.h"
20 #include "chrome/test/base/ui_test_utils.h"
21 #include "content/browser/renderer_host/render_view_host.h"
22 #include "content/public/browser/web_contents.h"
23 #include "content/public/browser/web_ui_message_handler.h"
24 #include "content/test/test_browser_thread.h"
25 #include "googleurl/src/gurl.h"
26 #include "net/base/address_list.h"
27 #include "net/base/host_cache.h"
28 #include "net/base/host_resolver.h"
29 #include "net/base/host_resolver_proc.h"
30 #include "net/base/net_errors.h"
31 #include "net/base/net_log.h"
32 #include "net/http/http_network_session.h"
33 #include "net/http/http_pipelined_host_capability.h"
34 #include "net/http/http_transaction_factory.h"
35 #include "net/url_request/url_request_context.h"
36 #include "net/url_request/url_request_context_getter.h"
37 #include "testing/gtest/include/gtest/gtest.h"
38
39 using content::BrowserThread;
40 using content::WebUIMessageHandler;
41
42 namespace {
43
44 // Called on IO thread. Adds an entry to the cache for the specified hostname.
45 // Either |net_error| must be net::OK, or |address| must be NULL.
46 void AddCacheEntryOnIOThread(net::URLRequestContextGetter* context_getter,
47 const std::string& hostname,
48 const std::string& ip_literal,
49 int net_error,
50 int expire_days_from_now) {
51 ASSERT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::IO));
52 net::URLRequestContext* context = context_getter->GetURLRequestContext();
53 net::HostCache* cache = context->host_resolver()->GetHostCache();
54 ASSERT_TRUE(cache);
55
56 net::HostCache::Key key(hostname, net::ADDRESS_FAMILY_UNSPECIFIED, 0);
57 base::TimeTicks expires =
58 base::TimeTicks::Now() + base::TimeDelta::FromDays(expire_days_from_now);
59
60 net::AddressList address_list;
61 if (net_error == net::OK) {
62 // If |net_error| does not indicate an error, convert |ip_literal| to a
63 // net::AddressList, so it can be used with the cache.
64 int rv = net::SystemHostResolverProc(ip_literal,
65 net::ADDRESS_FAMILY_UNSPECIFIED,
66 0,
67 &address_list,
68 NULL);
69 ASSERT_EQ(net::OK, rv);
70 } else {
71 ASSERT_TRUE(ip_literal.empty());
72 }
73
74 // Add entry to the cache.
75 cache->Set(net::HostCache::Key(hostname, net::ADDRESS_FAMILY_UNSPECIFIED, 0),
76 net_error,
77 address_list,
78 expires);
79 }
80
81 // Called on IO thread. Adds an entry to the list of known HTTP pipelining
82 // hosts.
83 void AddDummyHttpPipelineFeedbackOnIOThread(
84 net::URLRequestContextGetter* context_getter,
85 const std::string& hostname,
86 int port,
87 net::HttpPipelinedHostCapability capability) {
88 ASSERT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::IO));
89 net::URLRequestContext* context = context_getter->GetURLRequestContext();
90 net::HttpNetworkSession* http_network_session =
91 context->http_transaction_factory()->GetSession();
92 net::HttpServerProperties* http_server_properties =
93 http_network_session->http_server_properties();
94 net::HostPortPair origin(hostname, port);
95 http_server_properties->SetPipelineCapability(origin, capability);
96 }
97
98 // Called on IO thread. Adds an entry to the list of known HTTP pipelining
99 // hosts.
100 void EnableHttpPipeliningOnIOThread(bool enable) {
101 ASSERT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::IO));
102 net::HttpStreamFactory::set_http_pipelining_enabled(enable);
103 }
104
105 class NetInternalsTest : public WebUIBrowserTest {
106 public:
107 NetInternalsTest();
108 virtual ~NetInternalsTest();
109
110 // InProcessBrowserTest overrides.
111 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE;
112 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE;
113 virtual void SetUpOnMainThread() OVERRIDE;
114
115 protected:
116 GURL CreatePrerenderLoaderUrl(const GURL& prerender_url) {
117 std::vector<net::TestServer::StringPair> replacement_text;
118 replacement_text.push_back(
119 make_pair("REPLACE_WITH_PRERENDER_URL", prerender_url.spec()));
120 std::string replacement_path;
121 EXPECT_TRUE(net::TestServer::GetFilePathWithReplacements(
122 "files/prerender/prerender_loader.html",
123 replacement_text,
124 &replacement_path));
125 GURL url_loader = test_server()->GetURL(replacement_path);
126 return url_loader;
127 }
128
129 void EnableHttpPipelining(bool enable) {
130 BrowserThread::PostTask(
131 BrowserThread::IO, FROM_HERE,
132 base::Bind(&EnableHttpPipeliningOnIOThread, enable));
133 }
134
135 private:
136 // Class to handle messages from the renderer needed by certain tests.
137 class MessageHandler : public WebUIMessageHandler {
138 public:
139 explicit MessageHandler(NetInternalsTest* net_internals_test);
140
141 private:
142 virtual void RegisterMessages() OVERRIDE;
143
144 // Opens the given URL in a new background tab.
145 void OpenNewTab(const ListValue* list_value);
146
147 // Called on UI thread. Adds an entry to the cache for the specified
148 // hostname by posting a task to the IO thread. Takes the host name,
149 // ip address, net error code, and expiration time in days from now
150 // as parameters. If the error code indicates failure, the ip address
151 // must be an empty string.
152 void AddCacheEntry(const ListValue* list_value);
153
154 // Navigates to the prerender in the background tab. This assumes that
155 // there is a "Click()" function in the background tab which will navigate
156 // there, and that the background tab exists at slot 1.
157 void NavigateToPrerender(const ListValue* list_value);
158
159 // Creates an incognito browser. Once creation is complete, passes a
160 // message to the Javascript test harness.
161 void CreateIncognitoBrowser(const ListValue* list_value);
162
163 // Closes an incognito browser created with CreateIncognitoBrowser.
164 void CloseIncognitoBrowser(const ListValue* list_value);
165
166 // Called on UI thread. Adds an entry to the list of known HTTP pipelining
167 // hosts.
168 void AddDummyHttpPipelineFeedback(const ListValue* list_value);
169
170 Browser* browser() {
171 return net_internals_test_->browser();
172 }
173
174 NetInternalsTest* net_internals_test_;
175 Browser* incognito_browser_;
176
177 DISALLOW_COPY_AND_ASSIGN(MessageHandler);
178 };
179
180 virtual WebUIMessageHandler* GetMockMessageHandler() OVERRIDE {
181 return &message_handler_;
182 }
183
184 MessageHandler message_handler_;
185
186 DISALLOW_COPY_AND_ASSIGN(NetInternalsTest);
187 };
188
189 NetInternalsTest::NetInternalsTest()
190 : ALLOW_THIS_IN_INITIALIZER_LIST(message_handler_(this)) {
191 }
192
193 NetInternalsTest::~NetInternalsTest() {
194 }
195
196 void NetInternalsTest::SetUpCommandLine(CommandLine* command_line) {
197 WebUIBrowserTest::SetUpCommandLine(command_line);
198 // Needed to test the prerender view.
199 command_line->AppendSwitchASCII(switches::kPrerenderMode,
200 switches::kPrerenderModeSwitchValueEnabled);
201 }
202
203 void NetInternalsTest::SetUpInProcessBrowserTestFixture() {
204 // Adds libraries needed for testing, so much be first.
205 WebUIBrowserTest::SetUpInProcessBrowserTestFixture();
206
207 // Framework for net-internals tests.
208 AddLibrary(FilePath(FILE_PATH_LITERAL(
209 "net_internals/net_internals_test.js")));
210
211 // Add Javascript files needed for individual tests.
212 AddLibrary(FilePath(FILE_PATH_LITERAL("net_internals/dns_view.js")));
213 AddLibrary(FilePath(FILE_PATH_LITERAL("net_internals/hsts_view.js")));
214 AddLibrary(FilePath(FILE_PATH_LITERAL(
215 "net_internals/http_pipeline_view.js")));
216 AddLibrary(FilePath(FILE_PATH_LITERAL("net_internals/log_util.js")));
217 AddLibrary(FilePath(FILE_PATH_LITERAL("net_internals/log_view_painter.js")));
218 AddLibrary(FilePath(FILE_PATH_LITERAL("net_internals/main.js")));
219 AddLibrary(FilePath(FILE_PATH_LITERAL("net_internals/prerender_view.js")));
220 AddLibrary(FilePath(FILE_PATH_LITERAL("net_internals/test_view.js")));
221 AddLibrary(FilePath(FILE_PATH_LITERAL("net_internals/timeline_view.js")));
222 }
223
224 void NetInternalsTest::SetUpOnMainThread() {
225 // Navigate to chrome://net-internals.
226 ui_test_utils::NavigateToURL(browser(),
227 GURL(chrome::kChromeUINetInternalsURL));
228 // Increase the memory allowed in a prerendered page above normal settings,
229 // as debug builds use more memory and often go over the usual limit.
230 Profile* profile = browser()->GetSelectedTabContentsWrapper()->profile();
231 prerender::PrerenderManager* prerender_manager =
232 prerender::PrerenderManagerFactory::GetForProfile(profile);
233 prerender_manager->mutable_config().max_bytes = 1000 * 1024 * 1024;
234 }
235
236 ////////////////////////////////////////////////////////////////////////////////
237 // NetInternalsTest::MessageHandler
238 ////////////////////////////////////////////////////////////////////////////////
239
240 NetInternalsTest::MessageHandler::MessageHandler(
241 NetInternalsTest* net_internals_test)
242 : net_internals_test_(net_internals_test),
243 incognito_browser_(NULL) {
244 }
245
246 void NetInternalsTest::MessageHandler::RegisterMessages() {
247 web_ui()->RegisterMessageCallback(
248 "openNewTab",
249 base::Bind(&NetInternalsTest::MessageHandler::OpenNewTab,
250 base::Unretained(this)));
251 web_ui()->RegisterMessageCallback(
252 "addCacheEntry",
253 base::Bind(&NetInternalsTest::MessageHandler::AddCacheEntry,
254 base::Unretained(this)));
255 web_ui()->RegisterMessageCallback("navigateToPrerender",
256 base::Bind(&NetInternalsTest::MessageHandler::NavigateToPrerender,
257 base::Unretained(this)));
258 web_ui()->RegisterMessageCallback("createIncognitoBrowser",
259 base::Bind(&NetInternalsTest::MessageHandler::CreateIncognitoBrowser,
260 base::Unretained(this)));
261 web_ui()->RegisterMessageCallback("closeIncognitoBrowser",
262 base::Bind(&NetInternalsTest::MessageHandler::CloseIncognitoBrowser,
263 base::Unretained(this)));
264 web_ui()->RegisterMessageCallback("addDummyHttpPipelineFeedback",
265 base::Bind(
266 &NetInternalsTest::MessageHandler::AddDummyHttpPipelineFeedback,
267 base::Unretained(this)));
268 }
269
270 void NetInternalsTest::MessageHandler::OpenNewTab(
271 const ListValue* list_value) {
272 std::string url;
273 ASSERT_TRUE(list_value->GetString(0, &url));
274 ui_test_utils::NavigateToURLWithDisposition(
275 browser(),
276 GURL(url),
277 NEW_BACKGROUND_TAB,
278 ui_test_utils::BROWSER_TEST_NONE);
279 }
280
281 void NetInternalsTest::MessageHandler::AddCacheEntry(
282 const ListValue* list_value) {
283 std::string hostname;
284 std::string ip_literal;
285 double net_error;
286 double expire_days_from_now;
287 ASSERT_TRUE(list_value->GetString(0, &hostname));
288 ASSERT_TRUE(list_value->GetString(1, &ip_literal));
289 ASSERT_TRUE(list_value->GetDouble(2, &net_error));
290 ASSERT_TRUE(list_value->GetDouble(3, &expire_days_from_now));
291 ASSERT_TRUE(browser());
292
293 BrowserThread::PostTask(
294 BrowserThread::IO, FROM_HERE,
295 base::Bind(&AddCacheEntryOnIOThread,
296 make_scoped_refptr(browser()->profile()->GetRequestContext()),
297 hostname,
298 ip_literal,
299 static_cast<int>(net_error),
300 static_cast<int>(expire_days_from_now)));
301 }
302
303 void NetInternalsTest::MessageHandler::NavigateToPrerender(
304 const ListValue* list_value) {
305 RenderViewHost* host = browser()->GetWebContentsAt(1)->GetRenderViewHost();
306 host->ExecuteJavascriptInWebFrame(string16(), ASCIIToUTF16("Click()"));
307 }
308
309 void NetInternalsTest::MessageHandler::CreateIncognitoBrowser(
310 const ListValue* list_value) {
311 ASSERT_FALSE(incognito_browser_);
312 incognito_browser_ = net_internals_test_->CreateIncognitoBrowser();
313
314 // Tell the test harness that creation is complete.
315 StringValue command_value("onIncognitoBrowserCreatedForTest");
316 web_ui()->CallJavascriptFunction("g_browser.receive", command_value);
317 }
318
319 void NetInternalsTest::MessageHandler::CloseIncognitoBrowser(
320 const ListValue* list_value) {
321 ASSERT_TRUE(incognito_browser_);
322 incognito_browser_->CloseAllTabs();
323 // Closing all a Browser's tabs will ultimately result in its destruction,
324 // thought it may not have been destroyed yet.
325 incognito_browser_ = NULL;
326 }
327
328 void NetInternalsTest::MessageHandler::AddDummyHttpPipelineFeedback(
329 const ListValue* list_value) {
330 std::string hostname;
331 double port;
332 std::string raw_capability;
333 net::HttpPipelinedHostCapability capability;
334 ASSERT_TRUE(list_value->GetString(0, &hostname));
335 ASSERT_TRUE(list_value->GetDouble(1, &port));
336 ASSERT_TRUE(list_value->GetString(2, &raw_capability));
337 if (raw_capability == "capable") {
338 capability = net::PIPELINE_CAPABLE;
339 } else if (raw_capability == "incapable") {
340 capability = net::PIPELINE_INCAPABLE;
341 } else {
342 FAIL() << "Unexpected capability string: " << raw_capability;
343 }
344 BrowserThread::PostTask(
345 BrowserThread::IO, FROM_HERE,
346 base::Bind(&AddDummyHttpPipelineFeedbackOnIOThread,
347 make_scoped_refptr(browser()->profile()->GetRequestContext()),
348 hostname,
349 static_cast<int>(port),
350 capability));
351 }
352
353 ////////////////////////////////////////////////////////////////////////////////
354 // net_internals_ui.js
355 ////////////////////////////////////////////////////////////////////////////////
356
357 // Checks testDone.
358 IN_PROC_BROWSER_TEST_F(NetInternalsTest, NetInternalsDone) {
359 EXPECT_TRUE(RunJavascriptAsyncTest("netInternalsDone"));
360 }
361
362 // Checks a failed expect statement.
363 IN_PROC_BROWSER_TEST_F(NetInternalsTest, NetInternalsExpectFail) {
364 EXPECT_FALSE(RunJavascriptAsyncTest("netInternalsExpectFail"));
365 }
366
367 // Checks a failed assert statement.
368 IN_PROC_BROWSER_TEST_F(NetInternalsTest, NetInternalsAssertFail) {
369 EXPECT_FALSE(RunJavascriptAsyncTest("netInternalsAssertFail"));
370 }
371
372 // Checks that testDone works when called by an observer in response to an
373 // event.
374 IN_PROC_BROWSER_TEST_F(NetInternalsTest, NetInternalsObserverDone) {
375 EXPECT_TRUE(RunJavascriptAsyncTest("netInternalsObserverDone"));
376 }
377
378 // Checks that a failed expect works when called by an observer in response
379 // to an event.
380 IN_PROC_BROWSER_TEST_F(NetInternalsTest, NetInternalsObserverExpectFail) {
381 EXPECT_FALSE(RunJavascriptAsyncTest("netInternalsObserverExpectFail"));
382 }
383
384 // Checks that a failed assertion works when called by an observer in response
385 // to an event.
386 IN_PROC_BROWSER_TEST_F(NetInternalsTest, NetInternalsObserverAssertFail) {
387 EXPECT_FALSE(RunJavascriptAsyncTest("netInternalsObserverAssertFail"));
388 }
389
390 ////////////////////////////////////////////////////////////////////////////////
391 // main.js (Also tests status_view.js)
392 ////////////////////////////////////////////////////////////////////////////////
393
394 // Checks tabs initialization and switching between tabs.
395 IN_PROC_BROWSER_TEST_F(NetInternalsTest, NetInternalsTourTabs) {
396 EXPECT_TRUE(RunJavascriptAsyncTest("netInternalsTourTabs"));
397 }
398
399 // Checks pressing the stop capturing button.
400 IN_PROC_BROWSER_TEST_F(NetInternalsTest, NetInternalsStopCapturing) {
401 EXPECT_TRUE(RunJavascriptAsyncTest("netInternalsStopCapturing"));
402 }
403
404 ////////////////////////////////////////////////////////////////////////////////
405 // log_dump_util.js
406 ////////////////////////////////////////////////////////////////////////////////
407
408 // Checks exporting and importing a log dump, as well as some tab behavior in
409 // response to doing this. Does not actually save the log to a file, just
410 // to a string.
411 // TODO(mmenke): Add some checks for the import view.
412 // TODO(mmenke): Add a test for a log created with --log-net-log.
413 IN_PROC_BROWSER_TEST_F(NetInternalsTest, NetInternalsExportImportDump) {
414 EXPECT_TRUE(RunJavascriptAsyncTest("netInternalsExportImportDump"));
415 }
416
417 ////////////////////////////////////////////////////////////////////////////////
418 // timeline_view.js
419 ////////////////////////////////////////////////////////////////////////////////
420
421 // TODO(mmenke): Add tests for labels and DataSeries.
422
423 // Tests setting and updating range.
424 IN_PROC_BROWSER_TEST_F(NetInternalsTest, NetInternalsTimelineViewRange) {
425 EXPECT_TRUE(RunJavascriptAsyncTest("netInternalsTimelineViewRange"));
426 }
427
428 // Tests using the scroll bar.
429 IN_PROC_BROWSER_TEST_F(NetInternalsTest, NetInternalsTimelineViewScrollbar) {
430 EXPECT_TRUE(RunJavascriptAsyncTest("netInternalsTimelineViewScrollbar"));
431 }
432
433 // Tests case of having no events.
434 IN_PROC_BROWSER_TEST_F(NetInternalsTest, NetInternalsTimelineViewNoEvents) {
435 EXPECT_TRUE(RunJavascriptAsyncTest("netInternalsTimelineViewNoEvents"));
436 }
437
438 // Dumps a log file to memory, modifies its events, loads it again, and
439 // makes sure the range is correctly set and not automatically updated.
440 IN_PROC_BROWSER_TEST_F(NetInternalsTest, NetInternalsTimelineViewLoadLog) {
441 EXPECT_TRUE(RunJavascriptAsyncTest("netInternalsTimelineViewLoadLog"));
442 }
443
444 // Zooms out twice, and then zooms in once.
445 IN_PROC_BROWSER_TEST_F(NetInternalsTest, NetInternalsTimelineViewZoomOut) {
446 EXPECT_TRUE(RunJavascriptAsyncTest("netInternalsTimelineViewZoomOut"));
447 }
448
449 // Zooms in as much as allowed, and zooms out once.
450 IN_PROC_BROWSER_TEST_F(NetInternalsTest, NetInternalsTimelineViewZoomIn) {
451 EXPECT_TRUE(RunJavascriptAsyncTest("netInternalsTimelineViewZoomIn"));
452 }
453
454 // Tests case of all events having the same time.
455 IN_PROC_BROWSER_TEST_F(NetInternalsTest, NetInternalsTimelineViewDegenerate) {
456 EXPECT_TRUE(RunJavascriptAsyncTest("netInternalsTimelineViewDegenerate"));
457 }
458
459 ////////////////////////////////////////////////////////////////////////////////
460 // dns_view.js
461 ////////////////////////////////////////////////////////////////////////////////
462
463 // Adds a successful lookup to the DNS cache, then clears the cache.
464 IN_PROC_BROWSER_TEST_F(NetInternalsTest, NetInternalsDnsViewSuccess) {
465 EXPECT_TRUE(RunJavascriptAsyncTest("netInternalsDnsViewSuccess"));
466 }
467
468 // Adds a failed lookup to the DNS cache, then clears the cache.
469 IN_PROC_BROWSER_TEST_F(NetInternalsTest, NetInternalsDnsViewFail) {
470 EXPECT_TRUE(RunJavascriptAsyncTest("netInternalsDnsViewFail"));
471 }
472
473 // Adds an expired successful lookup to the DNS cache, then clears the cache.
474 IN_PROC_BROWSER_TEST_F(NetInternalsTest, NetInternalsDnsViewExpired) {
475 EXPECT_TRUE(RunJavascriptAsyncTest("netInternalsDnsViewExpired"));
476 }
477
478 // Adds two entries to the DNS cache, clears the cache, and then repeats.
479 IN_PROC_BROWSER_TEST_F(NetInternalsTest, NetInternalsDnsViewAddTwoTwice) {
480 EXPECT_TRUE(RunJavascriptAsyncTest("netInternalsDnsViewAddTwoTwice"));
481 }
482
483 // Makes sure that openning and then closing an incognito window clears the
484 // DNS cache. To keep things simple, we add a fake cache entry ourselves,
485 // rather than having the incognito browser create one.
486 IN_PROC_BROWSER_TEST_F(NetInternalsTest, NetInternalsDnsViewIncognitoClears) {
487 EXPECT_TRUE(RunJavascriptAsyncTest("netInternalsDnsViewIncognitoClears"));
488 }
489
490 ////////////////////////////////////////////////////////////////////////////////
491 // test_view.js
492 ////////////////////////////////////////////////////////////////////////////////
493
494 // Runs the test suite twice, expecting a passing result the first time. Checks
495 // the first result, the order of events that occur, and the number of rows in
496 // the table.
497 IN_PROC_BROWSER_TEST_F(NetInternalsTest, NetInternalsTestViewPassTwice) {
498 ASSERT_TRUE(test_server()->Start());
499 EXPECT_TRUE(RunJavascriptAsyncTest(
500 "netInternalsTestView",
501 // URL that results in success.
502 Value::CreateStringValue(
503 test_server()->GetURL("files/title1.html").spec()),
504 // Resulting error code of the first test.
505 Value::CreateIntegerValue(net::OK),
506 // Number of times to run the test suite.
507 Value::CreateIntegerValue(2)));
508 }
509
510 // Runs the test suite twice. Checks the exact error code of the first result,
511 // the order of events that occur, and the number of rows in the HTML table.
512 IN_PROC_BROWSER_TEST_F(NetInternalsTest, NetInternalsTestViewFailTwice) {
513 EXPECT_TRUE(RunJavascriptAsyncTest(
514 "netInternalsTestView",
515 // URL that results in an error, due to the port.
516 Value::CreateStringValue("http://127.0.0.1:7/"),
517 // Resulting error code of the first test.
518 Value::CreateIntegerValue(net::ERR_UNSAFE_PORT),
519 // Number of times to run the test suite.
520 Value::CreateIntegerValue(2)));
521 }
522
523 ////////////////////////////////////////////////////////////////////////////////
524 // hsts_view.js
525 ////////////////////////////////////////////////////////////////////////////////
526
527 // Checks that querying a domain that was never added fails.
528 IN_PROC_BROWSER_TEST_F(NetInternalsTest, NetInternalsHSTSViewQueryNotFound) {
529 EXPECT_TRUE(RunJavascriptAsyncTest("netInternalsHSTSViewQueryNotFound"));
530 }
531
532 // Checks that querying a domain with an invalid name returns an error.
533 IN_PROC_BROWSER_TEST_F(NetInternalsTest, NetInternalsHSTSViewQueryError) {
534 EXPECT_TRUE(RunJavascriptAsyncTest("netInternalsHSTSViewQueryError"));
535 }
536
537 // Deletes a domain that was never added.
538 IN_PROC_BROWSER_TEST_F(NetInternalsTest, NetInternalsHSTSViewDeleteNotFound) {
539 EXPECT_TRUE(RunJavascriptAsyncTest("netInternalsHSTSViewDeleteNotFound"));
540 }
541
542 // Deletes a domain that returns an error on lookup.
543 IN_PROC_BROWSER_TEST_F(NetInternalsTest, NetInternalsHSTSViewDeleteError) {
544 EXPECT_TRUE(RunJavascriptAsyncTest("netInternalsHSTSViewDeleteNotFound"));
545 }
546
547 // Adds a domain and then deletes it.
548 IN_PROC_BROWSER_TEST_F(NetInternalsTest, NetInternalsHSTSViewAddDelete) {
549 EXPECT_TRUE(RunJavascriptAsyncTest("netInternalsHSTSViewAddDelete"));
550 }
551
552 // Tries to add a domain with an invalid name.
553 IN_PROC_BROWSER_TEST_F(NetInternalsTest, NetInternalsHSTSViewAddFail) {
554 EXPECT_TRUE(RunJavascriptAsyncTest("netInternalsHSTSViewAddError"));
555 }
556
557 // Tries to add a domain with a name that errors out on lookup due to having
558 // non-ASCII characters in it.
559 IN_PROC_BROWSER_TEST_F(NetInternalsTest, NetInternalsHSTSViewAddError) {
560 EXPECT_TRUE(RunJavascriptAsyncTest("netInternalsHSTSViewAddError"));
561 }
562
563 // Adds a domain with an invalid hash.
564 IN_PROC_BROWSER_TEST_F(NetInternalsTest, NetInternalsHSTSViewAddInvalidHash) {
565 EXPECT_TRUE(RunJavascriptAsyncTest("netInternalsHSTSViewAddInvalidHash"));
566 }
567
568 // Adds the same domain twice in a row, modifying some values the second time.
569 IN_PROC_BROWSER_TEST_F(NetInternalsTest, NetInternalsHSTSViewAddOverwrite) {
570 EXPECT_TRUE(RunJavascriptAsyncTest("netInternalsHSTSViewAddOverwrite"));
571 }
572
573 // Adds two different domains and then deletes them.
574 IN_PROC_BROWSER_TEST_F(NetInternalsTest, NetInternalsHSTSViewAddTwice) {
575 EXPECT_TRUE(RunJavascriptAsyncTest("netInternalsHSTSViewAddTwice"));
576 }
577
578 ////////////////////////////////////////////////////////////////////////////////
579 // http_pipeline_view.js
580 ////////////////////////////////////////////////////////////////////////////////
581
582 // Adds a capable pipelining host.
583 IN_PROC_BROWSER_TEST_F(NetInternalsTest, NetInternalsHttpPipelineViewCapable) {
584 EnableHttpPipelining(true);
585 EXPECT_TRUE(RunJavascriptAsyncTest("netInternalsHttpPipelineViewCapable"));
586 }
587
588 // Adds a incapable pipelining host.
589 IN_PROC_BROWSER_TEST_F(NetInternalsTest,
590 NetInternalsHttpPipelineViewIncapable) {
591 EnableHttpPipelining(true);
592 EXPECT_TRUE(RunJavascriptAsyncTest("netInternalsHttpPipelineViewIncapable"));
593 }
594
595 // Checks with pipelining disabled.
596 IN_PROC_BROWSER_TEST_F(NetInternalsTest, NetInternalsHttpPipelineViewDisabled) {
597 EnableHttpPipelining(false);
598 EXPECT_TRUE(RunJavascriptAsyncTest("netInternalsHttpPipelineViewDisabled"));
599 }
600
601 ////////////////////////////////////////////////////////////////////////////////
602 // prerender_view.js
603 ////////////////////////////////////////////////////////////////////////////////
604
605 // Prerender a page and navigate to it, once prerendering starts.
606 IN_PROC_BROWSER_TEST_F(NetInternalsTest, NetInternalsPrerenderViewSucceed) {
607 ASSERT_TRUE(test_server()->Start());
608 GURL prerender_url = test_server()->GetURL("files/title1.html");
609 GURL loader_url = CreatePrerenderLoaderUrl(prerender_url);
610 ConstValueVector args;
611 args.push_back(Value::CreateStringValue(prerender_url.spec()));
612 args.push_back(Value::CreateStringValue(loader_url.spec()));
613 args.push_back(Value::CreateBooleanValue(true));
614 args.push_back(Value::CreateStringValue(
615 prerender::NameFromFinalStatus(prerender::FINAL_STATUS_USED)));
616 EXPECT_TRUE(RunJavascriptAsyncTest("netInternalsPrerenderView", args));
617 }
618
619 // Prerender a page that is expected to fail.
620 IN_PROC_BROWSER_TEST_F(NetInternalsTest, NetInternalsPrerenderViewFail) {
621 ASSERT_TRUE(test_server()->Start());
622 GURL prerender_url = test_server()->GetURL("files/download-test1.lib");
623 GURL loader_url = CreatePrerenderLoaderUrl(prerender_url);
624 ConstValueVector args;
625 args.push_back(Value::CreateStringValue(prerender_url.spec()));
626 args.push_back(Value::CreateStringValue(loader_url.spec()));
627 args.push_back(Value::CreateBooleanValue(false));
628 args.push_back(Value::CreateStringValue(
629 prerender::NameFromFinalStatus(prerender::FINAL_STATUS_DOWNLOAD)));
630 EXPECT_TRUE(RunJavascriptAsyncTest("netInternalsPrerenderView", args));
631 }
632
633 ////////////////////////////////////////////////////////////////////////////////
634 // log_view_painter.js
635 ////////////////////////////////////////////////////////////////////////////////
636
637 // Check that we correctly remove cookies and login information.
638 IN_PROC_BROWSER_TEST_F(NetInternalsTest,
639 NetInternalsLogViewPainterStripInfo) {
640 EXPECT_TRUE(RunJavascriptAsyncTest("netInternalsLogViewPainterStripInfo"));
641 }
642
643 } // namespace
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/net_internals_ui.cc ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698