Commit 0ec2e7a2 authored by Maks Orlovich's avatar Maks Orlovich Committed by Commit Bot

Fix ExtensionApiTest.Cookies with upcoming cookie semantics changes

We are going to be asking cookies accessible in 3rd party contexts to be
secure.

Bug: 1006816
Change-Id: Ibdbd145e52b5ee03acbe730ffd1814c9236c71bb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1863634
Commit-Queue: Maksim Orlovich <morlovich@chromium.org>
Reviewed-by: default avatarDevlin <rdevlin.cronin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#709499}
parent 8050ba4e
......@@ -5,11 +5,17 @@
#include "base/command_line.h"
#include "chrome/browser/extensions/extension_apitest.h"
#include "chrome/test/base/ui_test_utils.h"
#include "net/cookies/cookie_util.h"
namespace extensions {
IN_PROC_BROWSER_TEST_F(ExtensionApiTest, Cookies) {
ASSERT_TRUE(RunExtensionTest("cookies/api")) << message_;
ASSERT_TRUE(RunExtensionTestWithArg(
"cookies/api",
net::cookie_util::IsCookiesWithoutSameSiteMustBeSecureEnabled()
? "true"
: "false"))
<< message_;
}
IN_PROC_BROWSER_TEST_F(ExtensionApiTest, CookiesEvents) {
......
......@@ -6,6 +6,7 @@ var TEST_DOMAIN = 'cookies.com';
var TEST_PATH = '/auth';
var TEST_HOST = 'www.chrome_extensions.' + TEST_DOMAIN;
var TEST_URL = 'http://' + TEST_HOST + '/foobar.html?arg=toolbar&param=true';
var TEST_URL_HTTPS = 'https://' + TEST_HOST + '/foobar.html?arg=toolbar&param=true';
var TEST_URL2 = 'http://chromium.' + TEST_DOMAIN + '/index.html';
var TEST_URL3 = 'https://' + TEST_HOST + '/content.html';
var TEST_URL4 = 'https://' + TEST_HOST + TEST_PATH + '/content.html';
......@@ -79,7 +80,8 @@ function removeTestCookies() {
{url: TEST_URL4, name: TEST_SECURE_COOKIE.name});
chrome.cookies.remove({url: TEST_URL, name: 'abcd'});
chrome.cookies.remove({url: TEST_URL, name: 'AA'});
chrome.cookies.remove({url: TEST_URL, name: 'A'});
chrome.cookies.remove({url: TEST_URL_HTTPS, name: 'A'});
chrome.cookies.remove({url: TEST_URL, name: 'AI'});
chrome.cookies.remove({url: TEST_URL, name: 'B'});
chrome.cookies.remove({url: TEST_URL, name: 'C'});
chrome.cookies.remove({url: TEST_URL, name: 'D'});
......@@ -261,9 +263,10 @@ chrome.test.runTests([
// No same-site restriction
chrome.cookies.set(
{url: TEST_URL, name: "A", value: "1", sameSite: "no_restriction"},
{url: TEST_URL_HTTPS, name: "A", value: "1", sameSite: "no_restriction",
secure: true},
pass(function () {
chrome.cookies.get({url: TEST_URL, name: "A"}, pass(function (c) {
chrome.cookies.get({url: TEST_URL_HTTPS, name: "A"}, pass(function (c) {
expectValidCookie(c);
chrome.test.assertEq("no_restriction", c.sameSite);
}));
......@@ -299,6 +302,34 @@ chrome.test.runTests([
}));
}));
},
function setSameSiteCookiesInsecureNone() {
chrome.test.getConfig(config => {
// No same-site restriction but also not secure. This should succeed if
// and only if the feature requiring SameSite=none cookies to be secure
// cookies is disabled.
var sameSiteNoneRequiresSecure = config.customArg === 'true';
removeTestCookies();
chrome.cookies.set(
{url: TEST_URL, name: "AI", value: "1", sameSite: "no_restriction"},
setResult => {
if (sameSiteNoneRequiresSecure) {
chrome.test.assertLastError(
'Failed to parse or set cookie named "AI".');
chrome.test.assertEq(null, setResult);
chrome.test.succeed();
} else {
chrome.test.assertNoLastError();
chrome.cookies.get(
{url: TEST_URL_HTTPS, name: "AI"},
pass(function (c) {
expectValidCookie(c);
chrome.test.assertEq("no_restriction", c.sameSite);
}));
}
});
});
},
function setCookiesWithCallbacks() {
removeTestCookies();
// Basics.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment