Title: [279567] trunk
Revision
279567
Author
[email protected]
Date
2021-07-05 07:34:20 -0700 (Mon, 05 Jul 2021)

Log Message

Use AbortSignal's [PrivateIdentifier] whenSignalAborted() static method
https://bugs.webkit.org/show_bug.cgi?id=227673

Reviewed by Youenn Fablet.

LayoutTests/imported/w3c:

* web-platform-tests/streams/piping/abort.any-expected.txt:
* web-platform-tests/streams/piping/abort.any.worker-expected.txt:
* web-platform-tests/streams/piping/pipe-through.any-expected.txt:
* web-platform-tests/streams/piping/pipe-through.any.worker-expected.txt:

Source/WebCore:

Enabled by refactoring in r279546, this change removes handcrafted @whenSignalAborted()
global function in favor of using equivalent generated [PrivateIdentifier] static method.

The generated method checks its arguments more strictly (as per WebIDL spec):
a TypeError is thrown for invalid AbortSignal argument, which progresses the WPT.

Test: imported/w3c/web-platform-tests/streams/piping/pipe-through.any.js

* Modules/streams/ReadableStreamInternals.js:
(readableStreamPipeToWritableStream):
* bindings/js/JSDOMGlobalObject.cpp:
(WebCore::JSDOMGlobalObject::addBuiltinGlobals):

Modified Paths

Diff

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (279566 => 279567)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2021-07-05 11:48:53 UTC (rev 279566)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2021-07-05 14:34:20 UTC (rev 279567)
@@ -1,3 +1,15 @@
+2021-07-05  Alexey Shvayka  <[email protected]>
+
+        Use AbortSignal's [PrivateIdentifier] whenSignalAborted() static method
+        https://bugs.webkit.org/show_bug.cgi?id=227673
+
+        Reviewed by Youenn Fablet.
+
+        * web-platform-tests/streams/piping/abort.any-expected.txt:
+        * web-platform-tests/streams/piping/abort.any.worker-expected.txt:
+        * web-platform-tests/streams/piping/pipe-through.any-expected.txt:
+        * web-platform-tests/streams/piping/pipe-through.any.worker-expected.txt:
+
 2021-07-04  Rob Buis  <[email protected]>
 
         Resync web-platform-tests/css/css-sizing/aspect-ratio from upstream

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/streams/piping/abort.any-expected.txt (279566 => 279567)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/streams/piping/abort.any-expected.txt	2021-07-05 11:48:53 UTC (rev 279566)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/streams/piping/abort.any-expected.txt	2021-07-05 14:34:20 UTC (rev 279567)
@@ -5,7 +5,7 @@
 PASS a signal argument 'AbortSignal' should cause pipeTo() to reject
 PASS a signal argument 'true' should cause pipeTo() to reject
 PASS a signal argument '-1' should cause pipeTo() to reject
-FAIL a signal argument '[object AbortSignal]' should cause pipeTo() to reject promise_rejects_js: pipeTo should reject function "function () { throw e }" threw "failed to abort" with type "string", not an object
+FAIL a signal argument '[object AbortSignal]' should cause pipeTo() to reject Argument 1 ('object') to AbortSignal.whenSignalAborted must be an instance of AbortSignal
 PASS an aborted signal should cause the writable stream to reject with an AbortError
 PASS all the AbortError objects should be the same object
 PASS preventCancel should prevent canceling the readable

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/streams/piping/abort.any.worker-expected.txt (279566 => 279567)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/streams/piping/abort.any.worker-expected.txt	2021-07-05 11:48:53 UTC (rev 279566)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/streams/piping/abort.any.worker-expected.txt	2021-07-05 14:34:20 UTC (rev 279567)
@@ -5,7 +5,7 @@
 PASS a signal argument 'AbortSignal' should cause pipeTo() to reject
 PASS a signal argument 'true' should cause pipeTo() to reject
 PASS a signal argument '-1' should cause pipeTo() to reject
