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

Side by Side Diff: chrome/browser/task_manager/task_manager_browsertest.cc

Issue 1027333003: TaskManagerBrowserTest.WebWorkerJSHeapMemory: update postMessage() usage. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix the test + enable Created 5 years, 9 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 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 "chrome/browser/task_manager/task_manager.h" 5 #include "chrome/browser/task_manager/task_manager.h"
6 6
7 #include "base/files/file_path.h" 7 #include "base/files/file_path.h"
8 #include "base/strings/stringprintf.h" 8 #include "base/strings/stringprintf.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "chrome/browser/browser_process.h" 10 #include "chrome/browser/browser_process.h"
(...skipping 760 matching lines...) Expand 10 before | Expand all | Expand 10 after
771 DCHECK_NE(model()->GetResourceWebCoreImageCacheSize(resource_count), 771 DCHECK_NE(model()->GetResourceWebCoreImageCacheSize(resource_count),
772 l10n_util::GetStringUTF16(IDS_TASK_MANAGER_NA_CELL_TEXT)); 772 l10n_util::GetStringUTF16(IDS_TASK_MANAGER_NA_CELL_TEXT));
773 DCHECK_NE(model()->GetResourceWebCoreScriptsCacheSize(resource_count), 773 DCHECK_NE(model()->GetResourceWebCoreScriptsCacheSize(resource_count),
774 l10n_util::GetStringUTF16(IDS_TASK_MANAGER_NA_CELL_TEXT)); 774 l10n_util::GetStringUTF16(IDS_TASK_MANAGER_NA_CELL_TEXT));
775 DCHECK_NE(model()->GetResourceWebCoreCSSCacheSize(resource_count), 775 DCHECK_NE(model()->GetResourceWebCoreCSSCacheSize(resource_count),
776 l10n_util::GetStringUTF16(IDS_TASK_MANAGER_NA_CELL_TEXT)); 776 l10n_util::GetStringUTF16(IDS_TASK_MANAGER_NA_CELL_TEXT));
777 } 777 }
778 778
779 // Checks that task manager counts a worker thread JS heap size. 779 // Checks that task manager counts a worker thread JS heap size.
780 // http://crbug.com/241066 780 // http://crbug.com/241066
781 // Flaky, http://crbug.com/259368 781 IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, WebWorkerJSHeapMemory) {
782 IN_PROC_BROWSER_TEST_F(TaskManagerBrowserTest, DISABLED_WebWorkerJSHeapMemory) { 782 ShowTaskManager();
783 ui_test_utils::NavigateToURL(browser(), GetTestURL()); 783 ui_test_utils::NavigateToURL(browser(), GetTestURL());
784 const int extra_timeout_ms = 500; 784 const int extra_timeout_ms = 500;
785 size_t minimal_heap_size = 2 * 1024 * 1024 * sizeof(void*); 785 size_t minimal_heap_size = 2 * 1024 * 1024 * sizeof(void*);
786 std::string test_js = base::StringPrintf( 786 std::string test_js = base::StringPrintf(
787 "var blob = new Blob([\n" 787 "var blob = new Blob([\n"
788 " 'mem = new Array(%lu);',\n" 788 " 'mem = new Array(%lu);',\n"
789 " 'for (var i = 0; i < mem.length; i += 16) mem[i] = i;',\n" 789 " 'for (var i = 0; i < mem.length; i += 16) mem[i] = i;',\n"
790 " 'postMessage();']);\n" 790 " 'postMessage(i);']);\n"
791 "blobURL = window.URL.createObjectURL(blob);\n" 791 "blobURL = window.URL.createObjectURL(blob);\n"
792 "worker = new Worker(blobURL);\n" 792 "worker = new Worker(blobURL);\n"
793 "// Give the task manager few seconds to poll for JS heap sizes.\n" 793 "// Give the task manager few seconds to poll for JS heap sizes.\n"
794 "worker.onmessage = setTimeout.bind(\n" 794 "worker.onmessage = setTimeout.bind(\n"
795 " this,\n" 795 " this,\n"
796 " function () { window.domAutomationController.send(true); },\n" 796 " function () { window.domAutomationController.send(true); },\n"
797 " %d);\n" 797 " %d);\n"
798 "worker.postMessage();\n", 798 "worker.postMessage('go');\n",
799 static_cast<unsigned long>(minimal_heap_size), 799 static_cast<unsigned long>(minimal_heap_size),
800 GetUpdateTimeMs() + extra_timeout_ms); 800 GetUpdateTimeMs() + extra_timeout_ms);
801 bool ok; 801 bool ok;
802 ASSERT_TRUE(content::ExecuteScriptAndExtractBool( 802 ASSERT_TRUE(content::ExecuteScriptAndExtractBool(
803 browser()->tab_strip_model()->GetActiveWebContents(), test_js, &ok)); 803 browser()->tab_strip_model()->GetActiveWebContents(), test_js, &ok));
804 ASSERT_TRUE(ok); 804 ASSERT_TRUE(ok);
805 805
806 int resource_index = TaskManager::GetInstance()->model()->ResourceCount() - 1; 806 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchTab("title1.html")));
807 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab()));
808 int resource_index = FindResourceIndex(MatchTab("title1.html"));
807 size_t result; 809 size_t result;
808 810
809 ASSERT_TRUE(model()->GetV8Memory(resource_index, &result)); 811 ASSERT_TRUE(model()->GetV8Memory(resource_index, &result));
810 LOG(INFO) << "Got V8 Heap Size " << result << " bytes"; 812 LOG(INFO) << "Got V8 Heap Size " << result << " bytes";
811 EXPECT_GE(result, minimal_heap_size); 813 EXPECT_GE(result, minimal_heap_size);
812 814
813 ASSERT_TRUE(model()->GetV8MemoryUsed(resource_index, &result)); 815 ASSERT_TRUE(model()->GetV8MemoryUsed(resource_index, &result));
814 LOG(INFO) << "Got V8 Used Heap Size " << result << " bytes"; 816 LOG(INFO) << "Got V8 Used Heap Size " << result << " bytes";
815 EXPECT_GE(result, minimal_heap_size); 817 EXPECT_GE(result, minimal_heap_size);
816 } 818 }
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
1087 } else { 1089 } else {
1088 ASSERT_NO_FATAL_FAILURE( 1090 ASSERT_NO_FATAL_FAILURE(
1089 WaitForTaskManagerRows(0, MatchSubframe("http://b.com/"))); 1091 WaitForTaskManagerRows(0, MatchSubframe("http://b.com/")));
1090 ASSERT_NO_FATAL_FAILURE( 1092 ASSERT_NO_FATAL_FAILURE(
1091 WaitForTaskManagerRows(1, MatchSubframe("http://c.com/"))); 1093 WaitForTaskManagerRows(1, MatchSubframe("http://c.com/")));
1092 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnySubframe())); 1094 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnySubframe()));
1093 } 1095 }
1094 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchTab("aac"))); 1096 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchTab("aac")));
1095 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab())); 1097 ASSERT_NO_FATAL_FAILURE(WaitForTaskManagerRows(1, MatchAnyTab()));
1096 } 1098 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698