| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "base/strings/utf_string_conversions.h" |
| 6 #include "base/test/scoped_feature_list.h" |
| 7 #include "chrome/browser/ui/browser.h" |
| 8 #include "chrome/browser/ui/javascript_dialogs/javascript_dialog_tab_helper.h" |
| 9 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 10 #include "chrome/common/chrome_features.h" |
| 11 #include "chrome/test/base/in_process_browser_test.h" |
| 12 #include "content/public/browser/render_frame_host.h" |
| 13 #include "content/public/browser/web_contents.h" |
| 14 #include "content/public/test/browser_test_utils.h" |
| 15 #include "content/public/test/test_utils.h" |
| 16 |
| 17 using JavaScriptDialogTest = InProcessBrowserTest; |
| 18 |
| 19 IN_PROC_BROWSER_TEST_F(JavaScriptDialogTest, ReloadDoesntHang) { |
| 20 base::test::ScopedFeatureList feature_list; |
| 21 feature_list.InitAndEnableFeature(features::kAutoDismissingDialogs); |
| 22 |
| 23 content::WebContents* tab = |
| 24 browser()->tab_strip_model()->GetActiveWebContents(); |
| 25 JavaScriptDialogTabHelper* js_helper = |
| 26 JavaScriptDialogTabHelper::FromWebContents(tab); |
| 27 |
| 28 // Show a dialog. |
| 29 |
| 30 scoped_refptr<content::MessageLoopRunner> runner = |
| 31 new content::MessageLoopRunner; |
| 32 js_helper->SetDialogShownCallbackForTesting(runner->QuitClosure()); |
| 33 tab->GetMainFrame()->ExecuteJavaScriptForTests(base::UTF8ToUTF16("alert()")); |
| 34 runner->Run(); |
| 35 |
| 36 // Try reloading. |
| 37 |
| 38 tab->GetController().Reload(false); |
| 39 content::WaitForLoadStop(tab); |
| 40 |
| 41 // If the WaitForLoadStop doesn't hang forever, we've passed. |
| 42 } |
| OLD | NEW |