Title: [241743] trunk
Revision
241743
Author
wilan...@apple.com
Date
2019-02-18 15:13:58 -0800 (Mon, 18 Feb 2019)

Log Message

Check the existence of the frame in Document::hasFrameSpecificStorageAccess() and Document::setHasFrameSpecificStorageAccess()
https://bugs.webkit.org/show_bug.cgi?id=194777
<rdar://problem/47731945>

Reviewed by Geoffrey Garen and Chris Dumez.

Source/WebCore:

Test: http/tests/storageAccess/remove-requesting-iframe.html

* dom/Document.cpp:
(WebCore::Document::hasFrameSpecificStorageAccess const):
    Now checks for the existence of the frame.
(WebCore::Document::setHasFrameSpecificStorageAccess):
    Now checks for the existence of the frame.
* loader/ResourceLoadObserver.cpp:
(WebCore::ResourceLoadObserver::logUserInteractionWithReducedTimeResolution):
    Now checks that the session ID is valid.

Source/WebKit:

* NetworkProcess/NetworkConnectionToWebProcess.cpp:
(WebKit::NetworkConnectionToWebProcess::logUserInteraction):
   Now returns early if the incoming session ID is invalid.
   Added an ASSERT to help us find other call sites passing invalid session IDs.

LayoutTests:

* http/tests/storageAccess/remove-requesting-iframe-expected.txt: Added.
* http/tests/storageAccess/remove-requesting-iframe.html: Added.
* http/tests/storageAccess/resources/request-storage-access-and-immediately-postmessage-iframe.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (241742 => 241743)


--- trunk/LayoutTests/ChangeLog	2019-02-18 23:12:33 UTC (rev 241742)
+++ trunk/LayoutTests/ChangeLog	2019-02-18 23:13:58 UTC (rev 241743)
@@ -1,3 +1,15 @@
+2019-02-18  John Wilander  <wilan...@apple.com>
+
+        Check the existence of the frame in Document::hasFrameSpecificStorageAccess() and Document::setHasFrameSpecificStorageAccess()
+        https://bugs.webkit.org/show_bug.cgi?id=194777
+        <rdar://problem/47731945>
+
+        Reviewed by Geoffrey Garen and Chris Dumez.
+
+        * http/tests/storageAccess/remove-requesting-iframe-expected.txt: Added.
+        * http/tests/storageAccess/remove-requesting-iframe.html: Added.
+        * http/tests/storageAccess/resources/request-storage-access-and-immediately-postmessage-iframe.html: Added.
+
 2019-02-18  Joseph Pecoraro  <pecor...@apple.com>
 
         Web Inspector: Better categorize CPU usage per-thread / worker

Added: trunk/LayoutTests/http/tests/storageAccess/remove-requesting-iframe-expected.txt (0 => 241743)


--- trunk/LayoutTests/http/tests/storageAccess/remove-requesting-iframe-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/http/tests/storageAccess/remove-requesting-iframe-expected.txt	2019-02-18 23:13:58 UTC (rev 241743)
@@ -0,0 +1,10 @@
+Tests that Storage Access API calls work well for removed frames.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS iframe removed.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/http/tests/storageAccess/remove-requesting-iframe.html (0 => 241743)