-FAIL a signal argument '[object AbortSignal]' should cause pipeTo() to reject promise_rejects_js: pipeTo should reject function "function () { throw e }" threw "failed to abort" with type "string", not an object
+FAIL a signal argument '[object AbortSignal]' should cause pipeTo() to reject Argument 1 ('object') to AbortSignal.whenSignalAborted must be an instance of AbortSignal
 PASS an aborted signal should cause the writable stream to reject with an AbortError
 PASS all the AbortError objects should be the same object
 PASS preventCancel should prevent canceling the readable

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/streams/piping/pipe-through.any-expected.txt (279566 => 279567)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/streams/piping/pipe-through.any-expected.txt	2021-07-05 11:48:53 UTC (rev 279566)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/streams/piping/pipe-through.any-expected.txt	2021-07-05 14:34:20 UTC (rev 279567)
@@ -32,7 +32,7 @@
 PASS invalid values of signal should throw; specifically 'NaN'
 PASS invalid values of signal should throw; specifically 'true'
 PASS invalid values of signal should throw; specifically 'AbortSignal'
-FAIL invalid values of signal should throw; specifically '[object AbortSignal]' assert_throws_js: pipeThrough should throw function "() => rs.pipeThrough(uninterestingReadableWritablePair(), { signal })" did not throw
+PASS invalid values of signal should throw; specifically '[object AbortSignal]'
 PASS pipeThrough should accept a real AbortSignal
 PASS pipeThrough should throw if this is locked
 PASS pipeThrough should throw if writable is locked

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/streams/piping/pipe-through.any.worker-expected.txt (279566 => 279567)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/streams/piping/pipe-through.any.worker-expected.txt	2021-07-05 11:48:53 UTC (rev 279566)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/streams/piping/pipe-through.any.worker-expected.txt	2021-07-05 14:34:20 UTC (rev 279567)
@@ -32,7 +32,7 @@
 PASS invalid values of signal should throw; specifically 'NaN'
 PASS invalid values of signal should throw; specifically 'true'
 PASS invalid values of signal should throw; specifically 'AbortSignal'
-FAIL invalid values of signal should throw; specifically '[object AbortSignal]' assert_throws_js: pipeThrough should throw function "() => rs.pipeThrough(uninterestingReadableWritablePair(), { signal })" did not throw
+PASS invalid values of signal should throw; specifically '[object AbortSignal]'
 PASS pipeThrough should accept a real AbortSignal
 PASS pipeThrough should throw if this is locked
 PASS pipeThrough should throw if writable is locked

Modified: trunk/Source/WebCore/ChangeLog (279566 => 279567)


--- trunk/Source/WebCore/ChangeLog	2021-07-05 11:48:53 UTC (rev 279566)
+++ trunk/Source/WebCore/ChangeLog	2021-07-05 14:34:20 UTC (rev 279567)
@@ -1,3 +1,23 @@
+2021-07-05  Alexey Shvayka  <[email protected]>
+
+        Use AbortSignal's [PrivateIdentifier] whenSignalAborted() static method
+        https://bugs.webkit.org/show_bug.cgi?id=227673
+
+        Reviewed by Youenn Fablet.
+
+        Enabled by refactoring in r279546, this change removes handcrafted @whenSignalAborted()
+        global function in favor of using equivalent generated [PrivateIdentifier] static method.
+
+        The generated method checks its arguments more strictly (as per WebIDL spec):
+        a TypeError is thrown for invalid AbortSignal argument, which progresses the WPT.
+
+        Test: imported/w3c/web-platform-tests/streams/piping/pipe-through.any.js
+
+        * Modules/streams/ReadableStreamInternals.js:
+        (readableStreamPipeToWritableStream):
+        * bindings/js/JSDOMGlobalObject.cpp:
+        (WebCore::JSDOMGlobalObject::addBuiltinGlobals):
+
 2021-07-05  Martin Robinson  <[email protected]>
 
         [css-scroll-snap] Triggering a layout during scroll causes jittery scrolling on Mac when dragging the scrollbar

Modified: trunk/Source/WebCore/Modules/streams/ReadableStreamInternals.js (279566 => 279567)


--- trunk/Source/WebCore/Modules/streams/ReadableStreamInternals.js	2021-07-05 11:48:53 UTC (rev 279566)
+++ trunk/Source/WebCore/Modules/streams/ReadableStreamInternals.js	2021-07-05 14:34:20 UTC (rev 279567)
@@ -194,7 +194,7 @@
                 return promiseCapability.@promise;
             }, error);
         };
