Title: [271337] trunk
Revision
271337
Author
[email protected]
Date
2021-01-08 17:49:38 -0800 (Fri, 08 Jan 2021)

Log Message

BlobLoader lifetime cleanup.
<rdar://problem/70498831> and https://bugs.webkit.org/show_bug.cgi?id=220486

Reviewed by Chris Dumez.

Source/WebCore:

Test: LayoutTests/http/tests/loading/blob-load-fail.html

* fileapi/Blob.cpp:
(WebCore::Blob::loadBlob):
(WebCore::Blob::text):
(WebCore::Blob::arrayBuffer):
* fileapi/Blob.h:

LayoutTests:

* http/tests/loading/blob-load-fail-expected.txt: Added.
* http/tests/loading/blob-load-fail.html: Added.
* http/tests/loading/resources/remote-blob.php: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (271336 => 271337)


--- trunk/LayoutTests/ChangeLog	2021-01-09 01:19:15 UTC (rev 271336)
+++ trunk/LayoutTests/ChangeLog	2021-01-09 01:49:38 UTC (rev 271337)
@@ -1,3 +1,14 @@
+2021-01-08  Brady Eidson  <[email protected]>
+
+        BlobLoader lifetime cleanup.
+        <rdar://problem/70498831> and https://bugs.webkit.org/show_bug.cgi?id=220486
+
+        Reviewed by Chris Dumez.
+
+        * http/tests/loading/blob-load-fail-expected.txt: Added.
+        * http/tests/loading/blob-load-fail.html: Added.
+        * http/tests/loading/resources/remote-blob.php: Added.
+
 2021-01-08  Ryan Haddad  <[email protected]>
 
         [ Big Sur ] imported/w3c/web-platform-tests/mimesniff/mime-types/charset-parameter.window.html if failing

Added: trunk/LayoutTests/http/tests/loading/blob-load-fail-expected.txt (0 => 271337)


--- trunk/LayoutTests/http/tests/loading/blob-load-fail-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/http/tests/loading/blob-load-fail-expected.txt	2021-01-09 01:49:38 UTC (rev 271337)
@@ -0,0 +1,12 @@
+main frame - didStartProvisionalLoadForFrame
+main frame - didCommitLoadForFrame
+CONSOLE MESSAGE: Error while parsing the 'sandbox' attribute: 'allow-downloads', 'allow-presentation' are invalid sandbox flags.
+main frame - didFinishDocumentLoadForFrame
+frame "<!--frame1-->" - didStartProvisionalLoadForFrame
+frame "<!--frame1-->" - didCommitLoadForFrame
+frame "<!--frame1-->" - didFinishLoadForFrame
+main frame - didFinishLoadForFrame
+frame "<!--frame1-->" - didFinishDocumentLoadForFrame
+frame "<!--frame1-->" - didHandleOnloadEventsForFrame
+main frame - didHandleOnloadEventsForFrame
+

Added: trunk/LayoutTests/http/tests/loading/blob-load-fail.html (0 => 271337)


--- trunk/LayoutTests/http/tests/loading/blob-load-fail.html	                        (rev 0)
+++ trunk/LayoutTests/http/tests/loading/blob-load-fail.html	2021-01-09 01:49:38 UTC (rev 271337)
@@ -0,0 +1,34 @@
+<head>
+<script>
+if (window.testRunner) {
+    testRunner.waitUntilDone();
+    testRunner.dumpAsText();
+}
+</script>
+</head>
+<body class="">
+<div id="result-iframe-wrap" role="main">
+<iframe id="result" srcdoc="
+<!DOCTYPE html>
+<body translate=&quot;no&quot; >
+<script id=&quot;rendered-js&quot; type=&quot;module&quot;>
+    
+(async function () {
+    const req = await fetch('https://localhost:8443/loading/resources/remote-blob.php');
+
+    const blob = await req.blob();
+    const blob2 = blob.slice(5000, 10000);
+    blob2.arrayBuffer();
+    if (window.testRunner)
+        testRunner.notifyDone();
+})();
+</script>
+
+ 
+</body>
+ 
+"
+sandbox="allow-downloads allow-forms allow-modals allow-pointer-lock allow-popups allow-presentation  allow-scripts allow-top-navigation-by-user-activation" allow="accelerometer; ambient-light-sensor; camera; encrypted-media; geolocation; gyroscope; microphone; midi; payment; vr" allowtransparency="true" allowpaymentrequest="true" allowfullscreen="true" class="result-iframe">
+</iframe>
+</div>
+</body>

Added: trunk/LayoutTests/http/tests/loading/resources/remote-blob.php (0 => 271337)


--- trunk/LayoutTests/http/tests/loading/resources/remote-blob.php	                        (rev 0)
+++ trunk/LayoutTests/http/tests/loading/resources/remote-blob.php	2021-01-09 01:49:38 UTC (rev 271337)
@@ -0,0 +1,15 @@
+<?php
+$file = '../../resources/balls-of-the-orient.aif';
+
+if (file_exists($file)) {
+    header("Status: 200 OK");
+    header("HTTP/1.1 200 OK");
+    header("Access-Control-Allow-Origin: *");
+    header("Content-Type: audio/x-aiff");
+    header('Content-Length: ' . filesize($file));
+    ob_clean();
+    flush();
+    readfile($file);
+    exit;
+}
+?>
\ No newline at end of file

