Changeset 259649 in webkit


Ignore:
Timestamp:
Apr 7, 2020 11:19:18 AM (4 years ago)
Author:
Devin Rousso
Message:

Web Inspector: unable to see cookies on pages that have subframes which have been denied access to cookies
https://bugs.webkit.org/show_bug.cgi?id=210125
<rdar://problem/61357992>

Reviewed by Timothy Hatcher.

Previously, the same boolean value was re-used when checking whether that URL and document
pairs is able to access cookies, meaning that if the last check returned false, the logic
would incorrectly think that none of the URL and document pairs would have access to any
cookies, resulting in an empty array.

Instead of using this all-or-nothing boolean, if a URL and document pair is not able to
access cookies, simply ignore it and move on to the next pair.

  • inspector/agents/InspectorPageAgent.cpp:

(WebCore::InspectorPageAgent::getCookies):

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r259647 r259649  
     12020-04-07  Devin Rousso  <drousso@apple.com>
     2
     3        Web Inspector: unable to see cookies on pages that have subframes which have been denied access to cookies
     4        https://bugs.webkit.org/show_bug.cgi?id=210125
     5        <rdar://problem/61357992>
     6
     7        Reviewed by Timothy Hatcher.
     8
     9        Previously, the same boolean value was re-used when checking whether that URL and `document`
     10        pairs is able to access cookies, meaning that if the last check returned `false`, the logic
     11        would incorrectly think that none of the URL and `document` pairs would have access to any
     12        cookies, resulting in an empty array.
     13
     14        Instead of using this all-or-nothing boolean, if a URL and `document` pair is not able to
     15        access cookies, simply ignore it and move on to the next pair.
     16
     17        * inspector/agents/InspectorPageAgent.cpp:
     18        (WebCore::InspectorPageAgent::getCookies):
     19
    1202020-04-07  Ryosuke Niwa  <rniwa@webkit.org>
    221
  • trunk/Source/WebCore/inspector/agents/InspectorPageAgent.cpp

    r259173 r259649  
    521521void InspectorPageAgent::getCookies(ErrorString&, RefPtr<JSON::ArrayOf<Inspector::Protocol::Page::Cookie>>& cookies)
    522522{
    523     // If we can get raw cookies.
    524     ListHashSet<Cookie> rawCookiesList;
    525 
    526     // If we can't get raw cookies - fall back to String representation
    527     StringBuilder stringCookiesList;
    528 
    529     // Return value to getRawCookies should be the same for every call because
    530     // the return value is platform/network backend specific, and the call will
    531     // always return the same true/false value.
    532     bool rawCookiesImplemented = false;
     523    ListHashSet<Cookie> allRawCookies;
    533524
    534525    for (Frame* frame = &m_inspectedPage.mainFrame(); frame; frame = frame->tree().traverseNext()) {
     
    538529
    539530        for (auto& url : allResourcesURLsForFrame(frame)) {
    540             Vector<Cookie> docCookiesList;
    541             rawCookiesImplemented = document->page()->cookieJar().getRawCookies(*document, URL({ }, url), docCookiesList);
    542 
    543             if (!rawCookiesImplemented) {
    544                 // FIXME: We need duplication checking for the String representation of cookies.
    545                 // Exceptions are thrown by cookie() in sandboxed frames. That won't happen here
    546                 // because "document" is the document of the main frame of the page.
    547                 stringCookiesList.append(document->cookie().releaseReturnValue());
    548             } else {
    549                 for (auto& cookie : docCookiesList)
    550                     rawCookiesList.add(cookie);
    551             }
     531            Vector<Cookie> rawCookiesForURLInDocument;
     532            if (!document->page()->cookieJar().getRawCookies(*document, URL({ }, url), rawCookiesForURLInDocument))
     533                continue;
     534
     535            for (auto& rawCookieForURLInDocument : rawCookiesForURLInDocument)
     536                allRawCookies.add(rawCookieForURLInDocument);
    552537        }
    553538    }
    554539
    555     // FIXME: Do not return empty string/empty array. Make returns optional instead. https://bugs.webkit.org/show_bug.cgi?id=80855
    556     if (rawCookiesImplemented)
    557         cookies = buildArrayForCookies(rawCookiesList);
    558     else
    559         cookies = JSON::ArrayOf<Inspector::Protocol::Page::Cookie>::create();
     540    cookies = buildArrayForCookies(allRawCookies);
    560541}
    561542
Note: See TracChangeset for help on using the changeset viewer.