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