| Index: content/public/test/browser_test_utils.cc
|
| diff --git a/content/public/test/browser_test_utils.cc b/content/public/test/browser_test_utils.cc
|
| index 052ffca5772fabc52cc6e6cfd336c9c52f51db39..b9a3011b3e9321b4dd11c57cc67f7c085808a229 100644
|
| --- a/content/public/test/browser_test_utils.cc
|
| +++ b/content/public/test/browser_test_utils.cc
|
| @@ -471,6 +471,18 @@ bool WaitForLoadStop(WebContents* web_contents) {
|
| return IsLastCommittedEntryOfPageType(web_contents, PAGE_TYPE_NORMAL);
|
| }
|
|
|
| +void PrepContentsForBeforeUnloadTest(WebContents* web_contents) {
|
| + for (auto* frame : web_contents->GetAllFrames()) {
|
| + // JavaScript onbeforeunload dialogs are ignored unless the frame received a
|
| + // user gesture. Make sure the frames have user gestures.
|
| + frame->ExecuteJavaScriptWithUserGestureForTests(base::string16());
|
| +
|
| + // Disable the hang monitor, otherwise there will be a race between the
|
| + // beforeunload dialog and the beforeunload hang timer.
|
| + frame->DisableBeforeUnloadHangMonitorForTesting();
|
| + }
|
| +}
|
| +
|
| bool IsLastCommittedEntryOfPageType(WebContents* web_contents,
|
| content::PageType page_type) {
|
| NavigationEntry* last_entry =
|
|
|