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

Side by Side Diff: chrome/browser/devtools/devtools_sanity_browsertest.cc

Issue 11753009: Simplify ExecuteJavaScript* functions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Update prerender_browsertest.cc. Created 7 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
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 "base/bind.h" 5 #include "base/bind.h"
6 #include "base/cancelable_callback.h" 6 #include "base/cancelable_callback.h"
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "base/path_service.h" 10 #include "base/path_service.h"
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 const char kReloadSharedWorkerTestPage[] = 91 const char kReloadSharedWorkerTestPage[] =
92 "files/workers/debug_shared_worker_initialization.html"; 92 "files/workers/debug_shared_worker_initialization.html";
93 93
94 void RunTestFunction(DevToolsWindow* window, const char* test_name) { 94 void RunTestFunction(DevToolsWindow* window, const char* test_name) {
95 std::string result; 95 std::string result;
96 96
97 // At first check that JavaScript part of the front-end is loaded by 97 // At first check that JavaScript part of the front-end is loaded by
98 // checking that global variable uiTests exists(it's created after all js 98 // checking that global variable uiTests exists(it's created after all js
99 // files have been loaded) and has runTest method. 99 // files have been loaded) and has runTest method.
100 ASSERT_TRUE( 100 ASSERT_TRUE(
101 content::ExecuteJavaScriptAndExtractString( 101 content::ExecuteScriptAndExtractString(
102 window->GetRenderViewHost(), 102 window->GetRenderViewHost(),
103 "",
104 "window.domAutomationController.send(" 103 "window.domAutomationController.send("
105 " '' + (window.uiTests && (typeof uiTests.runTest)));", 104 " '' + (window.uiTests && (typeof uiTests.runTest)));",
106 &result)); 105 &result));
107 106
108 if (result == "function") { 107 if (result == "function") {
109 ASSERT_TRUE( 108 ASSERT_TRUE(
110 content::ExecuteJavaScriptAndExtractString( 109 content::ExecuteScriptAndExtractString(
111 window->GetRenderViewHost(), 110 window->GetRenderViewHost(),
112 "",
113 base::StringPrintf("uiTests.runTest('%s')", test_name), 111 base::StringPrintf("uiTests.runTest('%s')", test_name),
114 &result)); 112 &result));
115 EXPECT_EQ("[OK]", result); 113 EXPECT_EQ("[OK]", result);
116 } else { 114 } else {
117 FAIL() << "DevTools front-end is broken."; 115 FAIL() << "DevTools front-end is broken.";
118 } 116 }
119 } 117 }
120 118
121 class DevToolsSanityTest : public InProcessBrowserTest { 119 class DevToolsSanityTest : public InProcessBrowserTest {
122 public: 120 public:
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after
523 observer.Wait(); 521 observer.Wait();
524 522
525 RunTestFunction(window_, "testReattachAfterCrash"); 523 RunTestFunction(window_, "testReattachAfterCrash");
526 CloseDevToolsWindow(); 524 CloseDevToolsWindow();
527 } 525 }
528 526
529 IN_PROC_BROWSER_TEST_F(DevToolsSanityTest, TestPageWithNoJavaScript) { 527 IN_PROC_BROWSER_TEST_F(DevToolsSanityTest, TestPageWithNoJavaScript) {
530 OpenDevToolsWindow("about:blank"); 528 OpenDevToolsWindow("about:blank");
531 std::string result; 529 std::string result;
532 ASSERT_TRUE( 530 ASSERT_TRUE(
533 content::ExecuteJavaScriptAndExtractString( 531 content::ExecuteScriptAndExtractString(
534 window_->GetRenderViewHost(), 532 window_->GetRenderViewHost(),
535 "",
536 "window.domAutomationController.send(" 533 "window.domAutomationController.send("
537 " '' + (window.uiTests && (typeof uiTests.runTest)));", 534 " '' + (window.uiTests && (typeof uiTests.runTest)));",
538 &result)); 535 &result));
539 ASSERT_EQ("function", result) << "DevTools front-end is broken."; 536 ASSERT_EQ("function", result) << "DevTools front-end is broken.";
540 CloseDevToolsWindow(); 537 CloseDevToolsWindow();
541 } 538 }
542 539
543 #if defined(OS_MACOSX) 540 #if defined(OS_MACOSX)
544 #define MAYBE_InspectSharedWorker DISABLED_InspectSharedWorker 541 #define MAYBE_InspectSharedWorker DISABLED_InspectSharedWorker
545 #else 542 #else
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
589 content::CONSOLE_MESSAGE_LEVEL_LOG, 586 content::CONSOLE_MESSAGE_LEVEL_LOG,
590 "log"); 587 "log");
591 devtools_manager->AddMessageToConsole(agent_host, 588 devtools_manager->AddMessageToConsole(agent_host,
592 content::CONSOLE_MESSAGE_LEVEL_ERROR, 589 content::CONSOLE_MESSAGE_LEVEL_ERROR,
593 "error"); 590 "error");
594 RunTestFunction(window_, "checkLogAndErrorMessages"); 591 RunTestFunction(window_, "checkLogAndErrorMessages");
595 CloseDevToolsWindow(); 592 CloseDevToolsWindow();
596 } 593 }
597 594
598 } // namespace 595 } // namespace
OLDNEW
« no previous file with comments | « chrome/browser/content_settings/content_settings_browsertest.cc ('k') | chrome/browser/do_not_track_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698