-        if (@whenSignalAborted(signal, algorithm))
+        if (@AbortSignal.@whenSignalAborted(signal, algorithm))
             return pipeState.promiseCapability.@promise;
     }
 

Modified: trunk/Source/WebCore/bindings/js/JSDOMGlobalObject.cpp (279566 => 279567)


--- trunk/Source/WebCore/bindings/js/JSDOMGlobalObject.cpp	2021-07-05 11:48:53 UTC (rev 279566)
+++ trunk/Source/WebCore/bindings/js/JSDOMGlobalObject.cpp	2021-07-05 14:34:20 UTC (rev 279567)
@@ -31,7 +31,6 @@
 #include "DOMWindow.h"
 #include "Document.h"
 #include "FetchResponse.h"
-#include "JSAbortAlgorithm.h"
 #include "JSAbortSignal.h"
 #include "JSDOMPromiseDeferred.h"
 #include "JSDOMWindow.h"
@@ -72,7 +71,6 @@
 JSC_DECLARE_HOST_FUNCTION(makeDOMExceptionForBuiltins);
 JSC_DECLARE_HOST_FUNCTION(isReadableByteStreamAPIEnabled);
 JSC_DECLARE_HOST_FUNCTION(isWritableStreamAPIEnabled);
-JSC_DECLARE_HOST_FUNCTION(whenSignalAborted);
 
 const ClassInfo JSDOMGlobalObject::s_info = { "DOMGlobalObject", &JSGlobalObject::s_info, nullptr, nullptr, CREATE_METHOD_TABLE(JSDOMGlobalObject) };
 
@@ -162,23 +160,6 @@
     return JSValue::encode(jsBoolean(RuntimeEnabledFeatures::sharedFeatures().writableStreamAPIEnabled()));
 }
 
-JSC_DEFINE_HOST_FUNCTION(whenSignalAborted, (JSGlobalObject* globalObject, CallFrame* callFrame))
-{
-    ASSERT(callFrame);
-    ASSERT(callFrame->argumentCount() == 2);
-
-    auto& vm = globalObject->vm();
-    auto* abortSignal = jsDynamicCast<JSAbortSignal*>(vm, callFrame->uncheckedArgument(0));
-    if (UNLIKELY(!abortSignal))
-        return JSValue::encode(JSValue(JSC::JSValue::JSFalse));
-
-    auto* jsDOMGlobalObject = JSC::jsCast<JSDOMGlobalObject*>(globalObject);
-    Ref<AbortAlgorithm> abortAlgorithm = JSAbortAlgorithm::create(callFrame->uncheckedArgument(1).getObject(), jsDOMGlobalObject);
-
-    bool result = AbortSignal::whenSignalAborted(abortSignal->wrapped(), WTFMove(abortAlgorithm));
-    return JSValue::encode(result ? JSValue(JSC::JSValue::JSTrue) : JSValue(JSC::JSValue::JSFalse));
-}
-
 SUPPRESS_ASAN void JSDOMGlobalObject::addBuiltinGlobals(VM& vm)
 {
     m_builtinInternalFunctions.initialize(*this);
@@ -191,8 +172,6 @@
             JSFunction::create(vm, this, 2, String(), makeGetterTypeErrorForBuiltins), PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly),
         JSDOMGlobalObject::GlobalPropertyInfo(clientData.builtinNames().makeDOMExceptionPrivateName(),
             JSFunction::create(vm, this, 2, String(), makeDOMExceptionForBuiltins), PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly),
-        JSDOMGlobalObject::GlobalPropertyInfo(clientData.builtinNames().whenSignalAbortedPrivateName(),
-            JSFunction::create(vm, this, 2, String(), whenSignalAborted), PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly),
         JSDOMGlobalObject::GlobalPropertyInfo(clientData.builtinNames().cloneArrayBufferPrivateName(),
             JSFunction::create(vm, this, 3, String(), cloneArrayBuffer), PropertyAttribute::DontDelete | PropertyAttribute::ReadOnly),
         JSDOMGlobalObject::GlobalPropertyInfo(clientData.builtinNames().structuredCloneArrayBufferPrivateName(),
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to