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

Side by Side Diff: content/browser/frame_host/navigation_controller_impl_browsertest.cc

Issue 2165783003: Grant permission to the base url when loadDataWithBaseURL is called. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add test Created 4 years, 4 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
« no previous file with comments | « no previous file | content/browser/frame_host/render_frame_host_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "content/browser/frame_host/navigation_controller_impl.h" 5 #include "content/browser/frame_host/navigation_controller_impl.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 EXPECT_EQ(base_url, back_entry->GetBaseURLForDataURL()); 188 EXPECT_EQ(base_url, back_entry->GetBaseURLForDataURL());
189 EXPECT_EQ(history_url, back_entry->GetVirtualURL()); 189 EXPECT_EQ(history_url, back_entry->GetVirtualURL());
190 EXPECT_EQ(history_url, back_entry->GetHistoryURLForDataURL()); 190 EXPECT_EQ(history_url, back_entry->GetHistoryURLForDataURL());
191 EXPECT_EQ(data_url1, back_entry->GetOriginalRequestURL()); 191 EXPECT_EQ(data_url1, back_entry->GetOriginalRequestURL());
192 EXPECT_EQ(data_url1, back_entry->GetURL()); 192 EXPECT_EQ(data_url1, back_entry->GetURL());
193 193
194 EXPECT_EQ(data_url1, 194 EXPECT_EQ(data_url1,
195 shell()->web_contents()->GetMainFrame()->GetLastCommittedURL()); 195 shell()->web_contents()->GetMainFrame()->GetLastCommittedURL());
196 } 196 }
197 197
198 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
199 CrossDomainResourceRequestLoadDataWithBaseUrl) {
200 const GURL base_url("foobar://");
201 const GURL history_url("http://historyurl");
202 const std::string data = "<html><body></body></html>";
203 const GURL data_url = GURL("data:text/html;charset=utf-8," + data);
204
205 const NavigationControllerImpl& controller =
206 static_cast<const NavigationControllerImpl&>(
207 shell()->web_contents()->GetController());
208
209 // Load data and commit.
210 {
211 TestNavigationObserver same_tab_observer(shell()->web_contents(), 1);
212 shell()->LoadDataWithBaseURL(history_url, data, base_url);
213 same_tab_observer.Wait();
214 EXPECT_EQ(1, controller.GetEntryCount());
215 NavigationEntryImpl* entry = controller.GetLastCommittedEntry();
216 EXPECT_EQ(base_url, entry->GetBaseURLForDataURL());
217 EXPECT_EQ(history_url, entry->GetVirtualURL());
218 EXPECT_EQ(history_url, entry->GetHistoryURLForDataURL());
219 EXPECT_EQ(data_url, entry->GetURL());
220 }
221
222 // Now make an XHR request and check that the renderer isn't killed.
223 std::string script =
224 "var url = 'http://www.example.com';\n"
225 "var xhr = new XMLHttpRequest();\n"
226 "xhr.open('GET', url);\n"
227 "xhr.send();\n";
228 EXPECT_TRUE(ExecuteScript(shell()->web_contents(), script));
229 // The renderer may not be killed immediately (if it is indeed killed), so
230 // reload, block and verify its liveness.
231 ReloadBlockUntilNavigationsComplete(shell(), 1);
Charlie Reis 2016/07/26 17:57:13 I'm a bit surprised this fails without the fix, bu
232 EXPECT_TRUE(shell()->web_contents()->GetMainFrame()->IsRenderFrameLive());
233 }
234
198 #if defined(OS_ANDROID) 235 #if defined(OS_ANDROID)
199 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, 236 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest,
200 LoadDataWithInvalidBaseURL) { 237 LoadDataWithInvalidBaseURL) {
201 const GURL base_url("http://"); // Invalid. 238 const GURL base_url("http://"); // Invalid.
202 const GURL history_url("http://historyurl"); 239 const GURL history_url("http://historyurl");
203 const std::string title = "invalid_base_url"; 240 const std::string title = "invalid_base_url";
204 const std::string data = base::StringPrintf( 241 const std::string data = base::StringPrintf(
205 "<html><head><title>%s</title></head><body>foo</body></html>", 242 "<html><head><title>%s</title></head><body>foo</body></html>",
206 title.c_str()); 243 title.c_str());
207 const GURL data_url = GURL("data:text/html;charset=utf-8," + data); 244 const GURL data_url = GURL("data:text/html;charset=utf-8," + data);
(...skipping 5121 matching lines...) Expand 10 before | Expand all | Expand 10 after
5329 std::string body; 5366 std::string body;
5330 EXPECT_TRUE(ExecuteScriptAndExtractString( 5367 EXPECT_TRUE(ExecuteScriptAndExtractString(
5331 shell()->web_contents(), 5368 shell()->web_contents(),
5332 "window.domAutomationController.send(" 5369 "window.domAutomationController.send("
5333 "document.getElementsByTagName('pre')[0].innerText);", 5370 "document.getElementsByTagName('pre')[0].innerText);",
5334 &body)); 5371 &body));
5335 EXPECT_EQ("text=value\n", body); 5372 EXPECT_EQ("text=value\n", body);
5336 } 5373 }
5337 5374
5338 } // namespace content 5375 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/browser/frame_host/render_frame_host_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698