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 "content/public/test/browser_test_utils.h" | 5 #include "content/public/test/browser_test_utils.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <tuple> | 8 #include <tuple> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
464 Source<NavigationController>(&web_contents->GetController())); | 464 Source<NavigationController>(&web_contents->GetController())); |
465 load_stop_observer.Wait(); | 465 load_stop_observer.Wait(); |
466 } | 466 } |
467 } | 467 } |
468 | 468 |
469 bool WaitForLoadStop(WebContents* web_contents) { | 469 bool WaitForLoadStop(WebContents* web_contents) { |
470 WaitForLoadStopWithoutSuccessCheck(web_contents); | 470 WaitForLoadStopWithoutSuccessCheck(web_contents); |
471 return IsLastCommittedEntryOfPageType(web_contents, PAGE_TYPE_NORMAL); | 471 return IsLastCommittedEntryOfPageType(web_contents, PAGE_TYPE_NORMAL); |
472 } | 472 } |
473 | 473 |
| 474 void PrepContentsForBeforeUnloadTest(WebContents* web_contents) { |
| 475 for (auto* frame : web_contents->GetAllFrames()) { |
| 476 // JavaScript onbeforeunload dialogs are ignored unless the frame received a |
| 477 // user gesture. Make sure the frames have user gestures. |
| 478 frame->ExecuteJavaScriptWithUserGestureForTests(base::string16()); |
| 479 |
| 480 // Disable the hang monitor, otherwise there will be a race between the |
| 481 // beforeunload dialog and the beforeunload hang timer. |
| 482 frame->DisableBeforeUnloadHangMonitorForTesting(); |
| 483 } |
| 484 } |
| 485 |
474 bool IsLastCommittedEntryOfPageType(WebContents* web_contents, | 486 bool IsLastCommittedEntryOfPageType(WebContents* web_contents, |
475 content::PageType page_type) { | 487 content::PageType page_type) { |
476 NavigationEntry* last_entry = | 488 NavigationEntry* last_entry = |
477 web_contents->GetController().GetLastCommittedEntry(); | 489 web_contents->GetController().GetLastCommittedEntry(); |
478 if (!last_entry) | 490 if (!last_entry) |
479 return false; | 491 return false; |
480 return last_entry->GetPageType() == page_type; | 492 return last_entry->GetPageType() == page_type; |
481 } | 493 } |
482 | 494 |
483 void CrashTab(WebContents* web_contents) { | 495 void CrashTab(WebContents* web_contents) { |
(...skipping 1553 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2037 bool user_gesture, | 2049 bool user_gesture, |
2038 bool last_unlocked_by_target, | 2050 bool last_unlocked_by_target, |
2039 bool privileged) { | 2051 bool privileged) { |
2040 IPC::IpcSecurityTestUtil::PwnMessageReceived( | 2052 IPC::IpcSecurityTestUtil::PwnMessageReceived( |
2041 process->GetChannel(), | 2053 process->GetChannel(), |
2042 ViewHostMsg_LockMouse(routing_id, user_gesture, last_unlocked_by_target, | 2054 ViewHostMsg_LockMouse(routing_id, user_gesture, last_unlocked_by_target, |
2043 privileged)); | 2055 privileged)); |
2044 } | 2056 } |
2045 | 2057 |
2046 } // namespace content | 2058 } // namespace content |
OLD | NEW |