Title: [273890] trunk
Revision
273890
Author
you...@apple.com
Date
2021-03-04 08:32:24 -0800 (Thu, 04 Mar 2021)

Log Message

Handle the case of synchronous failure in loading blob.
https://bugs.webkit.org/show_bug.cgi?id=222724

Reviewed by Carlos Garcia Campos.

Source/WebCore:

Test: http/tests/fetch/blob-in-unload-event-handler.html

* fileapi/Blob.cpp:
(WebCore::Blob::stream):
In case of synchronous failure, wait for the stream to be started to error it.

LayoutTests:

* http/tests/fetch/blob-in-unload-event-handler-expected.txt: Added.
* http/tests/fetch/blob-in-unload-event-handler.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (273889 => 273890)


--- trunk/LayoutTests/ChangeLog	2021-03-04 16:26:28 UTC (rev 273889)
+++ trunk/LayoutTests/ChangeLog	2021-03-04 16:32:24 UTC (rev 273890)
@@ -1,3 +1,13 @@
+2021-03-04  Youenn Fablet  <you...@apple.com>
+
+        Handle the case of synchronous failure in loading blob.
+        https://bugs.webkit.org/show_bug.cgi?id=222724
+
+        Reviewed by Carlos Garcia Campos.
+
+        * http/tests/fetch/blob-in-unload-event-handler-expected.txt: Added.
+        * http/tests/fetch/blob-in-unload-event-handler.html: Added.
+
 2021-03-04  Rob Buis  <rb...@igalia.com>
 
         Null check platformData when decoding

Added: trunk/LayoutTests/http/tests/fetch/blob-in-unload-event-handler-expected.txt (0 => 273890)


--- trunk/LayoutTests/http/tests/fetch/blob-in-unload-event-handler-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/http/tests/fetch/blob-in-unload-event-handler-expected.txt	2021-03-04 16:32:24 UTC (rev 273890)
@@ -0,0 +1,2 @@
+main frame - has 1 onunload handler(s)
+PASS

Added: trunk/LayoutTests/http/tests/fetch/blob-in-unload-event-handler.html (0 => 273890)


--- trunk/LayoutTests/http/tests/fetch/blob-in-unload-event-handler.html	                        (rev 0)
+++ trunk/LayoutTests/http/tests/fetch/blob-in-unload-event-handler.html	2021-03-04 16:32:24 UTC (rev 273890)
@@ -0,0 +1,26 @@
+<!doctype html><!-- webkit-test-runner [ dumpJSConsoleLogInStdErr=true ] -->
+<html>
+    <head>
+        <meta charset="utf-8">
+        <title>Blobs in unload event handler</title>
+    </head>
+    <body>
+<script>
+if (window.testRunner) {
+    testRunner.dumpAsText();
+    testRunner.waitUntilDone();
+}
+
+if (window.location.hash == '') {
+    _onunload_ = () => {
+        new File([], '').stream();
+    };
+    window.location = "?#finish";
+} else {
+    document.body.innerHTML = "PASS";
+    if (window.testRunner)
+        testRunner.notifyDone();
+}
+</script>
+    </body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (273889 => 273890)


--- trunk/Source/WebCore/ChangeLog	2021-03-04 16:26:28 UTC (rev 273889)
+++ trunk/Source/WebCore/ChangeLog	2021-03-04 16:32:24 UTC (rev 273890)
@@ -1,3 +1,16 @@
+2021-03-04  Youenn Fablet  <you...@apple.com>
+
+        Handle the case of synchronous failure in loading blob.
+        https://bugs.webkit.org/show_bug.cgi?id=222724
+
+        Reviewed by Carlos Garcia Campos.
+
+        Test: http/tests/fetch/blob-in-unload-event-handler.html
+
+        * fileapi/Blob.cpp:
+        (WebCore::Blob::stream):
+        In case of synchronous failure, wait for the stream to be started to error it.
+
 2021-03-04  Zalan Bujtas  <za...@apple.com>
 
         [LFC][IFC] LineBox::m_rootInlineBox does not need to be a UniqueRef

Modified: trunk/Source/WebCore/fileapi/Blob.cpp (273889 => 273890)


--- trunk/Source/WebCore/fileapi/Blob.cpp	2021-03-04 16:26:28 UTC (rev 273889)
+++ trunk/Source/WebCore/fileapi/Blob.cpp	2021-03-04 16:32:24 UTC (rev 273890)
@@ -255,7 +255,13 @@
         // ReadableStreamSource
         void setActive() final { }
         void setInactive() final { }
-        void doStart() final { }
+        void doStart() final
+        {
+            m_isStarted = true;
+            if (m_exception)
+                controller().error(*m_exception);
+        }
+
         void doPull() final { }
         void doCancel() final
         {
@@ -282,13 +288,20 @@
         {
             controller().close();
         }
-        void didFail(ExceptionCode exception) final
+        void didFail(ExceptionCode code) final
         {
-            controller().error(Exception { exception });
+            Exception exception { code };
+            if (!m_isStarted) {
+                m_exception = WTFMove(exception);
+                return;
+            }
+            controller().error(exception);
         }
 
         UniqueRef<FileReaderLoader> m_loader;
         size_t m_bytesRead { 0 };
+        bool m_isStarted { false };
+        Optional<Exception> m_exception;
     };
 
     auto* globalObject = scriptExecutionContext.globalObject();
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to