| 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 #if defined(OS_POSIX) | 5 #if defined(OS_POSIX) |
| 6 #include <signal.h> | 6 #include <signal.h> |
| 7 #endif | 7 #endif |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
| 12 #include "chrome/browser/chrome_notification_types.h" | 12 #include "chrome/browser/chrome_notification_types.h" |
| 13 #include "chrome/browser/net/url_request_mock_util.h" | 13 #include "chrome/browser/net/url_request_mock_util.h" |
| 14 #include "chrome/browser/ui/app_modal_dialogs/javascript_app_modal_dialog.h" | 14 #include "chrome/browser/ui/app_modal_dialogs/javascript_app_modal_dialog.h" |
| 15 #include "chrome/browser/ui/app_modal_dialogs/native_app_modal_dialog.h" | 15 #include "chrome/browser/ui/app_modal_dialogs/native_app_modal_dialog.h" |
| 16 #include "chrome/browser/ui/browser.h" | 16 #include "chrome/browser/ui/browser.h" |
| 17 #include "chrome/browser/ui/browser_commands.h" | 17 #include "chrome/browser/ui/browser_commands.h" |
| 18 #include "chrome/browser/ui/browser_list.h" | 18 #include "chrome/browser/ui/browser_list.h" |
| 19 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 19 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 20 #include "chrome/common/chrome_switches.h" | 20 #include "chrome/common/chrome_switches.h" |
| 21 #include "chrome/test/base/in_process_browser_test.h" | 21 #include "chrome/test/base/in_process_browser_test.h" |
| 22 #include "chrome/test/base/ui_test_utils.h" | 22 #include "chrome/test/base/ui_test_utils.h" |
| 23 #include "content/public/browser/browser_thread.h" | 23 #include "content/public/browser/browser_thread.h" |
| 24 #include "content/public/browser/notification_service.h" | 24 #include "content/public/browser/notification_service.h" |
| 25 #include "content/public/browser/web_contents.h" | 25 #include "content/public/browser/web_contents.h" |
| 26 #include "content/public/test/browser_test_utils.h" | 26 #include "content/public/test/browser_test_utils.h" |
| 27 #include "content/test/net/url_request_mock_http_job.h" | 27 #include "net/test/url_request/url_request_mock_http_job.h" |
| 28 #include "net/url_request/url_request_test_util.h" | 28 #include "net/url_request/url_request_test_util.h" |
| 29 | 29 |
| 30 #if defined(OS_WIN) | 30 #if defined(OS_WIN) |
| 31 // For version specific disabled tests below (http://crbug.com/267597). | 31 // For version specific disabled tests below (http://crbug.com/267597). |
| 32 #include "base/win/windows_version.h" | 32 #include "base/win/windows_version.h" |
| 33 #endif | 33 #endif |
| 34 | 34 |
| 35 using base::TimeDelta; | 35 using base::TimeDelta; |
| 36 using content::BrowserThread; | 36 using content::BrowserThread; |
| 37 | 37 |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 } | 139 } |
| 140 | 140 |
| 141 void NavigateToDataURL(const std::string& html_content, | 141 void NavigateToDataURL(const std::string& html_content, |
| 142 const char* expected_title) { | 142 const char* expected_title) { |
| 143 ui_test_utils::NavigateToURL(browser(), | 143 ui_test_utils::NavigateToURL(browser(), |
| 144 GURL("data:text/html," + html_content)); | 144 GURL("data:text/html," + html_content)); |
| 145 CheckTitle(expected_title); | 145 CheckTitle(expected_title); |
| 146 } | 146 } |
| 147 | 147 |
| 148 void NavigateToNolistenersFileTwice() { | 148 void NavigateToNolistenersFileTwice() { |
| 149 GURL url(content::URLRequestMockHTTPJob::GetMockUrl( | 149 GURL url(net::URLRequestMockHTTPJob::GetMockUrl( |
| 150 base::FilePath(FILE_PATH_LITERAL("title2.html")))); | 150 base::FilePath(FILE_PATH_LITERAL("title2.html")))); |
| 151 ui_test_utils::NavigateToURL(browser(), url); | 151 ui_test_utils::NavigateToURL(browser(), url); |
| 152 CheckTitle("Title Of Awesomeness"); | 152 CheckTitle("Title Of Awesomeness"); |
| 153 ui_test_utils::NavigateToURL(browser(), url); | 153 ui_test_utils::NavigateToURL(browser(), url); |
| 154 CheckTitle("Title Of Awesomeness"); | 154 CheckTitle("Title Of Awesomeness"); |
| 155 } | 155 } |
| 156 | 156 |
| 157 // Navigates to a URL asynchronously, then again synchronously. The first | 157 // Navigates to a URL asynchronously, then again synchronously. The first |
| 158 // load is purposely async to test the case where the user loads another | 158 // load is purposely async to test the case where the user loads another |
| 159 // page without waiting for the first load to complete. | 159 // page without waiting for the first load to complete. |
| 160 void NavigateToNolistenersFileTwiceAsync() { | 160 void NavigateToNolistenersFileTwiceAsync() { |
| 161 GURL url(content::URLRequestMockHTTPJob::GetMockUrl( | 161 GURL url(net::URLRequestMockHTTPJob::GetMockUrl( |
| 162 base::FilePath(FILE_PATH_LITERAL("title2.html")))); | 162 base::FilePath(FILE_PATH_LITERAL("title2.html")))); |
| 163 ui_test_utils::NavigateToURLWithDisposition(browser(), url, CURRENT_TAB, 0); | 163 ui_test_utils::NavigateToURLWithDisposition(browser(), url, CURRENT_TAB, 0); |
| 164 ui_test_utils::NavigateToURL(browser(), url); | 164 ui_test_utils::NavigateToURL(browser(), url); |
| 165 CheckTitle("Title Of Awesomeness"); | 165 CheckTitle("Title Of Awesomeness"); |
| 166 } | 166 } |
| 167 | 167 |
| 168 void LoadUrlAndQuitBrowser(const std::string& html_content, | 168 void LoadUrlAndQuitBrowser(const std::string& html_content, |
| 169 const char* expected_title) { | 169 const char* expected_title) { |
| 170 NavigateToDataURL(html_content, expected_title); | 170 NavigateToDataURL(html_content, expected_title); |
| 171 content::WindowedNotificationObserver window_observer( | 171 content::WindowedNotificationObserver window_observer( |
| (...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 633 content::WindowedNotificationObserver window_observer( | 633 content::WindowedNotificationObserver window_observer( |
| 634 chrome::NOTIFICATION_BROWSER_CLOSED, | 634 chrome::NOTIFICATION_BROWSER_CLOSED, |
| 635 content::NotificationService::AllSources()); | 635 content::NotificationService::AllSources()); |
| 636 chrome::CloseWindow(browser()); | 636 chrome::CloseWindow(browser()); |
| 637 CrashTab(beforeunload_contents); | 637 CrashTab(beforeunload_contents); |
| 638 window_observer.Wait(); | 638 window_observer.Wait(); |
| 639 } | 639 } |
| 640 | 640 |
| 641 // TODO(ojan): Add tests for unload/beforeunload that have multiple tabs | 641 // TODO(ojan): Add tests for unload/beforeunload that have multiple tabs |
| 642 // and multiple windows. | 642 // and multiple windows. |
| OLD | NEW |