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

Unified Diff: content/browser/frame_host/render_frame_message_filter_browsertest.cc

Issue 1714013002: Load cookies once per 'document.cookie' read (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@reallyonce
Patch Set: FILE_PATH_LITERAL Created 4 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/frame_host/render_frame_message_filter.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/frame_host/render_frame_message_filter_browsertest.cc
diff --git a/content/browser/frame_host/render_frame_message_filter_browsertest.cc b/content/browser/frame_host/render_frame_message_filter_browsertest.cc
index 3362e96081c27f68e53255ac69a4314bb5a76828..adf9516281cb908de49d48f05793ce6aab287c61 100644
--- a/content/browser/frame_host/render_frame_message_filter_browsertest.cc
+++ b/content/browser/frame_host/render_frame_message_filter_browsertest.cc
@@ -24,6 +24,7 @@
#include "net/test/embedded_test_server/embedded_test_server.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
+#include "url/gurl.h"
namespace content {
@@ -48,7 +49,8 @@ IN_PROC_BROWSER_TEST_F(RenderFrameMessageFilterBrowserTest, Cookies) {
SetupCrossSiteRedirector(embedded_test_server());
net::EmbeddedTestServer https_server(net::EmbeddedTestServer::TYPE_HTTPS);
- https_server.ServeFilesFromSourceDirectory("content/test/data");
+ https_server.AddDefaultHandlers(
+ base::FilePath(FILE_PATH_LITERAL("content/test/data")));
ASSERT_TRUE(https_server.Start());
// The server sends a HttpOnly cookie. The RenderFrameMessageFilter should
@@ -102,6 +104,26 @@ IN_PROC_BROWSER_TEST_F(RenderFrameMessageFilterBrowserTest, Cookies) {
EXPECT_EQ("B=2; D=4", GetCookieFromJS(web_contents_http->GetMainFrame()));
}
+// SameSite cookies (that aren't marked as http-only) should be available to
+// JavaScript.
+IN_PROC_BROWSER_TEST_F(RenderFrameMessageFilterBrowserTest, SameSiteCookies) {
+ host_resolver()->AddRule("*", "127.0.0.1");
+ ASSERT_TRUE(embedded_test_server()->Start());
+ SetupCrossSiteRedirector(embedded_test_server());
+
+ // The server sends a SameSite cookie. The RenderFrameMessageFilter should
+ // allow this to be sent to the renderer.
+ GURL url = embedded_test_server()->GetURL("/set-cookie?samesite=1;SameSite");
+ NavigateToURL(shell(), url);
+
+ WebContentsImpl* web_contents =
+ static_cast<WebContentsImpl*>(shell()->web_contents());
+ EXPECT_EQ("http://127.0.0.1/",
+ web_contents->GetSiteInstance()->GetSiteURL().spec());
+
+ EXPECT_EQ("samesite=1", GetCookieFromJS(web_contents->GetMainFrame()));
+}
+
// The RenderFrameMessageFilter will kill processes when they access the cookies
// of sites other than the site the process is dedicated to, under site
// isolation.
« no previous file with comments | « content/browser/frame_host/render_frame_message_filter.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698