Title: [234776] trunk
Revision
234776
Author
[email protected]
Date
2018-08-10 16:03:25 -0700 (Fri, 10 Aug 2018)

Log Message

Crash under NetworkResourceLoader::convertToDownload()
https://bugs.webkit.org/show_bug.cgi?id=188479
<rdar://problem/42201724>

Reviewed by Alex Christensen.

Source/WebKit:

In NetworkResourceLoader::convertToDownload(), if m_networkLoad is null then we're trying
to convert a load that came from the disk cache. Since we do not currently support converting
such a load, cancel the current load and start a fresh download.

* NetworkProcess/NetworkResourceLoader.cpp:
(WebKit::NetworkResourceLoader::convertToDownload):

LayoutTests:

Add layout test coverage which reproduces the crash by:
1. Loading a cacheable plugin while plugins are enabled so that the plugin goes into the disk cache
2. Load the plugin again with plugins disabled so that we try to convert the load to a download

* http/tests/download/convert-cached-load-to-download-expected.txt: Added.
* http/tests/download/convert-cached-load-to-download.html: Added.
* http/tests/plugins/resources/mock-plugin-cacheable.pl: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (234775 => 234776)


--- trunk/LayoutTests/ChangeLog	2018-08-10 22:59:56 UTC (rev 234775)
+++ trunk/LayoutTests/ChangeLog	2018-08-10 23:03:25 UTC (rev 234776)
@@ -1,3 +1,19 @@
+2018-08-10  Chris Dumez  <[email protected]>
+
+        Crash under NetworkResourceLoader::convertToDownload()
+        https://bugs.webkit.org/show_bug.cgi?id=188479
+        <rdar://problem/42201724>
+
+        Reviewed by Alex Christensen.
+
+        Add layout test coverage which reproduces the crash by:
+        1. Loading a cacheable plugin while plugins are enabled so that the plugin goes into the disk cache
+        2. Load the plugin again with plugins disabled so that we try to convert the load to a download
+
+        * http/tests/download/convert-cached-load-to-download-expected.txt: Added.
+        * http/tests/download/convert-cached-load-to-download.html: Added.
+        * http/tests/plugins/resources/mock-plugin-cacheable.pl: Added.
+
 2018-08-10  Ross Kirsling  <[email protected]>
 
         [WinCairo] More unreviewed gardening.

Added: trunk/LayoutTests/http/tests/download/convert-cached-load-to-download-expected.txt (0 => 234776)


--- trunk/LayoutTests/http/tests/download/convert-cached-load-to-download-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/http/tests/download/convert-cached-load-to-download-expected.txt	2018-08-10 23:03:25 UTC (rev 234776)
@@ -0,0 +1,6 @@
+Download started.
+Downloading URL with suggested filename "mock-plugin-cacheable.pl"
+Download completed.
+The download should succeed.
+
+Download plugin 

Added: trunk/LayoutTests/http/tests/download/convert-cached-load-to-download.html (0 => 234776)


--- trunk/LayoutTests/http/tests/download/convert-cached-load-to-download.html	                        (rev 0)
+++ trunk/LayoutTests/http/tests/download/convert-cached-load-to-download.html	2018-08-10 23:03:25 UTC (rev 234776)
@@ -0,0 +1,54 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script>
+if (window.testRunner) {
+  testRunner.dumpAsText();
+  testRunner.setShouldLogDownloadCallbacks(true);
+  testRunner.waitUntilDownloadFinished();
+  testRunner.setShouldDownloadUndisplayableMIMETypes(true);
+}
+</script>
+</head>
+<body>
+<p>The download should succeed.</p>
+<a id="testLink">Download plugin</a>
+<script>
+const testURL = "/plugins/resources/mock-plugin-cacheable.pl";
+
+function click(elmt)
+{
+    if (!window.eventSender) {
+        alert('Click the link to run the test.');
+        return;
+    }
+    eventSender.mouseMoveTo(elmt.offsetLeft + 5, elmt.offsetTop + 5);
+    eventSender.mouseDown();
+    eventSender.mouseUp();
+}
+
+function cacheTestResource(then)
+{
+    let frame = document.createElement("iframe");
+    frame.src = ""
+    frame._onload_ = then;
+    document.body.appendChild(frame);
+}
+
+function runTest()
+{
+    cacheTestResource(function() {
+        if (window.testRunner)
+            testRunner.setPluginsEnabled(false);
+        if (window.internals)
+            internals.clearMemoryCache();
+
+        let link = document.getElementById("testLink");
+        testLink.href = ""
+        click(link);
+    });
+}
+runTest();
+</script>
+</body>
+</html>

Added: trunk/LayoutTests/http/tests/plugins/resources/mock-plugin-cacheable.pl (0 => 234776)


--- trunk/LayoutTests/http/tests/plugins/resources/mock-plugin-cacheable.pl	                        (rev 0)
+++ trunk/LayoutTests/http/tests/plugins/resources/mock-plugin-cacheable.pl	2018-08-10 23:03:25 UTC (rev 234776)
@@ -0,0 +1,6 @@
+#!/usr/bin/perl -wT
+use strict;
+
+print "Cache-Control: max-age=3600\n";
+print "Content-Type: application/x-webkit-test-netscape\n\n";
+print "This is a mock plugin. It does pretty much nothing.";
Property changes on: trunk/LayoutTests/http/tests/plugins/resources/mock-plugin-cacheable.pl
___________________________________________________________________

