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 <stddef.h> | 5 #include <stddef.h> |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
379 | 379 |
380 void CloseInspectedBrowser() { | 380 void CloseInspectedBrowser() { |
381 chrome::CloseWindow(browser()); | 381 chrome::CloseWindow(browser()); |
382 } | 382 } |
383 | 383 |
384 protected: | 384 protected: |
385 void InjectBeforeUnloadListener(content::WebContents* web_contents) { | 385 void InjectBeforeUnloadListener(content::WebContents* web_contents) { |
386 ASSERT_TRUE(content::ExecuteScript(web_contents->GetRenderViewHost(), | 386 ASSERT_TRUE(content::ExecuteScript(web_contents->GetRenderViewHost(), |
387 "window.addEventListener('beforeunload'," | 387 "window.addEventListener('beforeunload'," |
388 "function(event) { event.returnValue = 'Foo'; });")); | 388 "function(event) { event.returnValue = 'Foo'; });")); |
| 389 // JavaScript onbeforeunload dialogs require a user gesture. |
| 390 web_contents->GetMainFrame()->ExecuteJavaScriptWithUserGestureForTests( |
| 391 base::string16()); |
389 // Disable the hang monitor, otherwise there will be a race between the | 392 // Disable the hang monitor, otherwise there will be a race between the |
390 // beforeunload dialog and the beforeunload hang timer. | 393 // beforeunload dialog and the beforeunload hang timer. |
391 web_contents->GetMainFrame()->DisableBeforeUnloadHangMonitorForTesting(); | 394 web_contents->GetMainFrame()->DisableBeforeUnloadHangMonitorForTesting(); |
392 } | 395 } |
393 | 396 |
394 void RunBeforeUnloadSanityTest(bool is_docked, | 397 void RunBeforeUnloadSanityTest(bool is_docked, |
395 base::Callback<void(void)> close_method, | 398 base::Callback<void(void)> close_method, |
396 bool wait_for_browser_close = true) { | 399 bool wait_for_browser_close = true) { |
397 OpenDevToolsWindow(kDebuggerTestPage, is_docked); | 400 OpenDevToolsWindow(kDebuggerTestPage, is_docked); |
398 scoped_refptr<content::MessageLoopRunner> runner = | 401 scoped_refptr<content::MessageLoopRunner> runner = |
(...skipping 1668 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2067 RunTestFunction(window, "testWindowInitializedOnNavigateBack"); | 2070 RunTestFunction(window, "testWindowInitializedOnNavigateBack"); |
2068 | 2071 |
2069 DevToolsWindowTesting::CloseDevToolsWindowSync(window); | 2072 DevToolsWindowTesting::CloseDevToolsWindowSync(window); |
2070 content::WebUIControllerFactory::UnregisterFactoryForTesting(&test_factory); | 2073 content::WebUIControllerFactory::UnregisterFactoryForTesting(&test_factory); |
2071 } | 2074 } |
2072 | 2075 |
2073 // Tests scripts panel showing. | 2076 // Tests scripts panel showing. |
2074 IN_PROC_BROWSER_TEST_F(DevToolsSanityTest, TestDevToolsSharedWorker) { | 2077 IN_PROC_BROWSER_TEST_F(DevToolsSanityTest, TestDevToolsSharedWorker) { |
2075 RunTest("testDevToolsSharedWorker", url::kAboutBlankURL); | 2078 RunTest("testDevToolsSharedWorker", url::kAboutBlankURL); |
2076 } | 2079 } |
OLD | NEW |