Commit c87a2d5e authored by Pavel Feldman's avatar Pavel Feldman Committed by Commit Bot

DevTools: follow up to Storage.setCookies, fix browser endpoint.

Change-Id: I18672227a10a1988ce252a8fbf528684c317714d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1931267Reviewed-by: default avatarAndrey Kosyakov <caseq@chromium.org>
Commit-Queue: Pavel Feldman <pfeldman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#718280}
parent 03a07739
......@@ -518,7 +518,7 @@ Response StorageHandler::FindStoragePartition(
return response;
*storage_partition =
BrowserContext::GetDefaultStoragePartition(browser_context);
if (!storage_partition_)
if (!*storage_partition)
return Response::InternalError();
return Response::OK();
}
......
Tests that cookies are read and written.
Running test: testPageContext
Initial: 0 cookies
Cookies as seen on server: "HTTP_COOKIE: <not set>\n"
......@@ -16,3 +18,13 @@ Cookies as seen on server: "HTTP_COOKIE: name=value; foo=second bar2; foo2=bar1\
Post-clear: 0 cookies
Cookies as seen on server: "HTTP_COOKIE: <not set>\n"
Running test: testInvalidContext
{
error : {
code : -32602
message : Failed to find browser context for id invalid
}
id : <number>
sessionId : <string>
}
(async function(testRunner) {
const {dp} = await testRunner.startBlank(
const {dp, page} = await testRunner.startBlank(
`Tests that cookies are read and written.`);
async function logCookies(title) {
var data = (await dp.Storage.getCookies()).result;
async function logCookies(title, browserContextId) {
var data = (await dp.Storage.getCookies({ browserContextId })).result;
testRunner.log(`\n${title}: ${data.cookies.length} cookies`);
data.cookies.sort((a, b) => a.name.localeCompare(b.name));
for (var cookie of data.cookies) {
......@@ -40,21 +40,29 @@
}
await logCookies('Initial');
testRunner.runTestSuite([
async function testPageContext() {
await logCookies('Initial');
await setCookieViaFetch();
await logCookies('Post-fetch');
await setCookieViaFetch();
await logCookies('Post-fetch');
const cookies = [
{url: 'http://127.0.0.1', name: 'foo', value: 'bar1'},
{url: 'http://127.0.0.1', name: 'foo', value: 'second bar2'},
{url: 'http://127.0.0.1', name: 'foo2', value: 'bar1'}
];
await dp.Storage.setCookies({cookies});
await logCookies('Post-set');
const cookies = [
{url: 'http://127.0.0.1', name: 'foo', value: 'bar1'},
{url: 'http://127.0.0.1', name: 'foo', value: 'second bar2'},
{url: 'http://127.0.0.1', name: 'foo2', value: 'bar1'}
];
await dp.Storage.setCookies({cookies});
await logCookies('Post-set');
await dp.Storage.clearCookies();
await logCookies('Post-clear');
await dp.Storage.clearCookies();
await logCookies('Post-clear');
},
async function testInvalidContext() {
var data = (await dp.Storage.getCookies({ browserContextId: 'invalid' }));
testRunner.log(data);
}
]);
testRunner.completeTest();
})
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