--- trunk/LayoutTests/http/tests/storageAccess/remove-requesting-iframe.html	                        (rev 0)
+++ trunk/LayoutTests/http/tests/storageAccess/remove-requesting-iframe.html	2019-02-18 23:13:58 UTC (rev 241743)
@@ -0,0 +1,62 @@
+<!DOCTYPE html> <!-- webkit-test-runner [ useFlexibleViewport=true ] -->
+<html>
+<head>
+    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
+    <script src=""
+    <script src=""
+    <script src=""
+</head>
+<body _onload_="runTest()">
+<script>
+    description("Tests that Storage Access API calls work well for removed frames.");
+    jsTestIsAsync = true;
+
+    function finishTest() {
+        setEnableFeature(false, finishJSTest);
+    }
+
+    function receiveMessage() {
+        requestingiframe.remove();
+        testPassed("iframe removed.");
+        setTimeout(finishTest, 0.5);
+    }
+
+    window.addEventListener("message", receiveMessage, false);
+
+    function activateElement(elementId) {
+        var element = document.getElementById(elementId);
+        var centerX = element.offsetLeft + element.offsetWidth / 2;
+        var centerY = element.offsetTop + element.offsetHeight / 2;
+        UIHelper.activateAt(centerX, centerY).then(
+            function () {
+                if (window.eventSender)
+                    eventSender.keyDown("escape");
+                else {
+                    testFailed("No eventSender.");
+                    finishTest();
+                }
+            },
+            function () {
+                testFailed("Promise rejected.");
+                finishTest();
+            }
+        );
+    }
+
+    const iframeID = "requestingiframe";
+    const iframeSource = "http://localhost:8000/storageAccess/resources/request-storage-access-and-immediately-postmessage-iframe.html";
+
+    function runTest() {
+        let iframeElement = document.createElement("iframe");
+        iframeElement._onload_ = function() {
+            testRunner.statisticsUpdateCookieBlocking(function() {
+                activateElement(iframeID);
+            });
+        };
+        iframeElement.id = iframeID;
+        iframeElement.src = ""
+        document.body.appendChild(iframeElement);
+    }
+</script>
+</body>
+</html>
\ No newline at end of file

Added: trunk/LayoutTests/http/tests/storageAccess/resources/request-storage-access-and-immediately-postmessage-iframe.html (0 => 241743)


--- trunk/LayoutTests/http/tests/storageAccess/resources/request-storage-access-and-immediately-postmessage-iframe.html	                        (rev 0)
+++ trunk/LayoutTests/http/tests/storageAccess/resources/request-storage-access-and-immediately-postmessage-iframe.html	2019-02-18 23:13:58 UTC (rev 241743)
@@ -0,0 +1,15 @@
+<html>
+<head>
+    <script>
+        if (internals)
+            internals.setUserGrantsStorageAccess(true);
+
+        function makeRequestWithUserGesture() {
+            document.requestStorageAccess();
+            top.postMessage("API called.", "http://127.0.0.1:8000");
+        }
+    </script>
+</head>
+<body _onclick_="makeRequestWithUserGesture()">
+</body>
+</html>
\ No newline at end of file

Modified: trunk/Source/WebCore/ChangeLog (241742 => 241743)


--- trunk/Source/WebCore/ChangeLog	2019-02-18 23:12:33 UTC (rev 241742)
+++ trunk/Source/WebCore/ChangeLog	2019-02-18 23:13:58 UTC (rev 241743)
@@ -1,3 +1,22 @@
+2019-02-18  John Wilander  <wilan...@apple.com>
+
+        Check the existence of the frame in Document::hasFrameSpecificStorageAccess() and Document::setHasFrameSpecificStorageAccess()
+        https://bugs.webkit.org/show_bug.cgi?id=194777
+        <rdar://problem/47731945>
+
+        Reviewed by Geoffrey Garen and Chris Dumez.
+
+        Test: http/tests/storageAccess/remove-requesting-iframe.html
+
+        * dom/Document.cpp:
+        (WebCore::Document::hasFrameSpecificStorageAccess const):
+            Now checks for the existence of the frame.
+        (WebCore::Document::setHasFrameSpecificStorageAccess):
+            Now checks for the existence of the frame.
+        * loader/ResourceLoadObserver.cpp:
+        (WebCore::ResourceLoadObserver::logUserInteractionWithReducedTimeResolution):
+            Now checks that the session ID is valid.
+
 2019-02-18  Jer Noble  <jer.no...@apple.com>
 
         -[AVSampleBufferDisplayLayer player]: Unrecognized selector crash

