Skip to content
Permalink
Browse files
2010-10-19 Andrey Kosyakov <caseq@chromium.org>
        Reviewed by Pavel Feldman.

        Web Inspector: expose request/response cookies in HAR
        https://bugs.webkit.org/show_bug.cgi?id=47894

        Test: inspector/cookie-parser.html

        * WebCore.gypi:
        * WebCore.vcproj/WebCore.vcproj:
        * inspector/front-end/CookieParser.js: Added.
        * inspector/front-end/HAREntry.js:
        (WebInspector.HAREntry.prototype._buildRequest):
        (WebInspector.HAREntry.prototype._buildResponse):
        (WebInspector.HAREntry.prototype._buildCookies):
        (WebInspector.HAREntry.prototype._buildCookie):
        * inspector/front-end/Resource.js: Parse Cookie/Set-Cookie headers and expose cookies.
        (WebInspector.Resource.prototype.set requestHeaders):
        (WebInspector.Resource.prototype.get requestCookies):
        (WebInspector.Resource.prototype.set responseHeaders):
        (WebInspector.Resource.prototype.get responseCookies):
        (WebInspector.Resource.prototype._parseRequestCookies):
        (WebInspector.Resource.prototype._parseResponseCookies):
        * inspector/front-end/WebKit.qrc:
        * inspector/front-end/inspector.html:

2010-10-19  Andrey Kosyakov  <caseq@chromium.org>

        Reviewed by Pavel Feldman.

        Web Inspector: expose request/response cookies in HAR
        https://bugs.webkit.org/show_bug.cgi?id=47894

        * src/WebResourceRawHeaders.cpp:
        (WebKit::addHeader): paste coalescent headers using "\n: as a separator instead of ", "

2010-10-19  Andrey Kosyakov  <caseq@chromium.org>

        Reviewed by Pavel Feldman.

        Web Inspector: expose request/response cookies in HAR
        https://bugs.webkit.org/show_bug.cgi?id=47894

        * http/tests/inspector/inspector-test.js:
        (dumpObject): Handle null objects as a special case (display null instead of empty object)
        * http/tests/inspector/inspector-test2.js:
        (initialize_InspectorTest.InspectorTest.addObject): Ditto.
        * http/tests/inspector/resource-har-conversion-expected.txt:
        * http/tests/inspector/resource-har-conversion.html:
        * inspector/cookie-parser-expected.txt: Added.
        * inspector/cookie-parser.html: Added.


Canonical link: https://commits.webkit.org/60693@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@70137 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
caseq committed Oct 20, 2010
1 parent 415f0e1 commit 50e809048d26dc3c7b0317c8166171f07761a58d
Showing 17 changed files with 595 additions and 4 deletions.
@@ -1,3 +1,19 @@
2010-10-19 Andrey Kosyakov <caseq@chromium.org>

Reviewed by Pavel Feldman.

Web Inspector: expose request/response cookies in HAR
https://bugs.webkit.org/show_bug.cgi?id=47894

* http/tests/inspector/inspector-test.js:
(dumpObject): Handle null objects as a special case (display null instead of empty object)
* http/tests/inspector/inspector-test2.js:
(initialize_InspectorTest.InspectorTest.addObject): Ditto.
* http/tests/inspector/resource-har-conversion-expected.txt:
* http/tests/inspector/resource-har-conversion.html:
* inspector/cookie-parser-expected.txt: Added.
* inspector/cookie-parser.html: Added.

2010-10-20 Shinichiro Hamaji <hamaji@chromium.org>

Reviewed by Kent Tamura.
@@ -53,6 +53,8 @@ function dumpObject(object, nondeterministicProps, prefix, firstLinePrefix)
var propValue = object[prop];
if (nondeterministicProps && prop in nondeterministicProps)
output(prefixWithName + "<" + typeof propValue + ">");
else if (propValue === null)
output(prefixWithName + "null");
else if (typeof propValue === "object")
dumpObject(propValue, nondeterministicProps, prefix + " ", prefixWithName);
else if (typeof propValue === "string")
@@ -61,6 +61,8 @@ InspectorTest.addObject = function(object, nondeterministicProps, prefix, firstL
var propValue = object[prop];
if (nondeterministicProps && prop in nondeterministicProps)
InspectorTest.addResult(prefixWithName + "<" + typeof propValue + ">");
else if (propValue === null)
InspectorTest.addResult(prefixWithName + "null");
else if (typeof propValue === "object")
InspectorTest.addObject(propValue, nondeterministicProps, prefix + " ", prefixWithName);
else if (typeof propValue === "string")
@@ -12,6 +12,35 @@ Page reloaded.
headers : <object>
headersSize : -1
bodySize : <number>
cookies : {
0 : {
name : "a"
value : "b"
path : "/path"
domain : "example.com"
expires : null
httpOnly : false
secure : false
}
1 : {
name : "a1"
value : "b1"
path : undefined
domain : undefined
expires : null
httpOnly : false
secure : false
}
2 : {
name : "c1"
value : "d1"
path : undefined
domain : undefined
expires : null
httpOnly : false
secure : false
}
}
}
response : {
status : 304
@@ -24,6 +53,35 @@ Page reloaded.
redirectURL : ""
headersSize : -1
bodySize : <number>
cookies : {
0 : {
name : "x"
value : "y"
path : "/path"
domain : "example.com"
expires : null
httpOnly : true
secure : true
}
1 : {
name : "x1"
value : "y1"
path : undefined
domain : undefined
expires : null
httpOnly : false
secure : false
}
2 : {
name : "z2"
value : "y2"
path : undefined
domain : undefined
expires : null
httpOnly : false
secure : false
}
}
}
timings : <object>
}
@@ -12,8 +12,27 @@
return new WebInspector.HAREntry(WebInspector.resources[id]).build();
}

