Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(109)

Side by Side Diff: content/browser/web_contents/opened_by_dom_browsertest.cc

Issue 2052633002: Extend the ToRenderFrameHost magic to FrameTreeNode* and Shell* (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix induced script bug. Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "base/command_line.h" 5 #include "base/command_line.h"
6 #include "base/macros.h" 6 #include "base/macros.h"
7 #include "base/strings/stringprintf.h" 7 #include "base/strings/stringprintf.h"
8 #include "content/public/browser/web_contents.h" 8 #include "content/public/browser/web_contents.h"
9 #include "content/public/browser/web_contents_delegate.h" 9 #include "content/public/browser/web_contents_delegate.h"
10 #include "content/public/test/browser_test_utils.h" 10 #include "content/public/test/browser_test_utils.h"
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 web_contents->SetDelegate(old_delegate); 66 web_contents->SetDelegate(old_delegate);
67 return close_tracking_delegate.close_contents_called(); 67 return close_tracking_delegate.close_contents_called();
68 } 68 }
69 69
70 Shell* OpenWindowFromJavaScript(Shell* shell, const GURL& url) { 70 Shell* OpenWindowFromJavaScript(Shell* shell, const GURL& url) {
71 // Wait for the popup to be created and for it to have navigated. 71 // Wait for the popup to be created and for it to have navigated.
72 ShellAddedObserver new_shell_observer; 72 ShellAddedObserver new_shell_observer;
73 TestNavigationObserver nav_observer(NULL); 73 TestNavigationObserver nav_observer(NULL);
74 nav_observer.StartWatchingNewWebContents(); 74 nav_observer.StartWatchingNewWebContents();
75 CHECK(ExecuteScript( 75 CHECK(ExecuteScript(
76 shell->web_contents(), 76 shell, base::StringPrintf("window.open('%s')", url.spec().c_str())));
77 base::StringPrintf("window.open('%s')", url.spec().c_str())));
78 nav_observer.Wait(); 77 nav_observer.Wait();
79 return new_shell_observer.GetShell(); 78 return new_shell_observer.GetShell();
80 } 79 }
81 }; 80 };
82 81
83 // Tests that window.close() does not work on a normal window that has navigated 82 // Tests that window.close() does not work on a normal window that has navigated
84 // a few times. 83 // a few times.
85 IN_PROC_BROWSER_TEST_F(OpenedByDOMTest, NormalWindow) { 84 IN_PROC_BROWSER_TEST_F(OpenedByDOMTest, NormalWindow) {
86 ASSERT_TRUE(embedded_test_server()->Start()); 85 ASSERT_TRUE(embedded_test_server()->Start());
87 86
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 url3 = url3.ReplaceComponents(replace_host); 128 url3 = url3.ReplaceComponents(replace_host);
130 129
131 NavigateToURL(shell(), url1); 130 NavigateToURL(shell(), url1);
132 131
133 Shell* popup = OpenWindowFromJavaScript(shell(), url2); 132 Shell* popup = OpenWindowFromJavaScript(shell(), url2);
134 NavigateToURL(popup, url3); 133 NavigateToURL(popup, url3);
135 EXPECT_TRUE(AttemptCloseFromJavaScript(popup->web_contents())); 134 EXPECT_TRUE(AttemptCloseFromJavaScript(popup->web_contents()));
136 } 135 }
137 136
138 } // namespace content 137 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698