Title: [227074] trunk
Revision
227074
Author
[email protected]
Date
2018-01-17 11:01:41 -0800 (Wed, 17 Jan 2018)

Log Message

ASSERTION FAILED: !m_completionHandler in PingHandle::~PingHandle()
https://bugs.webkit.org/show_bug.cgi?id=181746
<rdar://problem/36586248>

Reviewed by Chris Dumez.

Source/WebCore:

Call PingHandle::pingLoadComplete() with an error when NSURLConnection queries
whether the ping is able to respond to an authentication request. (Pings do not
respond to authenticate requests.) It will call the completion handler, nullify
the completion handler, and deallocate the PingHandle. Nullifying the completion
handler is necessary to avoid the assertion failure in ~PingHandle().

Test: http/tests/misc/before-unload-load-image.html

* platform/network/PingHandle.h:

LayoutTests:

Adds a test to ensure that loading a protected image from a beforeunload handler
does not cause an assertion failure.

* http/tests/misc/before-unload-load-image-expected.txt: Added.
* http/tests/misc/before-unload-load-image.html: Added.
* http/tests/misc/resources/before-unload-in-subframe-child.html: Added.
* http/tests/misc/resources/protected/protected-image.php: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (227073 => 227074)


--- trunk/LayoutTests/ChangeLog	2018-01-17 18:57:11 UTC (rev 227073)
+++ trunk/LayoutTests/ChangeLog	2018-01-17 19:01:41 UTC (rev 227074)
@@ -1,3 +1,19 @@
+2018-01-17  Daniel Bates  <[email protected]>
+
+        ASSERTION FAILED: !m_completionHandler in PingHandle::~PingHandle()
+        https://bugs.webkit.org/show_bug.cgi?id=181746
+        <rdar://problem/36586248>
+
+        Reviewed by Chris Dumez.
+
+        Adds a test to ensure that loading a protected image from a beforeunload handler
+        does not cause an assertion failure.
+
+        * http/tests/misc/before-unload-load-image-expected.txt: Added.
+        * http/tests/misc/before-unload-load-image.html: Added.
+        * http/tests/misc/resources/before-unload-in-subframe-child.html: Added.
+        * http/tests/misc/resources/protected/protected-image.php: Added.
+
 2018-01-17  Yacine Bandou  <[email protected]>
 
         [EME][GStreamer] Add the full-sample encryption support in the GStreamer ClearKey decryptor

Added: trunk/LayoutTests/http/tests/misc/before-unload-load-image-expected.txt (0 => 227074)


--- trunk/LayoutTests/http/tests/misc/before-unload-load-image-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/http/tests/misc/before-unload-load-image-expected.txt	2018-01-17 19:01:41 UTC (rev 227074)
@@ -0,0 +1,2 @@
+PASS did not cause assertion failure.
+

Added: trunk/LayoutTests/http/tests/misc/before-unload-load-image.html (0 => 227074)


--- trunk/LayoutTests/http/tests/misc/before-unload-load-image.html	                        (rev 0)
+++ trunk/LayoutTests/http/tests/misc/before-unload-load-image.html	2018-01-17 19:01:41 UTC (rev 227074)
@@ -0,0 +1,49 @@
+<!DOCTYPE html>
+<html>
+<body>
+<pre id="log">FAIL did cause assertion failure.</pre>
+<script>
+if (window.testRunner) {
+    testRunner.dumpAsText();
+    testRunner.setHandlesAuthenticationChallenges(true);
+    testRunner.setAuthenticationUsername("testUser");
+    testRunner.setAuthenticationPassword("testPassword");
+    testRunner.waitUntilDone();
+}
+
+var log = document.getElementById("log");
+var isDone = false;
+
+function done()
+{
+    isDone = true;
+    window.setTimeout(() => {
+        log.innerHTML = "PASS did not cause assertion failure.";
+        if (window.testRunner)
+            testRunner.notifyDone();
+    }, 0);
+}
+
+function test(iframe)
+{
+    if (iframe.didLoad) {
+        done();
+        return;
+    }
+    iframe.didLoad = true;
+    iframe.contentWindow.location.href = ""
+}
+
+function fired(contentWindow)
+{
+    if (isDone)
+        return;
+    var image = new contentWindow.Image;
+    image.src = ""
+}
+
+
+</script>
+<iframe _onload_="test(this);" src=""
+</body>
+</html>

