| 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/location.h" | 9 #include "base/location.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 #include "content/public/browser/web_contents.h" | 48 #include "content/public/browser/web_contents.h" |
| 49 #include "content/public/browser/worker_service.h" | 49 #include "content/public/browser/worker_service.h" |
| 50 #include "content/public/browser/worker_service_observer.h" | 50 #include "content/public/browser/worker_service_observer.h" |
| 51 #include "content/public/common/content_switches.h" | 51 #include "content/public/common/content_switches.h" |
| 52 #include "content/public/test/browser_test_utils.h" | 52 #include "content/public/test/browser_test_utils.h" |
| 53 #include "content/public/test/test_navigation_observer.h" | 53 #include "content/public/test/test_navigation_observer.h" |
| 54 #include "extensions/browser/extension_registry.h" | 54 #include "extensions/browser/extension_registry.h" |
| 55 #include "extensions/browser/extension_system.h" | 55 #include "extensions/browser/extension_system.h" |
| 56 #include "extensions/browser/notification_types.h" | 56 #include "extensions/browser/notification_types.h" |
| 57 #include "extensions/common/switches.h" | 57 #include "extensions/common/switches.h" |
| 58 #include "net/test/spawned_test_server/spawned_test_server.h" | |
| 59 #include "ui/compositor/compositor_switches.h" | 58 #include "ui/compositor/compositor_switches.h" |
| 60 #include "ui/gl/gl_switches.h" | 59 #include "ui/gl/gl_switches.h" |
| 61 | 60 |
| 62 using app_modal::AppModalDialog; | 61 using app_modal::AppModalDialog; |
| 63 using app_modal::JavaScriptAppModalDialog; | 62 using app_modal::JavaScriptAppModalDialog; |
| 64 using app_modal::NativeAppModalDialog; | 63 using app_modal::NativeAppModalDialog; |
| 65 using content::BrowserThread; | 64 using content::BrowserThread; |
| 66 using content::DevToolsAgentHost; | 65 using content::DevToolsAgentHost; |
| 67 using content::NavigationController; | 66 using content::NavigationController; |
| 68 using content::RenderViewHost; | 67 using content::RenderViewHost; |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 DevToolsSanityTest() : window_(NULL) {} | 137 DevToolsSanityTest() : window_(NULL) {} |
| 139 | 138 |
| 140 protected: | 139 protected: |
| 141 void RunTest(const std::string& test_name, const std::string& test_page) { | 140 void RunTest(const std::string& test_name, const std::string& test_page) { |
| 142 OpenDevToolsWindow(test_page, false); | 141 OpenDevToolsWindow(test_page, false); |
| 143 RunTestFunction(window_, test_name.c_str()); | 142 RunTestFunction(window_, test_name.c_str()); |
| 144 CloseDevToolsWindow(); | 143 CloseDevToolsWindow(); |
| 145 } | 144 } |
| 146 | 145 |
| 147 void LoadTestPage(const std::string& test_page) { | 146 void LoadTestPage(const std::string& test_page) { |
| 148 GURL url = test_server()->GetURL(test_page); | 147 GURL url = spawned_test_server()->GetURL(test_page); |
| 149 ui_test_utils::NavigateToURL(browser(), url); | 148 ui_test_utils::NavigateToURL(browser(), url); |
| 150 } | 149 } |
| 151 | 150 |
| 152 void OpenDevToolsWindow(const std::string& test_page, bool is_docked) { | 151 void OpenDevToolsWindow(const std::string& test_page, bool is_docked) { |
| 153 ASSERT_TRUE(test_server()->Start()); | 152 ASSERT_TRUE(spawned_test_server()->Start()); |
| 154 LoadTestPage(test_page); | 153 LoadTestPage(test_page); |
| 155 | 154 |
| 156 window_ = DevToolsWindowTesting::OpenDevToolsWindowSync(GetInspectedTab(), | 155 window_ = DevToolsWindowTesting::OpenDevToolsWindowSync(GetInspectedTab(), |
| 157 is_docked); | 156 is_docked); |
| 158 } | 157 } |
| 159 | 158 |
| 160 WebContents* GetInspectedTab() { | 159 WebContents* GetInspectedTab() { |
| 161 return browser()->tab_strip_model()->GetWebContentsAt(0); | 160 return browser()->tab_strip_model()->GetWebContentsAt(0); |
| 162 } | 161 } |
| 163 | 162 |
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 477 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, | 476 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
| 478 base::MessageLoop::QuitWhenIdleClosure()); | 477 base::MessageLoop::QuitWhenIdleClosure()); |
| 479 delete this; | 478 delete this; |
| 480 } | 479 } |
| 481 scoped_refptr<WorkerData> worker_data_; | 480 scoped_refptr<WorkerData> worker_data_; |
| 482 }; | 481 }; |
| 483 | 482 |
| 484 void RunTest(const char* test_name, | 483 void RunTest(const char* test_name, |
| 485 const char* test_page, | 484 const char* test_page, |
| 486 const char* worker_path) { | 485 const char* worker_path) { |
| 487 ASSERT_TRUE(test_server()->Start()); | 486 ASSERT_TRUE(spawned_test_server()->Start()); |
| 488 GURL url = test_server()->GetURL(test_page); | 487 GURL url = spawned_test_server()->GetURL(test_page); |
| 489 ui_test_utils::NavigateToURL(browser(), url); | 488 ui_test_utils::NavigateToURL(browser(), url); |
| 490 | 489 |
| 491 scoped_refptr<WorkerData> worker_data = | 490 scoped_refptr<WorkerData> worker_data = |
| 492 WaitForFirstSharedWorker(worker_path); | 491 WaitForFirstSharedWorker(worker_path); |
| 493 OpenDevToolsWindowForSharedWorker(worker_data.get()); | 492 OpenDevToolsWindowForSharedWorker(worker_data.get()); |
| 494 RunTestFunction(window_, test_name); | 493 RunTestFunction(window_, test_name); |
| 495 CloseDevToolsWindow(); | 494 CloseDevToolsWindow(); |
| 496 } | 495 } |
| 497 | 496 |
| 498 static void TerminateWorkerOnIOThread(scoped_refptr<WorkerData> worker_data) { | 497 static void TerminateWorkerOnIOThread(scoped_refptr<WorkerData> worker_data) { |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 616 #define MAYBE_TestUndockedDevToolsUnresponsive DISABLED_TestUndockedDevToolsUnre
sponsive | 615 #define MAYBE_TestUndockedDevToolsUnresponsive DISABLED_TestUndockedDevToolsUnre
sponsive |
| 617 #else | 616 #else |
| 618 #define MAYBE_TestUndockedDevToolsUnresponsive TestUndockedDevToolsUnresponsive | 617 #define MAYBE_TestUndockedDevToolsUnresponsive TestUndockedDevToolsUnresponsive |
| 619 #endif | 618 #endif |
| 620 | 619 |
| 621 // Tests that inspected tab gets closed if devtools renderer | 620 // Tests that inspected tab gets closed if devtools renderer |
| 622 // becomes unresponsive during beforeunload event interception. | 621 // becomes unresponsive during beforeunload event interception. |
| 623 // @see http://crbug.com/322380 | 622 // @see http://crbug.com/322380 |
| 624 IN_PROC_BROWSER_TEST_F(DevToolsUnresponsiveBeforeUnloadTest, | 623 IN_PROC_BROWSER_TEST_F(DevToolsUnresponsiveBeforeUnloadTest, |
| 625 MAYBE_TestUndockedDevToolsUnresponsive) { | 624 MAYBE_TestUndockedDevToolsUnresponsive) { |
| 626 ASSERT_TRUE(test_server()->Start()); | 625 ASSERT_TRUE(spawned_test_server()->Start()); |
| 627 LoadTestPage(kDebuggerTestPage); | 626 LoadTestPage(kDebuggerTestPage); |
| 628 DevToolsWindow* devtools_window = OpenDevToolWindowOnWebContents( | 627 DevToolsWindow* devtools_window = OpenDevToolWindowOnWebContents( |
| 629 GetInspectedTab(), false); | 628 GetInspectedTab(), false); |
| 630 | 629 |
| 631 scoped_refptr<content::MessageLoopRunner> runner = | 630 scoped_refptr<content::MessageLoopRunner> runner = |
| 632 new content::MessageLoopRunner; | 631 new content::MessageLoopRunner; |
| 633 DevToolsWindowTesting::Get(devtools_window)->SetCloseCallback( | 632 DevToolsWindowTesting::Get(devtools_window)->SetCloseCallback( |
| 634 runner->QuitClosure()); | 633 runner->QuitClosure()); |
| 635 | 634 |
| 636 ASSERT_TRUE(content::ExecuteScript( | 635 ASSERT_TRUE(content::ExecuteScript( |
| 637 DevToolsWindowTesting::Get(devtools_window)->main_web_contents()-> | 636 DevToolsWindowTesting::Get(devtools_window)->main_web_contents()-> |
| 638 GetRenderViewHost(), | 637 GetRenderViewHost(), |
| 639 "window.addEventListener('beforeunload'," | 638 "window.addEventListener('beforeunload'," |
| 640 "function(event) { while (true); });")); | 639 "function(event) { while (true); });")); |
| 641 CloseInspectedTab(); | 640 CloseInspectedTab(); |
| 642 runner->Run(); | 641 runner->Run(); |
| 643 } | 642 } |
| 644 | 643 |
| 645 // Tests that closing worker inspector window does not cause browser crash | 644 // Tests that closing worker inspector window does not cause browser crash |
| 646 // @see http://crbug.com/323031 | 645 // @see http://crbug.com/323031 |
| 647 IN_PROC_BROWSER_TEST_F(DevToolsBeforeUnloadTest, | 646 IN_PROC_BROWSER_TEST_F(DevToolsBeforeUnloadTest, |
| 648 TestWorkerWindowClosing) { | 647 TestWorkerWindowClosing) { |
| 649 ASSERT_TRUE(test_server()->Start()); | 648 ASSERT_TRUE(spawned_test_server()->Start()); |
| 650 LoadTestPage(kDebuggerTestPage); | 649 LoadTestPage(kDebuggerTestPage); |
| 651 DevToolsWindow* devtools_window = OpenDevToolWindowOnWebContents( | 650 DevToolsWindow* devtools_window = OpenDevToolWindowOnWebContents( |
| 652 GetInspectedTab(), false); | 651 GetInspectedTab(), false); |
| 653 | 652 |
| 654 OpenDevToolsPopupWindow(devtools_window); | 653 OpenDevToolsPopupWindow(devtools_window); |
| 655 CloseDevToolsPopupWindow(devtools_window); | 654 CloseDevToolsPopupWindow(devtools_window); |
| 656 } | 655 } |
| 657 | 656 |
| 658 // Tests that BeforeUnload event gets called on devtools that are opened | 657 // Tests that BeforeUnload event gets called on devtools that are opened |
| 659 // on another devtools. | 658 // on another devtools. |
| 660 // Disabled because of http://crbug.com/497857 | 659 // Disabled because of http://crbug.com/497857 |
| 661 IN_PROC_BROWSER_TEST_F(DevToolsBeforeUnloadTest, | 660 IN_PROC_BROWSER_TEST_F(DevToolsBeforeUnloadTest, |
| 662 DISABLED_TestDevToolsOnDevTools) { | 661 DISABLED_TestDevToolsOnDevTools) { |
| 663 ASSERT_TRUE(test_server()->Start()); | 662 ASSERT_TRUE(spawned_test_server()->Start()); |
| 664 LoadTestPage(kDebuggerTestPage); | 663 LoadTestPage(kDebuggerTestPage); |
| 665 | 664 |
| 666 std::vector<DevToolsWindow*> windows; | 665 std::vector<DevToolsWindow*> windows; |
| 667 std::vector<content::WindowedNotificationObserver*> close_observers; | 666 std::vector<content::WindowedNotificationObserver*> close_observers; |
| 668 content::WebContents* inspected_web_contents = GetInspectedTab(); | 667 content::WebContents* inspected_web_contents = GetInspectedTab(); |
| 669 for (int i = 0; i < 3; ++i) { | 668 for (int i = 0; i < 3; ++i) { |
| 670 DevToolsWindow* devtools_window = OpenDevToolWindowOnWebContents( | 669 DevToolsWindow* devtools_window = OpenDevToolWindowOnWebContents( |
| 671 inspected_web_contents, i == 0); | 670 inspected_web_contents, i == 0); |
| 672 windows.push_back(devtools_window); | 671 windows.push_back(devtools_window); |
| 673 content::WindowedNotificationObserver* close_observer = | 672 content::WindowedNotificationObserver* close_observer = |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 838 IN_PROC_BROWSER_TEST_F(DevToolsSanityTest, TestSettings) { | 837 IN_PROC_BROWSER_TEST_F(DevToolsSanityTest, TestSettings) { |
| 839 OpenDevToolsWindow("about:blank", true); | 838 OpenDevToolsWindow("about:blank", true); |
| 840 RunTestFunction(window_, "testSettings"); | 839 RunTestFunction(window_, "testSettings"); |
| 841 CloseDevToolsWindow(); | 840 CloseDevToolsWindow(); |
| 842 } | 841 } |
| 843 | 842 |
| 844 // Tests that external navigation from inspector page is always handled by | 843 // Tests that external navigation from inspector page is always handled by |
| 845 // DevToolsWindow and results in inspected page navigation. | 844 // DevToolsWindow and results in inspected page navigation. |
| 846 IN_PROC_BROWSER_TEST_F(DevToolsSanityTest, TestDevToolsExternalNavigation) { | 845 IN_PROC_BROWSER_TEST_F(DevToolsSanityTest, TestDevToolsExternalNavigation) { |
| 847 OpenDevToolsWindow(kDebuggerTestPage, true); | 846 OpenDevToolsWindow(kDebuggerTestPage, true); |
| 848 GURL url = test_server()->GetURL(kNavigateBackTestPage); | 847 GURL url = spawned_test_server()->GetURL(kNavigateBackTestPage); |
| 849 ui_test_utils::UrlLoadObserver observer(url, | 848 ui_test_utils::UrlLoadObserver observer(url, |
| 850 content::NotificationService::AllSources()); | 849 content::NotificationService::AllSources()); |
| 851 ASSERT_TRUE(content::ExecuteScript( | 850 ASSERT_TRUE(content::ExecuteScript( |
| 852 main_web_contents(), | 851 main_web_contents(), |
| 853 std::string("window.location = \"") + url.spec() + "\"")); | 852 std::string("window.location = \"") + url.spec() + "\"")); |
| 854 observer.Wait(); | 853 observer.Wait(); |
| 855 | 854 |
| 856 ASSERT_TRUE(main_web_contents()->GetURL(). | 855 ASSERT_TRUE(main_web_contents()->GetURL(). |
| 857 SchemeIs(content::kChromeDevToolsScheme)); | 856 SchemeIs(content::kChromeDevToolsScheme)); |
| 858 ASSERT_EQ(url, GetInspectedTab()->GetURL()); | 857 ASSERT_EQ(url, GetInspectedTab()->GetURL()); |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 936 switches::kAshBrowserTests)) | 935 switches::kAshBrowserTests)) |
| 937 return; | 936 return; |
| 938 #endif | 937 #endif |
| 939 | 938 |
| 940 RunTest("testSharedWorker", kSharedWorkerTestPage, kSharedWorkerTestWorker); | 939 RunTest("testSharedWorker", kSharedWorkerTestPage, kSharedWorkerTestWorker); |
| 941 } | 940 } |
| 942 | 941 |
| 943 // Disabled, crashes under Dr.Memory and ASan, http://crbug.com/432444. | 942 // Disabled, crashes under Dr.Memory and ASan, http://crbug.com/432444. |
| 944 IN_PROC_BROWSER_TEST_F(WorkerDevToolsSanityTest, | 943 IN_PROC_BROWSER_TEST_F(WorkerDevToolsSanityTest, |
| 945 DISABLED_PauseInSharedWorkerInitialization) { | 944 DISABLED_PauseInSharedWorkerInitialization) { |
| 946 ASSERT_TRUE(test_server()->Start()); | 945 ASSERT_TRUE(spawned_test_server()->Start()); |
| 947 GURL url = test_server()->GetURL(kReloadSharedWorkerTestPage); | 946 GURL url = spawned_test_server()->GetURL(kReloadSharedWorkerTestPage); |
| 948 ui_test_utils::NavigateToURL(browser(), url); | 947 ui_test_utils::NavigateToURL(browser(), url); |
| 949 | 948 |
| 950 scoped_refptr<WorkerData> worker_data = | 949 scoped_refptr<WorkerData> worker_data = |
| 951 WaitForFirstSharedWorker(kReloadSharedWorkerTestWorker); | 950 WaitForFirstSharedWorker(kReloadSharedWorkerTestWorker); |
| 952 OpenDevToolsWindowForSharedWorker(worker_data.get()); | 951 OpenDevToolsWindowForSharedWorker(worker_data.get()); |
| 953 | 952 |
| 954 // We should make sure that the worker inspector has loaded before | 953 // We should make sure that the worker inspector has loaded before |
| 955 // terminating worker. | 954 // terminating worker. |
| 956 RunTestFunction(window_, "testPauseInSharedWorkerInitialization1"); | 955 RunTestFunction(window_, "testPauseInSharedWorkerInitialization1"); |
| 957 | 956 |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1037 (defined(OS_CHROMEOS) && defined(OFFICIAL_BUILD)) | 1036 (defined(OS_CHROMEOS) && defined(OFFICIAL_BUILD)) |
| 1038 #define MAYBE_TestScreenshotRecording DISABLED_TestScreenshotRecording | 1037 #define MAYBE_TestScreenshotRecording DISABLED_TestScreenshotRecording |
| 1039 #else | 1038 #else |
| 1040 #define MAYBE_TestScreenshotRecording TestScreenshotRecording | 1039 #define MAYBE_TestScreenshotRecording TestScreenshotRecording |
| 1041 #endif | 1040 #endif |
| 1042 // Tests raw headers text. | 1041 // Tests raw headers text. |
| 1043 IN_PROC_BROWSER_TEST_F(DevToolsPixelOutputTests, | 1042 IN_PROC_BROWSER_TEST_F(DevToolsPixelOutputTests, |
| 1044 MAYBE_TestScreenshotRecording) { | 1043 MAYBE_TestScreenshotRecording) { |
| 1045 RunTest("testScreenshotRecording", std::string()); | 1044 RunTest("testScreenshotRecording", std::string()); |
| 1046 } | 1045 } |
| OLD | NEW |