Title: [259649] trunk/Source/WebCore
Revision
259649
Author
drou...@apple.com
Date
2020-04-07 11:19:18 -0700 (Tue, 07 Apr 2020)

Log 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):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (259648 => 259649)


--- trunk/Source/WebCore/ChangeLog	2020-04-07 18:18:36 UTC (rev 259648)
+++ trunk/Source/WebCore/ChangeLog	2020-04-07 18:19:18 UTC (rev 259649)
@@ -1,3 +1,22 @@
+2020-04-07  Devin Rousso  <drou...@apple.com>
+
+        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):
+
 2020-04-07  Ryosuke Niwa  <rn...@webkit.org>
 
         TextManipulationController fails to replace a paragraph that ends with a br

Modified: trunk/Source/WebCore/inspector/agents/InspectorPageAgent.cpp (259648 => 259649)


--- trunk/Source/WebCore/inspector/agents/InspectorPageAgent.cpp	2020-04-07 18:18:36 UTC (rev 259648)
+++ trunk/Source/WebCore/inspector/agents/InspectorPageAgent.cpp	2020-04-07 18:19:18 UTC (rev 259649)
@@ -520,17 +520,8 @@
 
 void InspectorPageAgent::getCookies(ErrorString&, RefPtr<JSON::ArrayOf<Inspector::Protocol::Page::Cookie>>& cookies)
 {
-    // If we can get raw cookies.
-    ListHashSet<Cookie> rawCookiesList;
+    ListHashSet<Cookie> allRawCookies;
 
-    // If we can't get raw cookies - fall back to String representation
-    StringBuilder stringCookiesList;
-
-    // Return value to getRawCookies should be the same for every call because
-    // the return value is platform/network backend specific, and the call will
-    // always return the same true/false value.
-    bool rawCookiesImplemented = false;
-
     for (Frame* frame = &m_inspectedPage.mainFrame(); frame; frame = frame->tree().traverseNext()) {
         Document* document = frame->document();
         if (!document || !document->page())
@@ -537,26 +528,16 @@
             continue;
 
         for (auto& url : allResourcesURLsForFrame(frame)) {
-            Vector<Cookie> docCookiesList;
-            rawCookiesImplemented = document->page()->cookieJar().getRawCookies(*document, URL({ }, url), docCookiesList);
+            Vector<Cookie> rawCookiesForURLInDocument;
+            if (!document->page()->cookieJar().getRawCookies(*document, URL({ }, url), rawCookiesForURLInDocument))
+                continue;
 
-            if (!rawCookiesImplemented) {
-                // FIXME: We need duplication checking for the String representation of cookies.
-                // Exceptions are thrown by cookie() in sandboxed frames. That won't happen here
-                // because "document" is the document of the main frame of the page.
-                stringCookiesList.append(document->cookie().releaseReturnValue());
-            } else {
-                for (auto& cookie : docCookiesList)
-                    rawCookiesList.add(cookie);
-            }
+            for (auto& rawCookieForURLInDocument : rawCookiesForURLInDocument)
+                allRawCookies.add(rawCookieForURLInDocument);
         }
     }
 
-    // FIXME: Do not return empty string/empty array. Make returns optional instead. https://bugs.webkit.org/show_bug.cgi?id=80855
-    if (rawCookiesImplemented)
-        cookies = buildArrayForCookies(rawCookiesList);
-    else
-        cookies = JSON::ArrayOf<Inspector::Protocol::Page::Cookie>::create();
+    cookies = buildArrayForCookies(allRawCookies);
 }
 
 static Optional<Cookie> parseCookieObject(ErrorString& errorString, const JSON::Object& cookieObject)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to