Added: trunk/LayoutTests/http/tests/misc/resources/before-unload-in-subframe-child.html (0 => 227074)


--- trunk/LayoutTests/http/tests/misc/resources/before-unload-in-subframe-child.html	                        (rev 0)
+++ trunk/LayoutTests/http/tests/misc/resources/before-unload-in-subframe-child.html	2018-01-17 19:01:41 UTC (rev 227074)
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html>
+<body _onbeforeunload_="top.fired(window); return null;">
+Child loaded.
+<script>
+
+if (top.loaded)
+    top.loaded();
+
+</script>
+</body>
+</html>

Added: trunk/LayoutTests/http/tests/misc/resources/protected/protected-image.php (0 => 227074)


--- trunk/LayoutTests/http/tests/misc/resources/protected/protected-image.php	                        (rev 0)
+++ trunk/LayoutTests/http/tests/misc/resources/protected/protected-image.php	2018-01-17 19:01:41 UTC (rev 227074)
@@ -0,0 +1,12 @@
+<?php
+header("Cache-Control: no-store");
+header("Connection: close");
+if (!isset($_SERVER["PHP_AUTH_USER"])) {
+    header("WWW-authenticate: Basic realm=\"" . $_SERVER["REQUEST_URI"] . "\"");
+    header("HTTP/1.0 401 Unauthorized");
+    exit;
+}
+// Authenticated
+header("Content-Type: image/png");
+echo file_get_contents("../../../security/contentSecurityPolicy/block-all-mixed-content/resources/red-square.png");
+?>

Modified: trunk/Source/WebCore/ChangeLog (227073 => 227074)


--- trunk/Source/WebCore/ChangeLog	2018-01-17 18:57:11 UTC (rev 227073)
+++ trunk/Source/WebCore/ChangeLog	2018-01-17 19:01:41 UTC (rev 227074)
@@ -1,5 +1,23 @@
 2018-01-17  Daniel Bates  <[email protected]>
 
+        ASSERTION FAILED: !m_completionHandler in PingHandle::~PingHandle()
+        https://bugs.webkit.org/show_bug.cgi?id=181746
+        <rdar://problem/36586248>
+
+        Reviewed by Chris Dumez.
+
+        Call PingHandle::pingLoadComplete() with an error when NSURLConnection queries
+        whether the ping is able to respond to an authentication request. (Pings do not
+        respond to authenticate requests.) It will call the completion handler, nullify
+        the completion handler, and deallocate the PingHandle. Nullifying the completion
+        handler is necessary to avoid the assertion failure in ~PingHandle().
+
+        Test: http/tests/misc/before-unload-load-image.html
+
+        * platform/network/PingHandle.h:
+
+2018-01-17  Daniel Bates  <[email protected]>
+
         WebCoreResourceHandleAsOperationQueueDelegate/ResourceHandleCFURLConnectionDelegateWithOperationQueue may
         be deleted in main thread callback
         https://bugs.webkit.org/show_bug.cgi?id=181747

Modified: trunk/Source/WebCore/platform/network/PingHandle.h (227073 => 227074)


--- trunk/Source/WebCore/platform/network/PingHandle.h	2018-01-17 18:57:11 UTC (rev 227073)
+++ trunk/Source/WebCore/platform/network/PingHandle.h	2018-01-17 19:01:41 UTC (rev 227074)
@@ -81,7 +81,7 @@
     void canAuthenticateAgainstProtectionSpaceAsync(ResourceHandle*, const ProtectionSpace&)
     {
         m_handle->continueCanAuthenticateAgainstProtectionSpace(false);
-        delete this;
+        pingLoadComplete(ResourceError { String { }, 0, m_currentRequest.url(), ASCIILiteral("Not allowed to authenticate"), ResourceError::Type::AccessControl });
     }
 #endif
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to