function addCookieHeadersToResource(resource)
{
resource.requestHeaders = {
"Cookie": "a=b; $Path=/path; $Domain=example.com; a1=b1\nc1=d1"
};
resource.responseHeaders = {
"Set-Cookie": "x=y; Path=/path; Domain=example.com; Discard; httpOnly; Secure; Version=1\nx1=y1\nz2=y2"
};
}

function findResourceByURL(url)
{
for (var resource in WebInspector.resources) {
if (url.test(WebInspector.resources[resource].url))
return WebInspector.resources[resource];
}
}

InspectorTest.enableResourceTracking(function() {
InjectedScriptAccess.getDefault().evaluate("doXHR()", "console", function() {
addCookieHeadersToResource(findResourceByURL(/inspector-test2\.js$/));
var resources = Object.keys(WebInspector.resources).map(getHAR).sort(InspectorTest.resourceURLComparer);
InspectorTest.addObject(resources, InspectorTest.HARNondeterministicPropertiesWithSize);
InspectorTest.disableResourceTracking();
@@ -0,0 +1,133 @@
Tests inspector cookie parser

source: cookie=value
name: cookie, value: value, httpOnly: false, secure: false, session: true, path: undefined, domain: undefined, port: undefined, expires: n/a, size: 12
{
}
source: $version=1; a=b,c = d, e=f
name: a, value: b,c = d, e=f, httpOnly: false, secure: false, session: true, path: undefined, domain: undefined, port: undefined, expires: n/a, size: 17
{
}
source: $version=1; a=b;c = d; e =f
name: a, value: b, httpOnly: false, secure: false, session: true, path: undefined, domain: undefined, port: undefined, expires: n/a, size: 4
{
}
name: c, value: d, httpOnly: false, secure: false, session: true, path: undefined, domain: undefined, port: undefined, expires: n/a, size: 10
{
}
name: e, value: f, httpOnly: false, secure: false, session: true, path: undefined, domain: undefined, port: undefined, expires: n/a, size: 4
{
}
source: cooke1 = value1; another cookie = another value
name: cooke1, value: value1, httpOnly: false, secure: false, session: true, path: undefined, domain: undefined, port: undefined, expires: n/a, size: 25
{
}
name: cookie, value: another value, httpOnly: false, secure: false, session: true, path: undefined, domain: undefined, port: undefined, expires: n/a, size: 22
{
}
source: cooke1 = value; $Path=/; $Domain=.example.com;
name: cooke1, value: value, httpOnly: false, secure: false, session: true, path: /, domain: .example.com, port: undefined, expires: n/a, size: 46
{
path : "/"
domain : ".example.com"
}
source: cooke1 = value; $Path=/; $Domain=.example.com ; Cookie2 = value2; $Path = /foo; $DOMAIN = foo.example.com;
name: cooke1, value: value, httpOnly: false, secure: false, session: true, path: /, domain: .example.com, port: undefined, expires: n/a, size: 48
{
path : "/"
domain : ".example.com"
}
name: Cookie2, value: value2, httpOnly: false, secure: false, session: true, path: /foo, domain: foo.example.com, port: undefined, expires: n/a, size: 58
{
path : "/foo"
domain : "foo.example.com"
}
source: cooke1 = value; $Path=/; $Domain=.example.com
Cookie2 = value2; $Path = /foo; $DOMAIN = foo.example.com;
name: cooke1, value: value, httpOnly: false, secure: false, session: true, path: /, domain: .example.com, port: undefined, expires: n/a, size: 46
{
path : "/"
domain : ".example.com"
}
name: Cookie2, value: value2, httpOnly: false, secure: false, session: true, path: /foo, domain: foo.example.com, port: undefined, expires: n/a, size: 59
{
path : "/foo"
domain : "foo.example.com"
}
source: $version =1; cooke1 = value; $Path=/; $Domain =.example.com;
Cookie2 = value2; $Path = /foo; $DOMAIN = foo.example.com;
name: cooke1, value: value, httpOnly: false, secure: false, session: true, path: /, domain: .example.com, port: undefined, expires: n/a, size: 53
{
path : "/"
domain : ".example.com"
}
name: Cookie2, value: value2, httpOnly: false, secure: false, session: true, path: /foo, domain: foo.example.com, port: undefined, expires: n/a, size: 58
{
path : "/foo"
domain : "foo.example.com"
}
source: cookie=value
name: cookie, value: value, httpOnly: false, secure: false, session: true, path: undefined, domain: undefined, port: undefined, expires: n/a, size: 12
{
}
source: a=b
c=d
f
name: a, value: b, httpOnly: false, secure: false, session: true, path: undefined, domain: undefined, port: undefined, expires: n/a, size: 5
{
}
name: c, value: d, httpOnly: false, secure: false, session: true, path: undefined, domain: undefined, port: undefined, expires: n/a, size: 5
{
}
name: , value: f, httpOnly: false, secure: false, session: true, path: undefined, domain: undefined, port: undefined, expires: n/a, size: 1
{
}
source: cooke1 = value; Path=/; Domain=.example.com;
name: cooke1, value: value, httpOnly: false, secure: false, session: true, path: /, domain: .example.com, port: undefined, expires: n/a, size: 44
{
path : "/"
domain : ".example.com"
}
source: cooke1 = value; Path=/; Domain= .example.com
Cookie2 = value2; Path = /foo; Domain = foo.example.com
name: cooke1, value: value, httpOnly: false, secure: false, session: true, path: /, domain: .example.com, port: undefined, expires: n/a, size: 47
{
path : "/"
domain : ".example.com"
}
name: Cookie2, value: value2, httpOnly: false, secure: false, session: true, path: /foo, domain: foo.example.com, port: undefined, expires: n/a, size: 55
{
path : "/foo"
domain : "foo.example.com"
}
source: cooke1 = value; expires = Mon, Oct 18 2010 17:00 GMT+0000; Domain =.example.com
Cookie2 = value2; Path = /foo; DOMAIN = foo.example.com; HttpOnly; Secure; Discard;
name: cooke1, value: value, httpOnly: false, secure: false, session: true, path: undefined, domain: .example.com, port: undefined, expires: 1287421200000, size: 82
{
expires : "Mon, Oct 18 2010 17:00 GMT+0000"
domain : ".example.com"
}
name: Cookie2, value: value2, httpOnly: true, secure: true, session: true, path: /foo, domain: foo.example.com, port: undefined, expires: n/a, size: 83
{
path : "/foo"
domain : "foo.example.com"
httponly : undefined
secure : undefined
discard : undefined
}
source: cooke1 = value; max-age= 1440; Domain =.example.com
Cookie2 = value2; Path = /foo; DOMAIN = foo.example.com; HttpOnly; Secure; Discard;
name: cooke1, value: value, httpOnly: false, secure: false, session: false, path: undefined, domain: .example.com, port: undefined, expires: 1287422640000, size: 55
{
max-age : "1440"
domain : ".example.com"
}
name: Cookie2, value: value2, httpOnly: true, secure: true, session: true, path: /foo, domain: foo.example.com, port: undefined, expires: n/a, size: 83
{
path : "/foo"
domain : "foo.example.com"
httponly : undefined
secure : undefined
discard : undefined
}

@@ -0,0 +1,71 @@
<html>
<head>
<script src="../http/tests/inspector/inspector-test2.js"></script>
<script type="text/javascript">

function initialize_CookieTests()
{

InspectorTest.dumpCookie = function(cookie)
{
var requestDate = new Date("Mon Oct 18 2010 17:00:00 GMT+0000");
var expires = cookie.expires(requestDate);

var output = "name: " + cookie.name + ", value: " + cookie.value + ", httpOnly: " + cookie.httpOnly +
", secure: " + cookie.secure + ", session: " + cookie.session + ", path: " + cookie.path +
", domain: " + cookie.domain + ", port: " + cookie.port +
", expires: " + (expires ? expires.getTime() : "n/a") +
", size: " + cookie.size;

InspectorTest.addResult(output);
InspectorTest.addObject(cookie.attributes);
}

InspectorTest.dumpCookies = function(cookies)
{
for (var i = 0; i < cookies.length; ++i)
InspectorTest.dumpCookie(cookies[i]);
}

InspectorTest.parseAndDumpCookie = function(header)
{
var parser = new WebInspector.CookieParser();
InspectorTest.addResult("source: " + header);
InspectorTest.dumpCookies(parser.parseCookie(header));
}

InspectorTest.parseAndDumpSetCookie = function(header)
{
var parser = new WebInspector.CookieParser();
InspectorTest.addResult("source: " + header);
InspectorTest.dumpCookies(parser.parseSetCookie(header));
}

}

var test = function()
{
InspectorTest.parseAndDumpCookie("cookie=value");
InspectorTest.parseAndDumpCookie("$version=1; a=b,c = d, e=f");
InspectorTest.parseAndDumpCookie("$version=1; a=b;c = d; e =f");
InspectorTest.parseAndDumpCookie("cooke1 = value1; another cookie = another value");
InspectorTest.parseAndDumpCookie("cooke1 = value; $Path=/; $Domain=.example.com;");
InspectorTest.parseAndDumpCookie("cooke1 = value; $Path=/; $Domain=.example.com ; Cookie2 = value2; $Path = /foo; $DOMAIN = foo.example.com;");
InspectorTest.parseAndDumpCookie("cooke1 = value; $Path=/; $Domain=.example.com\nCookie2 = value2; $Path = /foo; $DOMAIN = foo.example.com; ");
InspectorTest.parseAndDumpCookie("$version =1; cooke1 = value; $Path=/; $Domain =.example.com; \n Cookie2 = value2; $Path = /foo; $DOMAIN = foo.example.com;");

InspectorTest.parseAndDumpSetCookie("cookie=value");
InspectorTest.parseAndDumpSetCookie("a=b\n c=d\n f");
InspectorTest.parseAndDumpSetCookie("cooke1 = value; Path=/; Domain=.example.com;");
InspectorTest.parseAndDumpSetCookie("cooke1 = value; Path=/; Domain= .example.com \nCookie2 = value2; Path = /foo; Domain = foo.example.com");
InspectorTest.parseAndDumpSetCookie("cooke1 = value; expires = Mon, Oct 18 2010 17:00 GMT+0000; Domain =.example.com\nCookie2 = value2; Path = /foo; DOMAIN = foo.example.com; HttpOnly; Secure; Discard;");
InspectorTest.parseAndDumpSetCookie("cooke1 = value; max-age= 1440; Domain =.example.com\n Cookie2 = value2; Path = /foo; DOMAIN = foo.example.com; HttpOnly; Secure; Discard;");
InspectorTest.completeTest();
}

</script>
</head>
<body onload="runTest()">
<p>Tests inspector cookie parser</p>
</body>
</html>
@@ -1,3 +1,30 @@
2010-10-19 Andrey Kosyakov <caseq@chromium.org>

Reviewed by Pavel Feldman.

Web Inspector: expose request/response cookies in HAR
https://bugs.webkit.org/show_bug.cgi?id=47894

Test: inspector/cookie-parser.html

* WebCore.gypi:
* WebCore.vcproj/WebCore.vcproj:
* inspector/front-end/CookieParser.js: Added.
* inspector/front-end/HAREntry.js:
(WebInspector.HAREntry.prototype._buildRequest):
(WebInspector.HAREntry.prototype._buildResponse):
(WebInspector.HAREntry.prototype._buildCookies):
(WebInspector.HAREntry.prototype._buildCookie):
* inspector/front-end/Resource.js: Parse Cookie/Set-Cookie headers and expose cookies.
(WebInspector.Resource.prototype.set requestHeaders):
(WebInspector.Resource.prototype.get requestCookies):
(WebInspector.Resource.prototype.set responseHeaders):
(WebInspector.Resource.prototype.get responseCookies):
(WebInspector.Resource.prototype._parseRequestCookies):
(WebInspector.Resource.prototype._parseResponseCookies):
* inspector/front-end/WebKit.qrc:
* inspector/front-end/inspector.html:

2010-10-20 Nikolas Zimmermann <nzimmermann@rim.com>

Not reviewed.
@@ -4358,6 +4358,7 @@
'inspector/front-end/ConsoleView.js',
'inspector/front-end/ContextMenu.js',
'inspector/front-end/CookieItemsView.js',
'inspector/front-end/CookieParser.js',
'inspector/front-end/CSSCompletions.js',
'inspector/front-end/CSSStyleModel.js',
'inspector/front-end/Database.js',
@@ -63457,6 +63457,14 @@
RelativePath="..\inspector\front-end\ContextMenu.js"
>
</File>
<File
RelativePath="..\inspector\front-end\CookieItemsView.js"
>
</File>
<File
RelativePath="..\inspector\front-end\CookieParser.js"
>
</File>
<File
RelativePath="..\inspector\front-end\CSSStyleModel.js"
>

0 comments on commit 50e8090

Please sign in to comment.