Title: [265748] trunk
Revision
265748
Author
[email protected]
Date
2020-08-17 00:31:01 -0700 (Mon, 17 Aug 2020)

Log Message

Make sure writableStreamDefaultWriterEnsureClosedPromiseRejected overwrite the closedPromise if needed
https://bugs.webkit.org/show_bug.cgi?id=215540

Reviewed by Darin Adler.

LayoutTests/imported/w3c:

* web-platform-tests/streams/writable-streams/aborting.any-expected.txt:
* web-platform-tests/streams/writable-streams/aborting.any.worker-expected.txt:

Source/WebCore:

Covered by rebased tests.

* Modules/streams/WritableStreamInternals.js:
(writableStreamDefaultWriterEnsureClosedPromiseRejected):
As per spec, if promise is already settled, we overwrite it to reject it.

Modified Paths

Diff

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (265747 => 265748)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2020-08-17 07:26:46 UTC (rev 265747)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2020-08-17 07:31:01 UTC (rev 265748)
@@ -1,5 +1,15 @@
 2020-08-17  Youenn Fablet  <[email protected]>
 
+        Make sure writableStreamDefaultWriterEnsureClosedPromiseRejected overwrite the closedPromise if needed
+        https://bugs.webkit.org/show_bug.cgi?id=215540
+
+        Reviewed by Darin Adler.
+
+        * web-platform-tests/streams/writable-streams/aborting.any-expected.txt:
+        * web-platform-tests/streams/writable-streams/aborting.any.worker-expected.txt:
+
+2020-08-17  Youenn Fablet  <[email protected]>
+
         Check WritableStream underlyingSink methods
         https://bugs.webkit.org/show_bug.cgi?id=215539
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/streams/writable-streams/aborting.any-expected.txt (265747 => 265748)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/streams/writable-streams/aborting.any-expected.txt	2020-08-17 07:26:46 UTC (rev 265747)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/streams/writable-streams/aborting.any-expected.txt	2020-08-17 07:31:01 UTC (rev 265748)
@@ -29,17 +29,11 @@
 PASS if a writer is created for a stream with a pending abort, its ready should be rejected with the abort error 
 PASS writer close() promise should resolve before abort() promise 
 PASS writer.ready should reject on controller error without waiting for underlying write 
-FAIL writer.abort() while there is an in-flight write, and then finish the write with rejection promise_rejects_js: writer.closed must be rejected with an error indicating release function "function () { throw e }" threw object "error1: error1" ("error1") expected instance of function "function TypeError() {
-    [native code]
-}" ("TypeError")
-FAIL writer.abort(), controller.error() while there is an in-flight write, and then finish the write promise_rejects_js: writer.closed must be rejected with an error indicating release function "function () { throw e }" threw object "error1: error1" ("error1") expected instance of function "function TypeError() {
-    [native code]
-}" ("TypeError")
-FAIL writer.abort(), controller.error() while there is an in-flight close, and then finish the close assert_unreached: Should have rejected: writer.closed must be rejected with an error indicating release Reached unreachable code
-FAIL controller.error(), writer.abort() while there is an in-flight write, and then finish the write promise_rejects_js: writer.closed must be rejected with an error indicating release function "function () { throw e }" threw object "error2: error2" ("error2") expected instance of function "function TypeError() {
-    [native code]
-}" ("TypeError")
-FAIL controller.error(), writer.abort() while there is an in-flight close, and then finish the close assert_unreached: Should have rejected: writer.closed must be rejected with an error indicating release Reached unreachable code
+PASS writer.abort() while there is an in-flight write, and then finish the write with rejection 
+PASS writer.abort(), controller.error() while there is an in-flight write, and then finish the write 
+PASS writer.abort(), controller.error() while there is an in-flight close, and then finish the close 
+PASS controller.error(), writer.abort() while there is an in-flight write, and then finish the write 
+PASS controller.error(), writer.abort() while there is an in-flight close, and then finish the close 
 PASS releaseLock() while aborting should reject the original closed promise 
 PASS releaseLock() during delayed async abort() should reject the writer.closed promise 
 PASS sink abort() should not be called until sink start() is done 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/streams/writable-streams/aborting.any.worker-expected.txt (265747 => 265748)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/streams/writable-streams/aborting.any.worker-expected.txt	2020-08-17 07:26:46 UTC (rev 265747)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/streams/writable-streams/aborting.any.worker-expected.txt	2020-08-17 07:31:01 UTC (rev 265748)
@@ -29,17 +29,11 @@
 PASS if a writer is created for a stream with a pending abort, its ready should be rejected with the abort error 
 PASS writer close() promise should resolve before abort() promise 
 PASS writer.ready should reject on controller error without waiting for underlying write 