Modified: trunk/Source/WebCore/ChangeLog (271336 => 271337)


--- trunk/Source/WebCore/ChangeLog	2021-01-09 01:19:15 UTC (rev 271336)
+++ trunk/Source/WebCore/ChangeLog	2021-01-09 01:49:38 UTC (rev 271337)
@@ -1,3 +1,18 @@
+2021-01-08  Brady Eidson  <[email protected]>
+
+        BlobLoader lifetime cleanup.
+        <rdar://problem/70498831> and https://bugs.webkit.org/show_bug.cgi?id=220486
+
+        Reviewed by Chris Dumez.
+
+        Test: LayoutTests/http/tests/loading/blob-load-fail.html
+
+        * fileapi/Blob.cpp:
+        (WebCore::Blob::loadBlob):
+        (WebCore::Blob::text):
+        (WebCore::Blob::arrayBuffer):
+        * fileapi/Blob.h:
+
 2021-01-08  Peng Liu  <[email protected]>
 
         REGRESSION (r271273): Crash in WebCore::HTMLMediaElement::setVideoFullscreenGravity

Modified: trunk/Source/WebCore/fileapi/Blob.cpp (271336 => 271337)


--- trunk/Source/WebCore/fileapi/Blob.cpp	2021-01-09 01:19:15 UTC (rev 271336)
+++ trunk/Source/WebCore/fileapi/Blob.cpp	2021-01-09 01:49:38 UTC (rev 271337)
@@ -201,35 +201,38 @@
     return contentType.convertToASCIILowercase();
 }
 
-void Blob::loadBlob(ScriptExecutionContext& context, FileReaderLoader::ReadType readType, CompletionHandler<void(std::unique_ptr<BlobLoader>)>&& completionHandler)
+void Blob::loadBlob(ScriptExecutionContext& context, FileReaderLoader::ReadType readType, CompletionHandler<void(BlobLoader&)>&& completionHandler)
 {
     auto blobLoader = makeUnique<BlobLoader>([this, pendingActivity = makePendingActivity(*this), completionHandler = WTFMove(completionHandler)](BlobLoader& blobLoader) mutable {
-        completionHandler(m_blobLoaders.take(&blobLoader));
+        completionHandler(blobLoader);
+        m_blobLoaders.take(&blobLoader);
     });
-    auto* blobLoaderPtr = blobLoader.get();
-    m_blobLoaders.add(WTFMove(blobLoader));
-    blobLoaderPtr->start(*this, &context, readType);
+
+    blobLoader->start(*this, &context, readType);
+
+    if (blobLoader->isLoading())
+        m_blobLoaders.add(WTFMove(blobLoader));
 }
 
 void Blob::text(ScriptExecutionContext& context, Ref<DeferredPromise>&& promise)
 {
-    loadBlob(context, FileReaderLoader::ReadAsText, [promise = WTFMove(promise)](std::unique_ptr<BlobLoader> blobLoader) mutable {
-        if (auto optionalErrorCode = blobLoader->errorCode()) {
+    loadBlob(context, FileReaderLoader::ReadAsText, [promise = WTFMove(promise)](BlobLoader& blobLoader) mutable {
+        if (auto optionalErrorCode = blobLoader.errorCode()) {
             promise->reject(Exception { *optionalErrorCode });
             return;
         }
-        promise->resolve<IDLDOMString>(blobLoader->stringResult());
+        promise->resolve<IDLDOMString>(blobLoader.stringResult());
     });
 }
 
 void Blob::arrayBuffer(ScriptExecutionContext& context, Ref<DeferredPromise>&& promise)
 {
-    loadBlob(context, FileReaderLoader::ReadAsArrayBuffer, [promise = WTFMove(promise)](std::unique_ptr<BlobLoader> blobLoader) mutable {
-        if (auto optionalErrorCode = blobLoader->errorCode()) {
+    loadBlob(context, FileReaderLoader::ReadAsArrayBuffer, [promise = WTFMove(promise)](BlobLoader& blobLoader) mutable {
+        if (auto optionalErrorCode = blobLoader.errorCode()) {
             promise->reject(Exception { *optionalErrorCode });
             return;
         }
-        auto arrayBuffer = blobLoader->arrayBufferResult();
+        auto arrayBuffer = blobLoader.arrayBufferResult();
         if (!arrayBuffer) {
             promise->reject(Exception { InvalidStateError });
             return;

Modified: trunk/Source/WebCore/fileapi/Blob.h (271336 => 271337)


--- trunk/Source/WebCore/fileapi/Blob.h	2021-01-09 01:19:15 UTC (rev 271336)
+++ trunk/Source/WebCore/fileapi/Blob.h	2021-01-09 01:49:38 UTC (rev 271337)
@@ -147,7 +147,7 @@
     Blob(ScriptExecutionContext*, const URL& srcURL, long long start, long long end, const String& contentType);
 
 private:
-    void loadBlob(ScriptExecutionContext&, FileReaderLoader::ReadType, CompletionHandler<void(std::unique_ptr<BlobLoader>)>&&);
+    void loadBlob(ScriptExecutionContext&, FileReaderLoader::ReadType, CompletionHandler<void(BlobLoader&)>&&);
 
     // ActiveDOMObject.
     const char* activeDOMObjectName() const override;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to