Title: [241137] trunk
Revision
241137
Author
[email protected]
Date
2019-02-07 12:14:58 -0800 (Thu, 07 Feb 2019)

Log Message

Unable to sign in leetcode.
https://bugs.webkit.org/show_bug.cgi?id=194366
rdar://problem/47259025.

Reviewed by Chris Dumez.

Source/WebCore:

In case a signal is passed as part of a FetchRequestInit,
the IDL binding code is throwing an exception in case signal is not an AbortSignal object.
This breaks an AbortSignal shim used in some web sites.
Relaxed the IDL binding rule by marking signal as any and doing the conversion in FetchRequest.

Test: http/wpt/fetch/request-abort.html
Also covered by manually signing in to leetcode.

* Modules/fetch/FetchRequest.cpp:
(WebCore::FetchRequest::initializeWith):
* Modules/fetch/FetchRequestInit.h:
(WebCore::FetchRequestInit::hasMembers const):
* Modules/fetch/FetchRequestInit.idl:

LayoutTests:

* http/wpt/fetch/request-abort-expected.txt: Added.
* http/wpt/fetch/request-abort.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (241136 => 241137)


--- trunk/LayoutTests/ChangeLog	2019-02-07 19:42:38 UTC (rev 241136)
+++ trunk/LayoutTests/ChangeLog	2019-02-07 20:14:58 UTC (rev 241137)
@@ -1,3 +1,14 @@
+2019-02-07  Youenn Fablet  <[email protected]>
+
+        Unable to sign in leetcode.
+        https://bugs.webkit.org/show_bug.cgi?id=194366
+        rdar://problem/47259025.
+
+        Reviewed by Chris Dumez.
+
+        * http/wpt/fetch/request-abort-expected.txt: Added.
+        * http/wpt/fetch/request-abort.html: Added.
+
 2019-02-07  Alex Christensen  <[email protected]>
 
         Deprecate WKBundlePageSetDefersLoading

Added: trunk/LayoutTests/http/wpt/fetch/request-abort-expected.txt (0 => 241137)


--- trunk/LayoutTests/http/wpt/fetch/request-abort-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/http/wpt/fetch/request-abort-expected.txt	2019-02-07 20:14:58 UTC (rev 241137)
@@ -0,0 +1,6 @@
+CONSOLE MESSAGE: line 14: FetchRequestInit.signal should be undefined, null or an AbortSignal object.
+CONSOLE MESSAGE: line 28: FetchRequestInit.signal should be undefined, null or an AbortSignal object.
+
+FAIL Request from URL with signal assert_throws: function "() => { new Request("/", {signal: "my signal"}) }" did not throw
+FAIL Request from request with signal assert_throws: function "() => { new Request(request, {signal: "my signal"}) }" did not throw
+

Added: trunk/LayoutTests/http/wpt/fetch/request-abort.html (0 => 241137)


--- trunk/LayoutTests/http/wpt/fetch/request-abort.html	                        (rev 0)
+++ trunk/LayoutTests/http/wpt/fetch/request-abort.html	2019-02-07 20:14:58 UTC (rev 241137)
@@ -0,0 +1,32 @@
+<!doctype html>
+<html>
+    <head>
+        <meta charset="utf-8">
+        <title>Request signal</title>
+        <script src=""
+        <script src=""
+    </head>
+    <body>
+        <script>
+test(() => {
+    new Request("/", {signal: null});
+    new Request("/", {signal: undefined});
+    assert_throws(new TypeError, () => { new Request("/", {signal: "my signal"}) });
+}, "Request from URL with signal");
+
+test(() => {
+    const controller = new AbortController();
+    const request = new Request("/", {signal : controller.signal});
+    controller.abort();
+
+    const r1 = new Request(request, {signal: undefined});
+    assert_true(r1.signal.aborted, "r1 signal is aborted");
+
+    const r2 = new Request(request, {signal: null});
+    assert_false(r2.signal.aborted, "r2 signal is not aborted");
+
+    assert_throws(new TypeError, () => { new Request(request, {signal: "my signal"}) });
+}, "Request from request with signal");
+        </script>
+    </body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (241136 => 241137)


--- trunk/Source/WebCore/ChangeLog	2019-02-07 19:42:38 UTC (rev 241136)
+++ trunk/Source/WebCore/ChangeLog	2019-02-07 20:14:58 UTC (rev 241137)
@@ -1,5 +1,27 @@
 2019-02-07  Youenn Fablet  <[email protected]>
 