-FAIL writer.abort() while there is an in-flight write, and then finish the write with rejection promise_rejects_js: writer.closed must be rejected with an error indicating release function "function () { throw e }" threw object "error1: error1" ("error1") expected instance of function "function TypeError() {
-    [native code]
-}" ("TypeError")
-FAIL writer.abort(), controller.error() while there is an in-flight write, and then finish the write promise_rejects_js: writer.closed must be rejected with an error indicating release function "function () { throw e }" threw object "error1: error1" ("error1") expected instance of function "function TypeError() {
-    [native code]
-}" ("TypeError")
-FAIL writer.abort(), controller.error() while there is an in-flight close, and then finish the close assert_unreached: Should have rejected: writer.closed must be rejected with an error indicating release Reached unreachable code
-FAIL controller.error(), writer.abort() while there is an in-flight write, and then finish the write promise_rejects_js: writer.closed must be rejected with an error indicating release function "function () { throw e }" threw object "error2: error2" ("error2") expected instance of function "function TypeError() {
-    [native code]
-}" ("TypeError")
-FAIL controller.error(), writer.abort() while there is an in-flight close, and then finish the close assert_unreached: Should have rejected: writer.closed must be rejected with an error indicating release Reached unreachable code
+PASS writer.abort() while there is an in-flight write, and then finish the write with rejection 
+PASS writer.abort(), controller.error() while there is an in-flight write, and then finish the write 
+PASS writer.abort(), controller.error() while there is an in-flight close, and then finish the close 
+PASS controller.error(), writer.abort() while there is an in-flight write, and then finish the write 
+PASS controller.error(), writer.abort() while there is an in-flight close, and then finish the close 
 PASS releaseLock() while aborting should reject the original closed promise 
 PASS releaseLock() during delayed async abort() should reject the writer.closed promise 
 PASS sink abort() should not be called until sink start() is done 

Modified: trunk/Source/WebCore/ChangeLog (265747 => 265748)


--- trunk/Source/WebCore/ChangeLog	2020-08-17 07:26:46 UTC (rev 265747)
+++ trunk/Source/WebCore/ChangeLog	2020-08-17 07:31:01 UTC (rev 265748)
@@ -1,5 +1,18 @@
 2020-08-17  Youenn Fablet  <[email protected]>
 
+        Make sure writableStreamDefaultWriterEnsureClosedPromiseRejected overwrite the closedPromise if needed
+        https://bugs.webkit.org/show_bug.cgi?id=215540
+
+        Reviewed by Darin Adler.
+
+        Covered by rebased tests.
+
+        * Modules/streams/WritableStreamInternals.js:
+        (writableStreamDefaultWriterEnsureClosedPromiseRejected):
+        As per spec, if promise is already settled, we overwrite it to reject it.
+
+2020-08-17  Youenn Fablet  <[email protected]>
+
         Check WritableStream underlyingSink methods
         https://bugs.webkit.org/show_bug.cgi?id=215539
 

Modified: trunk/Source/WebCore/Modules/streams/WritableStreamInternals.js (265747 => 265748)


--- trunk/Source/WebCore/Modules/streams/WritableStreamInternals.js	2020-08-17 07:26:46 UTC (rev 265747)
+++ trunk/Source/WebCore/Modules/streams/WritableStreamInternals.js	2020-08-17 07:31:01 UTC (rev 265748)
@@ -381,9 +381,17 @@
 
 function writableStreamDefaultWriterEnsureClosedPromiseRejected(writer, error)
 {
-     const closedPromise = @getByIdDirectPrivate(writer, "closedPromise");
-     closedPromise.@reject.@call(@undefined, error);
-     @putPromiseInternalField(closedPromise.@promise, @promiseFieldFlags, @getPromiseInternalField(closedPromise.@promise, @promiseFieldFlags) | @promiseFlagsIsHandled);
+    let closedPromiseCapability = @getByIdDirectPrivate(writer, "closedPromise");
+    let closedPromise = closedPromiseCapability.@promise;
+
+    if ((@getPromiseInternalField(closedPromise, @promiseFieldFlags) & @promiseStateMask) !== @promiseStatePending) {
+        closedPromiseCapability = @newPromiseCapability(@Promise);
+        closedPromise = closedPromiseCapability.@promise;
+        @putByIdDirectPrivate(writer, "closedPromise", closedPromiseCapability);
+    }
+
+    closedPromiseCapability.@reject.@call(@undefined, error);
+    @putPromiseInternalField(closedPromise, @promiseFieldFlags, @getPromiseInternalField(closedPromise, @promiseFieldFlags) | @promiseFlagsIsHandled);
 }
 
 function writableStreamDefaultWriterEnsureReadyPromiseRejected(writer, error)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to