OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 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 #include <stddef.h> | 5 #include <stddef.h> |
6 #include <vector> | 6 #include <vector> |
7 | 7 |
8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
(...skipping 654 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
665 // Wait for the heap stats to reflect this. | 665 // Wait for the heap stats to reflect this. |
666 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerStatToExceed( | 666 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerStatToExceed( |
667 MatchTab("title1.html"), ColumnSpecifier::V8_MEMORY, minimal_heap_size)); | 667 MatchTab("title1.html"), ColumnSpecifier::V8_MEMORY, minimal_heap_size)); |
668 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerStatToExceed( | 668 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerStatToExceed( |
669 MatchTab("title1.html"), ColumnSpecifier::V8_MEMORY_USED, | 669 MatchTab("title1.html"), ColumnSpecifier::V8_MEMORY_USED, |
670 minimal_heap_size)); | 670 minimal_heap_size)); |
671 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab())); | 671 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab())); |
672 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchTab("title1.html"))); | 672 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchTab("title1.html"))); |
673 } | 673 } |
674 | 674 |
| 675 IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, SentDataObserved) { |
| 676 ShowTaskManager(); |
| 677 GURL test_gurl = embedded_test_server()->GetURL("/title1.html"); |
| 678 |
| 679 ui_test_utils::NavigateToURL(browser(), test_gurl); |
| 680 std::string test_js = R"( |
| 681 document.title = 'network use'; |
| 682 var mem = new Uint8Array(16 << 20); |
| 683 for (var i = 0; i < mem.length; i += 16) { |
| 684 mem[i] = i; |
| 685 } |
| 686 var formData = new FormData(); |
| 687 formData.append('StringKey1', new Blob([mem])); |
| 688 var request = |
| 689 new Request(location.href, {method: 'POST', body: formData}); |
| 690 fetch(request).then(response => response.text()); |
| 691 )"; |
| 692 |
| 693 browser() |
| 694 ->tab_strip_model() |
| 695 ->GetActiveWebContents() |
| 696 ->GetMainFrame() |
| 697 ->ExecuteJavaScriptForTests(base::UTF8ToUTF16(test_js)); |
| 698 // TODO(cburn): The assertion below currently assumes that the rate |
| 699 // contribution of the entire 16MB upload arrives in a single refresh cycle. |
| 700 // That's true now because it's only reported when the transaction completes, |
| 701 // but if that changes in the future, this assertion may need to change. |
| 702 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerStatToExceed( |
| 703 MatchTab("network use"), ColumnSpecifier::NETWORK_USE, 16000000)); |
| 704 } |
| 705 |
| 706 IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, TotalSentDataObserved) { |
| 707 ShowTaskManager(); |
| 708 GURL test_gurl = embedded_test_server()->GetURL("/title1.html"); |
| 709 |
| 710 ui_test_utils::NavigateToURL(browser(), test_gurl); |
| 711 std::string test_js = R"( |
| 712 document.title = 'network use'; |
| 713 var mem = new Uint8Array(16 << 20); |
| 714 for (var i = 0; i < mem.length; i += 16) { |
| 715 mem[i] = i; |
| 716 } |
| 717 var formData = new FormData(); |
| 718 formData.append('StringKey1', new Blob([mem])); |
| 719 var request = |
| 720 new Request(location.href, {method: 'POST', body: formData}); |
| 721 fetch(request).then(response => response.text()); |
| 722 )"; |
| 723 |
| 724 browser() |
| 725 ->tab_strip_model() |
| 726 ->GetActiveWebContents() |
| 727 ->GetMainFrame() |
| 728 ->ExecuteJavaScriptForTests(base::UTF8ToUTF16(test_js)); |
| 729 |
| 730 // This test uses |setTimeout| to exceed the Nyquist ratio to ensure that at |
| 731 // least 1 refresh has happened of no traffic. |
| 732 test_js = R"( |
| 733 var request = |
| 734 new Request(location.href, {method: 'POST', body: formData}); |
| 735 setTimeout( |
| 736 () => {fetch(request).then(response => response.text())}, 2000); |
| 737 )"; |
| 738 |
| 739 browser() |
| 740 ->tab_strip_model() |
| 741 ->GetActiveWebContents() |
| 742 ->GetMainFrame() |
| 743 ->ExecuteJavaScriptForTests(base::UTF8ToUTF16(test_js)); |
| 744 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerStatToExceed( |
| 745 MatchTab("network use"), ColumnSpecifier::TOTAL_NETWORK_USE, |
| 746 16000000 * 2)); |
| 747 } |
| 748 |
675 // Checks that task manager counts idle wakeups. | 749 // Checks that task manager counts idle wakeups. |
676 // Flakily fails on Mac: http://crbug.com/639939 | 750 // Flakily fails on Mac: http://crbug.com/639939 |
677 #if defined(OS_MACOSX) | 751 #if defined(OS_MACOSX) |
678 #define MAYBE_IdleWakeups DISABLED_IdleWakeups | 752 #define MAYBE_IdleWakeups DISABLED_IdleWakeups |
679 #else | 753 #else |
680 #define MAYBE_IdleWakeups IdleWakeups | 754 #define MAYBE_IdleWakeups IdleWakeups |
681 #endif // defined(OS_MACOSX) | 755 #endif // defined(OS_MACOSX) |
682 IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, | 756 IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, |
683 MAYBE_IdleWakeups) { | 757 MAYBE_IdleWakeups) { |
684 ShowTaskManager(); | 758 ShowTaskManager(); |
(...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1168 | 1242 |
1169 // Because the subframes for tab 2 are nested, their order is deterministic. | 1243 // Because the subframes for tab 2 are nested, their order is deterministic. |
1170 EXPECT_EQ("Subframe: http://a.com/", | 1244 EXPECT_EQ("Subframe: http://a.com/", |
1171 base::UTF16ToUTF8(model()->GetRowTitle(tab2_start + 1))); | 1245 base::UTF16ToUTF8(model()->GetRowTitle(tab2_start + 1))); |
1172 EXPECT_EQ("Subframe: http://c.com/", | 1246 EXPECT_EQ("Subframe: http://c.com/", |
1173 base::UTF16ToUTF8(model()->GetRowTitle(tab2_start + 2))); | 1247 base::UTF16ToUTF8(model()->GetRowTitle(tab2_start + 2))); |
1174 EXPECT_EQ("Subframe: http://b.com/", | 1248 EXPECT_EQ("Subframe: http://b.com/", |
1175 base::UTF16ToUTF8(model()->GetRowTitle(tab2_start + 3))); | 1249 base::UTF16ToUTF8(model()->GetRowTitle(tab2_start + 3))); |
1176 } | 1250 } |
1177 } | 1251 } |
OLD | NEW |