Title: [271338] branches/safari-610.4.3.1-branch
Revision
271338
Author
[email protected]
Date
2021-01-08 17:54:03 -0800 (Fri, 08 Jan 2021)

Log Message

Cherry-pick r271337. rdar://problem/72941242

    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.

    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@271337 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Modified Paths

Added Paths

Diff

Modified: branches/safari-610.4.3.1-branch/LayoutTests/ChangeLog (271337 => 271338)


--- branches/safari-610.4.3.1-branch/LayoutTests/ChangeLog	2021-01-09 01:49:38 UTC (rev 271337)
+++ branches/safari-610.4.3.1-branch/LayoutTests/ChangeLog	2021-01-09 01:54:03 UTC (rev 271338)
@@ -1,3 +1,42 @@
+2021-01-08  Russell Epstein  <[email protected]>
+
+        Cherry-pick r271337. rdar://problem/72941242
+
+    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.
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@271337 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    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.
+
 2020-12-15  Alan Coon  <[email protected]>
 
         Cherry-pick r266695. rdar://problem/72356057

Added: branches/safari-610.4.3.1-branch/LayoutTests/http/tests/loading/blob-load-fail-expected.txt (0 => 271338)


--- branches/safari-610.4.3.1-branch/LayoutTests/http/tests/loading/blob-load-fail-expected.txt	                        (rev 0)
+++ branches/safari-610.4.3.1-branch/LayoutTests/http/tests/loading/blob-load-fail-expected.txt	2021-01-09 01:54:03 UTC (rev 271338)
@@ -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: branches/safari-610.4.3.1-branch/LayoutTests/http/tests/loading/blob-load-fail.html (0 => 271338)


--- branches/safari-610.4.3.1-branch/LayoutTests/http/tests/loading/blob-load-fail.html	                        (rev 0)
+++ branches/safari-610.4.3.1-branch/LayoutTests/http/tests/loading/blob-load-fail.html	2021-01-09 01:54:03 UTC (rev 271338)
@@ -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: branches/safari-610.4.3.1-branch/LayoutTests/http/tests/loading/resources/remote-blob.php (0 => 271338)


--- branches/safari-610.4.3.1-branch/LayoutTests/http/tests/loading/resources/remote-blob.php	                        (rev 0)
+++ branches/safari-610.4.3.1-branch/LayoutTests/http/tests/loading/resources/remote-blob.php	2021-01-09 01:54:03 UTC (rev 271338)
@@ -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: branches/safari-610.4.3.1-branch/Source/WebCore/ChangeLog (271337 => 271338)


--- branches/safari-610.4.3.1-branch/Source/WebCore/ChangeLog	2021-01-09 01:49:38 UTC (rev 271337)
+++ branches/safari-610.4.3.1-branch/Source/WebCore/ChangeLog	2021-01-09 01:54:03 UTC (rev 271338)
@@ -1,3 +1,46 @@
+2021-01-08  Russell Epstein  <[email protected]>
+
+        Cherry-pick r271337. rdar://problem/72941242
+
+    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.
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@271337 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    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:
+
 2020-12-21  Alan Coon  <[email protected]>
 
         Cherry-pick r270580. rdar://problem/72552978

Modified: branches/safari-610.4.3.1-branch/Source/WebCore/fileapi/Blob.cpp (271337 => 271338)


--- branches/safari-610.4.3.1-branch/Source/WebCore/fileapi/Blob.cpp	2021-01-09 01:49:38 UTC (rev 271337)
+++ branches/safari-610.4.3.1-branch/Source/WebCore/fileapi/Blob.cpp	2021-01-09 01:54:03 UTC (rev 271338)
@@ -199,35 +199,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: branches/safari-610.4.3.1-branch/Source/WebCore/fileapi/Blob.h (271337 => 271338)


--- branches/safari-610.4.3.1-branch/Source/WebCore/fileapi/Blob.h	2021-01-09 01:49:38 UTC (rev 271337)
+++ branches/safari-610.4.3.1-branch/Source/WebCore/fileapi/Blob.h	2021-01-09 01:54:03 UTC (rev 271338)
@@ -143,7 +143,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