Added: svn:executable

+* \ No newline at end of property

Modified: trunk/LayoutTests/platform/ios-wk1/TestExpectations (234775 => 234776)


--- trunk/LayoutTests/platform/ios-wk1/TestExpectations	2018-08-10 22:59:56 UTC (rev 234775)
+++ trunk/LayoutTests/platform/ios-wk1/TestExpectations	2018-08-10 23:03:25 UTC (rev 234776)
@@ -1382,6 +1382,7 @@
 # testRunner.setShouldDownloadUndisplayableMIMETypes() is not supported on WK1.
 fast/dom/HTMLAnchorElement/anchor-file-blob-convert-to-download.html [ Skip ]
 fast/dom/HTMLAnchorElement/anchor-file-blob-convert-to-download-async-delegate.html [ Skip ]
+http/tests/download/convert-cached-load-to-download.html [ Skip ]
 
 webkit.org/b/137572 scrollbars/scrollbar-iframe-click-does-not-blur-content.html [ Failure ]
 

Modified: trunk/LayoutTests/platform/ios-wk2/TestExpectations (234775 => 234776)


--- trunk/LayoutTests/platform/ios-wk2/TestExpectations	2018-08-10 22:59:56 UTC (rev 234775)
+++ trunk/LayoutTests/platform/ios-wk2/TestExpectations	2018-08-10 23:03:25 UTC (rev 234776)
@@ -1175,6 +1175,7 @@
 webkit.org/b/156067 http/tests/security/anchor-download-allow-sameorigin.html [ Skip ]
 webkit.org/b/156067 http/tests/security/anchor-download-block-crossorigin.html [ Skip ]
 webkit.org/b/156067 http/tests/download/anchor-download-no-value.html [ Skip ]
+webkit.org/b/156067 http/tests/download/convert-cached-load-to-download.html [ Skip ]
 
 webkit.org/b/149087 http/tests/cache/disk-cache/disk-cache-vary.html [ Pass Timeout ]
 webkit.org/b/149087 http/tests/cache/disk-cache/disk-cache-vary-no-body.html [ Pass Timeout ]

Modified: trunk/LayoutTests/platform/mac-wk1/TestExpectations (234775 => 234776)


--- trunk/LayoutTests/platform/mac-wk1/TestExpectations	2018-08-10 22:59:56 UTC (rev 234775)
+++ trunk/LayoutTests/platform/mac-wk1/TestExpectations	2018-08-10 23:03:25 UTC (rev 234776)
@@ -331,6 +331,7 @@
 # testRunner.setShouldDownloadUndisplayableMIMETypes() is not supported on WK1.
 fast/dom/HTMLAnchorElement/anchor-file-blob-convert-to-download.html [ Skip ]
 fast/dom/HTMLAnchorElement/anchor-file-blob-convert-to-download-async-delegate.html [ Skip ]
+http/tests/download/convert-cached-load-to-download.html [ Skip ]
 
 webkit.org/b/156629 imported/w3c/web-platform-tests/html/semantics/embedded-content/the-img-element/sizes/parse-a-sizes-attribute.html [ Pass Failure ]
 

Modified: trunk/Source/WebKit/ChangeLog (234775 => 234776)


--- trunk/Source/WebKit/ChangeLog	2018-08-10 22:59:56 UTC (rev 234775)
+++ trunk/Source/WebKit/ChangeLog	2018-08-10 23:03:25 UTC (rev 234776)
@@ -1,3 +1,18 @@
+2018-08-10  Chris Dumez  <[email protected]>
+
+        Crash under NetworkResourceLoader::convertToDownload()
+        https://bugs.webkit.org/show_bug.cgi?id=188479
+        <rdar://problem/42201724>
+
+        Reviewed by Alex Christensen.
+
+        In NetworkResourceLoader::convertToDownload(), if m_networkLoad is null then we're trying
+        to convert a load that came from the disk cache. Since we do not currently support converting
+        such a load, cancel the current load and start a fresh download.
+
+        * NetworkProcess/NetworkResourceLoader.cpp:
+        (WebKit::NetworkResourceLoader::convertToDownload):
+
 2018-08-10  Sihui Liu  <[email protected]>
 
         Incorrect log message in NetworkSession when creating NetworkDataTask

Modified: trunk/Source/WebKit/NetworkProcess/NetworkResourceLoader.cpp (234775 => 234776)


--- trunk/Source/WebKit/NetworkProcess/NetworkResourceLoader.cpp	2018-08-10 22:59:56 UTC (rev 234775)
+++ trunk/Source/WebKit/NetworkProcess/NetworkResourceLoader.cpp	2018-08-10 23:03:25 UTC (rev 234776)
@@ -337,7 +337,13 @@
 
 void NetworkResourceLoader::convertToDownload(DownloadID downloadID, const ResourceRequest& request, const ResourceResponse& response)
 {
-    ASSERT(m_networkLoad);
+    // This can happen if the resource came from the disk cache.
+    if (!m_networkLoad) {
+        NetworkProcess::singleton().downloadManager().startDownload(m_connection.ptr(), m_parameters.sessionID, downloadID, request);
+        abort();
+        return;
+    }
+
     NetworkProcess::singleton().downloadManager().convertNetworkLoadToDownload(downloadID, std::exchange(m_networkLoad, nullptr), WTFMove(m_fileReferences), request, response);
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to