Changeset 70137 in webkit


Ignore:
Timestamp:
Oct 20, 2010 2:14:09 AM (14 years ago)
Author:
caseq@chromium.org
Message:

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.
Location:
trunk
Files:
3 added
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r70132 r70137  
     12010-10-19  Andrey Kosyakov  <caseq@chromium.org>
     2
     3        Reviewed by Pavel Feldman.
     4
     5        Web Inspector: expose request/response cookies in HAR
     6        https://bugs.webkit.org/show_bug.cgi?id=47894
     7
     8        * http/tests/inspector/inspector-test.js:
     9        (dumpObject): Handle null objects as a special case (display null instead of empty object)
     10        * http/tests/inspector/inspector-test2.js:
     11        (initialize_InspectorTest.InspectorTest.addObject): Ditto.
     12        * http/tests/inspector/resource-har-conversion-expected.txt:
     13        * http/tests/inspector/resource-har-conversion.html:
     14        * inspector/cookie-parser-expected.txt: Added.
     15        * inspector/cookie-parser.html: Added.
     16
    1172010-10-20  Shinichiro Hamaji  <hamaji@chromium.org>
    218
  • trunk/LayoutTests/http/tests/inspector/inspector-test.js

    r65053 r70137  
    5454        if (nondeterministicProps && prop in nondeterministicProps)
    5555            output(prefixWithName + "<" + typeof propValue + ">");
     56        else if (propValue === null)
     57            output(prefixWithName + "null");
    5658        else if (typeof propValue === "object")
    5759            dumpObject(propValue, nondeterministicProps, prefix + "    ", prefixWithName);
  • trunk/LayoutTests/http/tests/inspector/inspector-test2.js

    r67721 r70137  
    6262        if (nondeterministicProps && prop in nondeterministicProps)
    6363            InspectorTest.addResult(prefixWithName + "<" + typeof propValue + ">");
     64        else if (propValue === null)
     65            InspectorTest.addResult(prefixWithName + "null");
    6466        else if (typeof propValue === "object")
    6567            InspectorTest.addObject(propValue, nondeterministicProps, prefix + "    ", prefixWithName);
  • trunk/LayoutTests/http/tests/inspector/resource-har-conversion-expected.txt

    r67474 r70137  
    1313            headersSize : -1
    1414            bodySize : <number>
     15            cookies : {
     16                0 : {
     17                    name : "a"
     18                    value : "b"
     19                    path : "/path"
     20                    domain : "example.com"
     21                    expires : null
     22                    httpOnly : false
     23                    secure : false
     24                }
     25                1 : {
     26                    name : "a1"
     27                    value : "b1"
     28                    path : undefined
     29                    domain : undefined
     30                    expires : null
     31                    httpOnly : false
     32                    secure : false
     33                }
     34                2 : {
     35                    name : "c1"
     36                    value : "d1"
     37                    path : undefined
     38                    domain : undefined
     39                    expires : null
     40                    httpOnly : false
     41                    secure : false
     42                }
     43            }
    1544        }
    1645        response : {
     
    2554            headersSize : -1
    2655            bodySize : <number>
     56            cookies : {
     57                0 : {
     58                    name : "x"
     59                    value : "y"
     60                    path : "/path"
     61                    domain : "example.com"
     62                    expires : null
     63                    httpOnly : true
     64                    secure : true
     65                }
     66                1 : {
     67                    name : "x1"
     68                    value : "y1"
     69                    path : undefined
     70                    domain : undefined
     71                    expires : null
     72                    httpOnly : false
     73                    secure : false
     74                }
     75                2 : {
     76                    name : "z2"
     77                    value : "y2"
     78                    path : undefined
     79                    domain : undefined
     80                    expires : null
     81                    httpOnly : false
     82                    secure : false
     83                }
     84            }
    2785        }
    2886        timings : <object>
  • trunk/LayoutTests/http/tests/inspector/resource-har-conversion.html

    r66735 r70137  
    1313    }
    1414
     15    function addCookieHeadersToResource(resource)
     16    {
     17        resource.requestHeaders = {
     18            "Cookie": "a=b; $Path=/path; $Domain=example.com; a1=b1\nc1=d1"
     19        };
     20        resource.responseHeaders = {
     21            "Set-Cookie": "x=y; Path=/path; Domain=example.com; Discard; httpOnly; Secure; Version=1\nx1=y1\nz2=y2"
     22        };
     23    }
     24
     25    function findResourceByURL(url)
     26    {
     27        for (var resource in WebInspector.resources) {
     28            if (url.test(WebInspector.resources[resource].url))
     29                return WebInspector.resources[resource];
     30        }
     31    }
     32
    1533    InspectorTest.enableResourceTracking(function() {
    1634        InjectedScriptAccess.getDefault().evaluate("doXHR()", "console", function() {
     35            addCookieHeadersToResource(findResourceByURL(/inspector-test2\.js$/));
    1736            var resources = Object.keys(WebInspector.resources).map(getHAR).sort(InspectorTest.resourceURLComparer);
    1837            InspectorTest.addObject(resources, InspectorTest.HARNondeterministicPropertiesWithSize);
  • trunk/WebCore/ChangeLog

    r70136 r70137  
     12010-10-19  Andrey Kosyakov  <caseq@chromium.org>
     2
     3        Reviewed by Pavel Feldman.
     4
     5        Web Inspector: expose request/response cookies in HAR
     6        https://bugs.webkit.org/show_bug.cgi?id=47894
     7
     8        Test: inspector/cookie-parser.html
     9
     10        * WebCore.gypi:
     11        * WebCore.vcproj/WebCore.vcproj:
     12        * inspector/front-end/CookieParser.js: Added.
     13        * inspector/front-end/HAREntry.js:
     14        (WebInspector.HAREntry.prototype._buildRequest):
     15        (WebInspector.HAREntry.prototype._buildResponse):
     16        (WebInspector.HAREntry.prototype._buildCookies):
     17        (WebInspector.HAREntry.prototype._buildCookie):
     18        * inspector/front-end/Resource.js: Parse Cookie/Set-Cookie headers and expose cookies.
     19        (WebInspector.Resource.prototype.set requestHeaders):
     20        (WebInspector.Resource.prototype.get requestCookies):
     21        (WebInspector.Resource.prototype.set responseHeaders):
     22        (WebInspector.Resource.prototype.get responseCookies):
     23        (WebInspector.Resource.prototype._parseRequestCookies):
     24        (WebInspector.Resource.prototype._parseResponseCookies):
     25        * inspector/front-end/WebKit.qrc:
     26        * inspector/front-end/inspector.html:
     27
    1282010-10-20  Nikolas Zimmermann  <nzimmermann@rim.com>
    229
  • trunk/WebCore/WebCore.gypi

    r70135 r70137  
    43594359            'inspector/front-end/ContextMenu.js',
    43604360            'inspector/front-end/CookieItemsView.js',
     4361            'inspector/front-end/CookieParser.js',
    43614362            'inspector/front-end/CSSCompletions.js',
    43624363            'inspector/front-end/CSSStyleModel.js',
  • trunk/WebCore/WebCore.vcproj/WebCore.vcproj

    r70135 r70137  
    6345963459                                </File>
    6346063460                                <File
     63461                                        RelativePath="..\inspector\front-end\CookieItemsView.js"
     63462                                        >
     63463                                </File>
     63464                                <File
     63465                                        RelativePath="..\inspector\front-end\CookieParser.js"
     63466                                        >
     63467                                </File>
     63468                                <File
    6346163469                                        RelativePath="..\inspector\front-end\CSSStyleModel.js"
    6346263470                                        >
  • trunk/WebCore/inspector/front-end/HAREntry.js

    r70046 r70137  
    5757            url: this._resource.url,
    5858            // httpVersion: "HTTP/1.1" -- Not available.
    59             // cookies: [] -- Not available.
    6059            headers: this._buildHeaders(this._resource.requestHeaders),
    6160            headersSize: -1, // Not available.
     
    6665        if (this._resource.requestFormData)
    6766            res.postData = this._buildPostData();
     67        if (this._resource.requestCookies)
     68            res.cookies = this._buildCookies(this._resource.requestCookies);
    6869        return res;
    6970    },
     
    7172    _buildResponse: function()
    7273    {
    73         return {
     74        var res = {
    7475            status: this._resource.statusCode,
    7576            statusText: this._resource.statusText,
    7677            // "httpVersion": "HTTP/1.1" -- Not available.
    77             // "cookies": [],  -- Not available.
    7878            headers: this._buildHeaders(this._resource.responseHeaders),
    7979            content: this._buildContent(),
     
    8282            bodySize: this._resource.resourceSize
    8383        };
     84        if (this._resource.responseCookies)
     85            res.cookies = this._buildCookies(this._resource.responseCookies);
     86        return res;
    8487    },
    8588
     
    151154    },
    152155
     156    _buildCookies: function(cookies)
     157    {
     158        return cookies.map(this._buildCookie.bind(this));
     159    },
     160
     161    _buildCookie: function(cookie)
     162    {
     163       
     164        return {
     165            name: cookie.name,
     166            value: cookie.value,
     167            path: cookie.path,
     168            domain: cookie.domain,
     169            expires: cookie.expires(new Date(this._resource.startTime * 1000)),
     170            httpOnly: cookie.httpOnly,
     171            secure: cookie.secure
     172        };
     173    },
     174
    153175    _interval: function(start, end)
    154176    {
  • trunk/WebCore/inspector/front-end/Resource.js

    r70045 r70137  
    351351        this._requestHeaders = x;
    352352        delete this._sortedRequestHeaders;
     353        delete this._requestCookies;
    353354
    354355        this.dispatchEventToListeners("requestHeaders changed");
     
    373374    },
    374375
     376    get requestCookies()
     377    {
     378        if (!this._requestCookies)
     379            this._requestCookies = WebInspector.CookieParser.parseCookie(this.requestHeaderValue("Cookie"));
     380        return this._requestCookies;
     381    },
     382
    375383    get requestFormData()
    376384    {
     
    393401        this._responseHeaders = x;
    394402        delete this._sortedResponseHeaders;
     403        delete this._responseCookies;
    395404
    396405        this.dispatchEventToListeners("responseHeaders changed");
     
    413422    {
    414423        return this._headerValue(this.responseHeaders, headerName);
     424    },
     425
     426    get responseCookies()
     427    {
     428        if (!this._responseCookies)
     429            this._responseCookies = WebInspector.CookieParser.parseSetCookie(this.responseHeaderValue("Set-Cookie"));
     430        return this._responseCookies;
    415431    },
    416432
  • trunk/WebCore/inspector/front-end/WebKit.qrc

    r69948 r70137  
    2121    <file>ContextMenu.js</file>
    2222    <file>CookieItemsView.js</file>
     23    <file>CookieParser.js</file>
    2324    <file>CSSCompletions.js</file>
    2425    <file>CSSStyleModel.js</file>
  • trunk/WebCore/inspector/front-end/inspector.html

    r69948 r70137  
    145145    <script type="text/javascript" src="ShortcutsHelp.js"></script>
    146146    <script type="text/javascript" src="HAREntry.js"></script>
     147    <script type="text/javascript" src="CookieParser.js"></script>
    147148</head>
    148149<body class="detached">
  • trunk/WebKit/chromium/ChangeLog

    r70081 r70137  
     12010-10-19  Andrey Kosyakov  <caseq@chromium.org>
     2
     3        Reviewed by Pavel Feldman.
     4
     5        Web Inspector: expose request/response cookies in HAR
     6        https://bugs.webkit.org/show_bug.cgi?id=47894
     7
     8        * src/WebResourceRawHeaders.cpp:
     9        (WebKit::addHeader): paste coalescent headers using "\n: as a separator instead of ", "
     10
    1112010-10-19  Tony Chang  <tony@chromium.org>
    212
  • trunk/WebKit/chromium/src/WebResourceRawHeaders.cpp

    r69295 r70137  
    7070    pair<HTTPHeaderMap::iterator, bool> result = map->add(name, value);
    7171    if (!result.second)
    72         result.first->second += String(", ") + value;
     72        result.first->second += String("\n") + value;
    7373}
    7474
Note: See TracChangeset for help on using the changeset viewer.