Modified: trunk/Source/WebCore/dom/Document.cpp (241742 => 241743)


--- trunk/Source/WebCore/dom/Document.cpp	2019-02-18 23:12:33 UTC (rev 241742)
+++ trunk/Source/WebCore/dom/Document.cpp	2019-02-18 23:13:58 UTC (rev 241743)
@@ -8458,12 +8458,13 @@
 #if ENABLE(RESOURCE_LOAD_STATISTICS)
 bool Document::hasFrameSpecificStorageAccess() const
 {
-    return m_frame->loader().client().hasFrameSpecificStorageAccess();
+    return m_frame && m_frame->loader().client().hasFrameSpecificStorageAccess();
 }
     
 void Document::setHasFrameSpecificStorageAccess(bool value)
 {
-    m_frame->loader().client().setHasFrameSpecificStorageAccess(value);
+    if (m_frame)
+        m_frame->loader().client().setHasFrameSpecificStorageAccess(value);
 }
 
 bool Document::hasRequestedPageSpecificStorageAccessWithUserInteraction(const String& primaryDomain)

Modified: trunk/Source/WebCore/loader/ResourceLoadObserver.cpp (241742 => 241743)


--- trunk/Source/WebCore/loader/ResourceLoadObserver.cpp	2019-02-18 23:12:33 UTC (rev 241742)
+++ trunk/Source/WebCore/loader/ResourceLoadObserver.cpp	2019-02-18 23:13:58 UTC (rev 241743)
@@ -193,7 +193,7 @@
 
 void ResourceLoadObserver::logUserInteractionWithReducedTimeResolution(const Document& document)
 {
-    if (!shouldLog(document.sessionID().isEphemeral()))
+    if (!document.sessionID().isValid() || !shouldLog(document.sessionID().isEphemeral()))
         return;
 
     auto& url = ""

Modified: trunk/Source/WebKit/ChangeLog (241742 => 241743)


--- trunk/Source/WebKit/ChangeLog	2019-02-18 23:12:33 UTC (rev 241742)
+++ trunk/Source/WebKit/ChangeLog	2019-02-18 23:13:58 UTC (rev 241743)
@@ -1,3 +1,16 @@
+2019-02-18  John Wilander  <wilan...@apple.com>
+
+        Check the existence of the frame in Document::hasFrameSpecificStorageAccess() and Document::setHasFrameSpecificStorageAccess()
+        https://bugs.webkit.org/show_bug.cgi?id=194777
+        <rdar://problem/47731945>
+
+        Reviewed by Geoffrey Garen and Chris Dumez.
+
+        * NetworkProcess/NetworkConnectionToWebProcess.cpp:
+        (WebKit::NetworkConnectionToWebProcess::logUserInteraction):
+           Now returns early if the incoming session ID is invalid.
+           Added an ASSERT to help us find other call sites passing invalid session IDs.
+
 2019-02-18  Per Arne Vollan  <pvol...@apple.com>
 
         It should be possible to get the mouse event modifiers for a page overlay client.

Modified: trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.cpp (241742 => 241743)


--- trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.cpp	2019-02-18 23:12:33 UTC (rev 241742)
+++ trunk/Source/WebKit/NetworkProcess/NetworkConnectionToWebProcess.cpp	2019-02-18 23:13:58 UTC (rev 241743)
@@ -587,6 +587,10 @@
 
 void NetworkConnectionToWebProcess::logUserInteraction(PAL::SessionID sessionID, const String& topLevelOrigin)
 {
+    ASSERT(sessionID.isValid());
+    if (!sessionID.isValid())
+        return;
+
     if (auto networkSession = networkProcess().networkSession(sessionID)) {
         if (auto* resourceLoadStatistics = networkSession->resourceLoadStatistics())
             resourceLoadStatistics->logUserInteraction(topLevelOrigin, [] { });
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to