Chromium Code Reviews| 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 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 381 | 381 |
| 382 void CloseInspectedBrowser() { | 382 void CloseInspectedBrowser() { |
| 383 chrome::CloseWindow(browser()); | 383 chrome::CloseWindow(browser()); |
| 384 } | 384 } |
| 385 | 385 |
| 386 protected: | 386 protected: |
| 387 void InjectBeforeUnloadListener(content::WebContents* web_contents) { | 387 void InjectBeforeUnloadListener(content::WebContents* web_contents) { |
| 388 ASSERT_TRUE(content::ExecuteScript(web_contents->GetRenderViewHost(), | 388 ASSERT_TRUE(content::ExecuteScript(web_contents->GetRenderViewHost(), |
| 389 "window.addEventListener('beforeunload'," | 389 "window.addEventListener('beforeunload'," |
| 390 "function(event) { event.returnValue = 'Foo'; });")); | 390 "function(event) { event.returnValue = 'Foo'; });")); |
| 391 // Disable the hang monitor, otherwise there will be a race between the | 391 content::PrepContentsForBeforeUnloadTest(web_contents); |
|
Nico
2017/05/05 16:36:47
:-)
| |
| 392 // beforeunload dialog and the beforeunload hang timer. | |
| 393 web_contents->GetMainFrame()->DisableBeforeUnloadHangMonitorForTesting(); | |
| 394 } | 392 } |
| 395 | 393 |
| 396 void RunBeforeUnloadSanityTest(bool is_docked, | 394 void RunBeforeUnloadSanityTest(bool is_docked, |
| 397 base::Callback<void(void)> close_method, | 395 base::Callback<void(void)> close_method, |
| 398 bool wait_for_browser_close = true) { | 396 bool wait_for_browser_close = true) { |
| 399 OpenDevToolsWindow(kDebuggerTestPage, is_docked); | 397 OpenDevToolsWindow(kDebuggerTestPage, is_docked); |
| 400 scoped_refptr<content::MessageLoopRunner> runner = | 398 scoped_refptr<content::MessageLoopRunner> runner = |
| 401 new content::MessageLoopRunner; | 399 new content::MessageLoopRunner; |
| 402 DevToolsWindowTesting::Get(window_)-> | 400 DevToolsWindowTesting::Get(window_)-> |
| 403 SetCloseCallback(runner->QuitClosure()); | 401 SetCloseCallback(runner->QuitClosure()); |
| (...skipping 1670 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2074 RunTestFunction(window, "testWindowInitializedOnNavigateBack"); | 2072 RunTestFunction(window, "testWindowInitializedOnNavigateBack"); |
| 2075 | 2073 |
| 2076 DevToolsWindowTesting::CloseDevToolsWindowSync(window); | 2074 DevToolsWindowTesting::CloseDevToolsWindowSync(window); |
| 2077 content::WebUIControllerFactory::UnregisterFactoryForTesting(&test_factory); | 2075 content::WebUIControllerFactory::UnregisterFactoryForTesting(&test_factory); |
| 2078 } | 2076 } |
| 2079 | 2077 |
| 2080 // Tests scripts panel showing. | 2078 // Tests scripts panel showing. |
| 2081 IN_PROC_BROWSER_TEST_F(DevToolsSanityTest, TestDevToolsSharedWorker) { | 2079 IN_PROC_BROWSER_TEST_F(DevToolsSanityTest, TestDevToolsSharedWorker) { |
| 2082 RunTest("testDevToolsSharedWorker", url::kAboutBlankURL); | 2080 RunTest("testDevToolsSharedWorker", url::kAboutBlankURL); |
| 2083 } | 2081 } |
| OLD | NEW |