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

Unified Diff: chrome/browser/task_manager/task_manager_browsertest.cc

Issue 2905403002: plumb network upload into the task manager (Closed)
Patch Set: added refresh timer tests Created 3 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/task_manager/task_manager_browsertest.cc
diff --git a/chrome/browser/task_manager/task_manager_browsertest.cc b/chrome/browser/task_manager/task_manager_browsertest.cc
index 51e133c5d75743e3fe9bdca0bb700e10838b202d..983cd20ac44cd0ff63dc519aaef35decba39bc48 100644
--- a/chrome/browser/task_manager/task_manager_browsertest.cc
+++ b/chrome/browser/task_manager/task_manager_browsertest.cc
@@ -672,6 +672,84 @@ IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, JSHeapMemory) {
ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchTab("title1.html")));
}
+IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, SentDataObserved) {
+ ShowTaskManager();
+ GURL test_gurl = embedded_test_server()->GetURL("/title1.html");
+
+ ui_test_utils::NavigateToURL(browser(), test_gurl);
+ std::string test_js = R"(
+ mem = new Uint8Array(16 << 20);
+ for (var i = 0; i < mem.length; i += 16)
+ mem[i] = i;
+ var formData = new FormData();
+ formData.append('StringKey1', new Blob([mem]));
+ var request = new Request(
+ location.href,
+ {method: 'POST', body: formData});
+ fetch(request)
+ .then(response => response.text())
+ .then(body => domAutomationController.send("okay"))
+ .catch(error => domAutomationController.send("failed " + error));
+ )";
+ std::string ok;
+
+ ASSERT_TRUE(content::ExecuteScriptAndExtractString(
+ browser()->tab_strip_model()->GetActiveWebContents(), test_js, &ok));
+ ASSERT_EQ("okay", ok);
+
+ ASSERT_NO_FATAL_FAILURE(
+ WaitForTaskManagerStatToExceed(MatchTab(test_gurl.GetContent().c_str()),
ncarter (slow) 2017/06/17 00:21:02 Just use MatchTab("title1.html") -- it's consisten
cburn 2017/06/19 22:07:08 Done.
+ ColumnSpecifier::NETWORK_USE, 16000000));
ncarter (slow) 2017/06/17 00:21:02 I worry that this might be flaky, for two reasons:
cburn 2017/06/19 22:07:08 Done.
+}
+
+IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, TotalSentDataObserved) {
+ ShowTaskManager();
+ GURL test_gurl = embedded_test_server()->GetURL("/title1.html");
+
+ ui_test_utils::NavigateToURL(browser(), test_gurl);
+ std::string test_js = R"(
+ mem = new Uint8Array(16 << 20);
ncarter (slow) 2017/06/17 00:21:02 "var mem ="
cburn 2017/06/19 22:07:08 Done.
+ for (var i = 0; i < mem.length; i += 16)
+ mem[i] = i;
+ var formData = new FormData();
+ formData.append('StringKey1', new Blob([mem]));
+ var request = new Request(
+ location.href,
+ {method: 'POST', body: formData});
+ fetch(request)
+ .then(response => response.text())
+ .then(body => domAutomationController.send("okay"))
+ .catch(error => domAutomationController.send("failed " + error));
+ )";
+ std::string ok;
+
+ ASSERT_TRUE(content::ExecuteScriptAndExtractString(
+ browser()->tab_strip_model()->GetActiveWebContents(), test_js, &ok));
+ ASSERT_EQ("okay", ok);
+ test_js = R"(
+ mem = new Uint8Array(16 << 20);
+ for (var i = 0; i < mem.length; i += 16)
+ mem[i] = i;
ncarter (slow) 2017/06/17 00:21:01 mem already exists from the previous script execut
cburn 2017/06/19 22:07:08 Done.
+ var formData = new FormData();
+ formData.append('StringKey1', new Blob([mem]));
+ var request = new Request(
+ location.href,
+ {method: 'POST', body: formData});
+ setTimeout( function(){fetch(request)
ncarter (slow) 2017/06/17 00:21:02 Use lambda syntax here, since it's used elsewhere
cburn 2017/06/19 22:07:08 Done.
+ .then(response => response.text())
+ .then(body => domAutomationController.send("okay"))
+ .catch(error => domAutomationController.send("failed " + error))},
+ 2000);
ncarter (slow) 2017/06/17 00:21:01 What's the importance of this two-second wait? (Is
cburn 2017/06/19 22:07:08 Done.
+ )";
+ ASSERT_TRUE(content::ExecuteScriptAndExtractString(
+ browser()->tab_strip_model()->GetActiveWebContents(), test_js, &ok));
+ ASSERT_EQ("okay", ok);
+
+ ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerStatToExceed(
+ MatchTab(test_gurl.GetContent().c_str()),
+ ColumnSpecifier::TOTAL_NETWORK_USE, 16000000 * 2));
+}
+
// Checks that task manager counts idle wakeups.
// Flakily fails on Mac: http://crbug.com/639939
#if defined(OS_MACOSX)

Powered by Google App Engine
This is Rietveld 408576698