OLD | NEW |
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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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::ExecuteJavaScriptAndExtractString( |
102 window->GetRenderViewHost(), | 102 window->GetRenderViewHost(), |
103 L"", | 103 "", |
104 L"window.domAutomationController.send(" | 104 "window.domAutomationController.send(" |
105 L"'' + (window.uiTests && (typeof uiTests.runTest)));", | 105 " '' + (window.uiTests && (typeof uiTests.runTest)));", |
106 &result)); | 106 &result)); |
107 | 107 |
108 if (result == "function") { | 108 if (result == "function") { |
109 ASSERT_TRUE( | 109 ASSERT_TRUE( |
110 content::ExecuteJavaScriptAndExtractString( | 110 content::ExecuteJavaScriptAndExtractString( |
111 window->GetRenderViewHost(), | 111 window->GetRenderViewHost(), |
112 L"", | 112 "", |
113 UTF8ToWide(base::StringPrintf("uiTests.runTest('%s')", | 113 base::StringPrintf("uiTests.runTest('%s')", test_name), |
114 test_name)), | |
115 &result)); | 114 &result)); |
116 EXPECT_EQ("[OK]", result); | 115 EXPECT_EQ("[OK]", result); |
117 } else { | 116 } else { |
118 FAIL() << "DevTools front-end is broken."; | 117 FAIL() << "DevTools front-end is broken."; |
119 } | 118 } |
120 } | 119 } |
121 | 120 |
122 class DevToolsSanityTest : public InProcessBrowserTest { | 121 class DevToolsSanityTest : public InProcessBrowserTest { |
123 public: | 122 public: |
124 DevToolsSanityTest() | 123 DevToolsSanityTest() |
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
526 RunTestFunction(window_, "testReattachAfterCrash"); | 525 RunTestFunction(window_, "testReattachAfterCrash"); |
527 CloseDevToolsWindow(); | 526 CloseDevToolsWindow(); |
528 } | 527 } |
529 | 528 |
530 IN_PROC_BROWSER_TEST_F(DevToolsSanityTest, TestPageWithNoJavaScript) { | 529 IN_PROC_BROWSER_TEST_F(DevToolsSanityTest, TestPageWithNoJavaScript) { |
531 OpenDevToolsWindow("about:blank"); | 530 OpenDevToolsWindow("about:blank"); |
532 std::string result; | 531 std::string result; |
533 ASSERT_TRUE( | 532 ASSERT_TRUE( |
534 content::ExecuteJavaScriptAndExtractString( | 533 content::ExecuteJavaScriptAndExtractString( |
535 window_->GetRenderViewHost(), | 534 window_->GetRenderViewHost(), |
536 L"", | 535 "", |
537 L"window.domAutomationController.send(" | 536 "window.domAutomationController.send(" |
538 L"'' + (window.uiTests && (typeof uiTests.runTest)));", | 537 " '' + (window.uiTests && (typeof uiTests.runTest)));", |
539 &result)); | 538 &result)); |
540 ASSERT_EQ("function", result) << "DevTools front-end is broken."; | 539 ASSERT_EQ("function", result) << "DevTools front-end is broken."; |
541 CloseDevToolsWindow(); | 540 CloseDevToolsWindow(); |
542 } | 541 } |
543 | 542 |
544 #if defined(OS_MACOSX) | 543 #if defined(OS_MACOSX) |
545 #define MAYBE_InspectSharedWorker DISABLED_InspectSharedWorker | 544 #define MAYBE_InspectSharedWorker DISABLED_InspectSharedWorker |
546 #else | 545 #else |
547 #define MAYBE_InspectSharedWorker InspectSharedWorker | 546 #define MAYBE_InspectSharedWorker InspectSharedWorker |
548 #endif | 547 #endif |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
590 content::CONSOLE_MESSAGE_LEVEL_LOG, | 589 content::CONSOLE_MESSAGE_LEVEL_LOG, |
591 "log"); | 590 "log"); |
592 devtools_manager->AddMessageToConsole(agent_host, | 591 devtools_manager->AddMessageToConsole(agent_host, |
593 content::CONSOLE_MESSAGE_LEVEL_ERROR, | 592 content::CONSOLE_MESSAGE_LEVEL_ERROR, |
594 "error"); | 593 "error"); |
595 RunTestFunction(window_, "checkLogAndErrorMessages"); | 594 RunTestFunction(window_, "checkLogAndErrorMessages"); |
596 CloseDevToolsWindow(); | 595 CloseDevToolsWindow(); |
597 } | 596 } |
598 | 597 |
599 } // namespace | 598 } // namespace |
OLD | NEW |