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

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

Issue 1411073005: Migrating tests to use EmbeddedTestServer (/content) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 5 years, 1 month 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/strings/stringprintf.h" 6 #include "base/strings/stringprintf.h"
7 #include "content/public/browser/web_contents.h" 7 #include "content/public/browser/web_contents.h"
8 #include "content/public/browser/web_contents_delegate.h" 8 #include "content/public/browser/web_contents_delegate.h"
9 #include "content/public/test/browser_test_utils.h" 9 #include "content/public/test/browser_test_utils.h"
10 #include "content/public/test/content_browser_test.h" 10 #include "content/public/test/content_browser_test.h"
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 shell->web_contents(), 75 shell->web_contents(),
76 base::StringPrintf("window.open('%s')", url.spec().c_str()))); 76 base::StringPrintf("window.open('%s')", url.spec().c_str())));
77 nav_observer.Wait(); 77 nav_observer.Wait();
78 return new_shell_observer.GetShell(); 78 return new_shell_observer.GetShell();
79 } 79 }
80 }; 80 };
81 81
82 // 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
83 // a few times. 83 // a few times.
84 IN_PROC_BROWSER_TEST_F(OpenedByDOMTest, NormalWindow) { 84 IN_PROC_BROWSER_TEST_F(OpenedByDOMTest, NormalWindow) {
85 ASSERT_TRUE(test_server()->Start()); 85 ASSERT_TRUE(embedded_test_server()->Start());
86 86
87 // window.close is allowed if the window was opened by DOM OR the back/forward 87 // window.close is allowed if the window was opened by DOM OR the back/forward
88 // list has only one element. Navigate a bit so the second condition is false. 88 // list has only one element. Navigate a bit so the second condition is false.
89 GURL url1 = test_server()->GetURL("files/site_isolation/blank.html?1"); 89 GURL url1 = embedded_test_server()->GetURL("/site_isolation/blank.html?1");
90 GURL url2 = test_server()->GetURL("files/site_isolation/blank.html?2"); 90 GURL url2 = embedded_test_server()->GetURL("/site_isolation/blank.html?2");
91 NavigateToURL(shell(), url1); 91 NavigateToURL(shell(), url1);
92 NavigateToURL(shell(), url2); 92 NavigateToURL(shell(), url2);
93 93
94 // This window was not opened by DOM, so close does not reach the browser 94 // This window was not opened by DOM, so close does not reach the browser
95 // process. 95 // process.
96 EXPECT_FALSE(AttemptCloseFromJavaScript(shell()->web_contents())); 96 EXPECT_FALSE(AttemptCloseFromJavaScript(shell()->web_contents()));
97 } 97 }
98 98
99 // Tests that window.close() works in a popup window that has navigated a few 99 // Tests that window.close() works in a popup window that has navigated a few
100 // times. 100 // times.
101 IN_PROC_BROWSER_TEST_F(OpenedByDOMTest, Popup) { 101 IN_PROC_BROWSER_TEST_F(OpenedByDOMTest, Popup) {
102 ASSERT_TRUE(test_server()->Start()); 102 ASSERT_TRUE(embedded_test_server()->Start());
103 103
104 GURL url1 = test_server()->GetURL("files/site_isolation/blank.html?1"); 104 GURL url1 = embedded_test_server()->GetURL("/site_isolation/blank.html?1");
105 GURL url2 = test_server()->GetURL("files/site_isolation/blank.html?2"); 105 GURL url2 = embedded_test_server()->GetURL("/site_isolation/blank.html?2");
106 GURL url3 = test_server()->GetURL("files/site_isolation/blank.html?3"); 106 GURL url3 = embedded_test_server()->GetURL("/site_isolation/blank.html?3");
107 NavigateToURL(shell(), url1); 107 NavigateToURL(shell(), url1);
108 108
109 Shell* popup = OpenWindowFromJavaScript(shell(), url2); 109 Shell* popup = OpenWindowFromJavaScript(shell(), url2);
110 NavigateToURL(popup, url3); 110 NavigateToURL(popup, url3);
111 EXPECT_TRUE(AttemptCloseFromJavaScript(popup->web_contents())); 111 EXPECT_TRUE(AttemptCloseFromJavaScript(popup->web_contents()));
112 } 112 }
113 113
114 // Tests that window.close() works in a popup window that has navigated a few 114 // Tests that window.close() works in a popup window that has navigated a few
115 // times and swapped processes. 115 // times and swapped processes.
116 IN_PROC_BROWSER_TEST_F(OpenedByDOMTest, CrossProcessPopup) { 116 IN_PROC_BROWSER_TEST_F(OpenedByDOMTest, CrossProcessPopup) {
117 host_resolver()->AddRule("*", "127.0.0.1"); 117 host_resolver()->AddRule("*", "127.0.0.1");
118 ASSERT_TRUE(test_server()->Start()); 118 ASSERT_TRUE(embedded_test_server()->Start());
119 119
120 GURL url1 = test_server()->GetURL("files/site_isolation/blank.html?1"); 120 GURL url1 = embedded_test_server()->GetURL("/site_isolation/blank.html?1");
121 121
122 GURL url2 = test_server()->GetURL("files/site_isolation/blank.html?2"); 122 GURL url2 = embedded_test_server()->GetURL("/site_isolation/blank.html?2");
123 GURL::Replacements replace_host; 123 GURL::Replacements replace_host;
124 replace_host.SetHostStr("foo.com"); 124 replace_host.SetHostStr("foo.com");
125 url2 = url2.ReplaceComponents(replace_host); 125 url2 = url2.ReplaceComponents(replace_host);
126 126
127 GURL url3 = test_server()->GetURL("files/site_isolation/blank.html?3"); 127 GURL url3 = embedded_test_server()->GetURL("/site_isolation/blank.html?3");
128 url3 = url3.ReplaceComponents(replace_host); 128 url3 = url3.ReplaceComponents(replace_host);
129 129
130 NavigateToURL(shell(), url1); 130 NavigateToURL(shell(), url1);
131 131
132 Shell* popup = OpenWindowFromJavaScript(shell(), url2); 132 Shell* popup = OpenWindowFromJavaScript(shell(), url2);
133 NavigateToURL(popup, url3); 133 NavigateToURL(popup, url3);
134 EXPECT_TRUE(AttemptCloseFromJavaScript(popup->web_contents())); 134 EXPECT_TRUE(AttemptCloseFromJavaScript(popup->web_contents()));
135 } 135 }
136 136
137 } // namespace content 137 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/site_per_process_browsertest.cc ('k') | content/browser/web_contents/web_contents_impl_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698