+        Unable to sign in leetcode.
+        https://bugs.webkit.org/show_bug.cgi?id=194366
+        rdar://problem/47259025.
+
+        Reviewed by Chris Dumez.
+
+        In case a signal is passed as part of a FetchRequestInit,
+        the IDL binding code is throwing an exception in case signal is not an AbortSignal object.
+        This breaks an AbortSignal shim used in some web sites.
+        Relaxed the IDL binding rule by marking signal as any and doing the conversion in FetchRequest.
+
+        Test: http/wpt/fetch/request-abort.html
+        Also covered by manually signing in to leetcode.
+
+        * Modules/fetch/FetchRequest.cpp:
+        (WebCore::FetchRequest::initializeWith):
+        * Modules/fetch/FetchRequestInit.h:
+        (WebCore::FetchRequestInit::hasMembers const):
+        * Modules/fetch/FetchRequestInit.idl:
+
+2019-02-07  Youenn Fablet  <[email protected]>
+
         Make to clear sources from UserMediaCaptureManagerProxy and UserMediaCaptureManager when no longer needed
         https://bugs.webkit.org/show_bug.cgi?id=194312
 

Modified: trunk/Source/WebCore/Modules/fetch/FetchRequest.cpp (241136 => 241137)


--- trunk/Source/WebCore/Modules/fetch/FetchRequest.cpp	2019-02-07 19:42:38 UTC (rev 241136)
+++ trunk/Source/WebCore/Modules/fetch/FetchRequest.cpp	2019-02-07 20:14:58 UTC (rev 241137)
@@ -30,6 +30,7 @@
 #include "FetchRequest.h"
 
 #include "HTTPParsers.h"
+#include "JSAbortSignal.h"
 #include "ScriptExecutionContext.h"
 #include "SecurityOrigin.h"
 
@@ -159,8 +160,14 @@
     if (optionsResult.hasException())
         return optionsResult.releaseException();
 
-    if (init.signal && init.signal.value())
-        m_signal->follow(*init.signal.value());
+    if (init.signal) {
+        if (auto* signal = JSAbortSignal::toWrapped(scriptExecutionContext()->vm(), init.signal))
+            m_signal->follow(*signal);
+        else if (!init.signal.isUndefinedOrNull())  {
+            ASCIILiteral consoleMessage { "FetchRequestInit.signal should be undefined, null or an AbortSignal object."_s };
+            scriptExecutionContext()->addConsoleMessage(MessageSource::JS, MessageLevel::Warning, consoleMessage);
+        }
+    }
 
     if (init.headers) {
         auto fillResult = m_headers->fill(*init.headers);
@@ -191,11 +198,16 @@
     if (optionsResult.hasException())
         return optionsResult.releaseException();
 
-    if (init.signal) {
-        if (init.signal.value())
-            m_signal->follow(*init.signal.value());
+    if (init.signal && !init.signal.isUndefined()) {
+        if (auto* signal = JSAbortSignal::toWrapped(scriptExecutionContext()->vm(), init.signal))
+            m_signal->follow(*signal);
+        else if (!init.signal.isNull()) {
+            ASCIILiteral consoleMessage { "FetchRequestInit.signal should be undefined, null or an AbortSignal object."_s };
+            scriptExecutionContext()->addConsoleMessage(MessageSource::JS, MessageLevel::Warning, consoleMessage);
+        }
+
     } else
-        m_signal->follow(input.m_signal);
+        m_signal->follow(input.m_signal.get());
 
     if (init.headers) {
         auto fillResult = m_headers->fill(*init.headers);

Modified: trunk/Source/WebCore/Modules/fetch/FetchRequestInit.h (241136 => 241137)


--- trunk/Source/WebCore/Modules/fetch/FetchRequestInit.h	2019-02-07 19:42:38 UTC (rev 241136)
+++ trunk/Source/WebCore/Modules/fetch/FetchRequestInit.h	2019-02-07 20:14:58 UTC (rev 241137)
@@ -47,10 +47,10 @@
     Optional<FetchOptions::Redirect> redirect;
     String integrity;
     Optional<bool> keepalive;
-    Optional<AbortSignal*> signal;
+    JSC::JSValue signal;
     JSC::JSValue window;
 
-    bool hasMembers() const { return !method.isEmpty() || headers || body || !referrer.isEmpty() || referrerPolicy || mode || credentials || cache || redirect || !integrity.isEmpty() || keepalive || !window.isUndefined() || signal; }
+    bool hasMembers() const { return !method.isEmpty() || headers || body || !referrer.isEmpty() || referrerPolicy || mode || credentials || cache || redirect || !integrity.isEmpty() || keepalive || !window.isUndefined() || !signal.isUndefined(); }
 };
 
 }

Modified: trunk/Source/WebCore/Modules/fetch/FetchRequestInit.idl (241136 => 241137)


--- trunk/Source/WebCore/Modules/fetch/FetchRequestInit.idl	2019-02-07 19:42:38 UTC (rev 241136)
+++ trunk/Source/WebCore/Modules/fetch/FetchRequestInit.idl	2019-02-07 20:14:58 UTC (rev 241137)
@@ -39,6 +39,6 @@
     FetchRequestRedirect redirect;
     DOMString integrity;
     boolean keepalive;
-    AbortSignal? signal;
+    any signal;
     any window; // can only be set to null
 };
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to