Title: [241164] branches/safari-607-branch
Revision
241164
Author
[email protected]
Date
2019-02-07 15:37:17 -0800 (Thu, 07 Feb 2019)

Log Message

Cherry-pick r241137. rdar://problem/47893603

    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.

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

Modified Paths

Added Paths

Diff

Modified: branches/safari-607-branch/LayoutTests/ChangeLog (241163 => 241164)


--- branches/safari-607-branch/LayoutTests/ChangeLog	2019-02-07 23:37:13 UTC (rev 241163)
+++ branches/safari-607-branch/LayoutTests/ChangeLog	2019-02-07 23:37:17 UTC (rev 241164)
@@ -1,5 +1,50 @@
 2019-02-07  Alan Coon  <[email protected]>
 
+        Cherry-pick r241137. rdar://problem/47893603
+
+    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.
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@241137 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    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  Alan Coon  <[email protected]>
+
         Cherry-pick r241105. rdar://problem/47893571
 
     [Payment Request] It should be possible to require a phonetic name for shipping contacts

Added: branches/safari-607-branch/LayoutTests/http/wpt/fetch/request-abort-expected.txt (0 => 241164)


--- branches/safari-607-branch/LayoutTests/http/wpt/fetch/request-abort-expected.txt	                        (rev 0)
+++ branches/safari-607-branch/LayoutTests/http/wpt/fetch/request-abort-expected.txt	2019-02-07 23:37:17 UTC (rev 241164)
@@ -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: branches/safari-607-branch/LayoutTests/http/wpt/fetch/request-abort.html (0 => 241164)


--- branches/safari-607-branch/LayoutTests/http/wpt/fetch/request-abort.html	                        (rev 0)
+++ branches/safari-607-branch/LayoutTests/http/wpt/fetch/request-abort.html	2019-02-07 23:37:17 UTC (rev 241164)
@@ -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: branches/safari-607-branch/Source/WebCore/ChangeLog (241163 => 241164)


--- branches/safari-607-branch/Source/WebCore/ChangeLog	2019-02-07 23:37:13 UTC (rev 241163)
+++ branches/safari-607-branch/Source/WebCore/ChangeLog	2019-02-07 23:37:17 UTC (rev 241164)
@@ -1,5 +1,61 @@
 2019-02-07  Alan Coon  <[email protected]>
 
+        Cherry-pick r241137. rdar://problem/47893603
+
+    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.
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@241137 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    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  Alan Coon  <[email protected]>
+
         Cherry-pick r241130. rdar://problem/47893594
 
     HTMLMediaElement registers wrong ScriptExecutionContext with its ActiveDOMObject parent class

Modified: branches/safari-607-branch/Source/WebCore/Modules/fetch/FetchRequest.cpp (241163 => 241164)


--- branches/safari-607-branch/Source/WebCore/Modules/fetch/FetchRequest.cpp	2019-02-07 23:37:13 UTC (rev 241163)
+++ branches/safari-607-branch/Source/WebCore/Modules/fetch/FetchRequest.cpp	2019-02-07 23:37:17 UTC (rev 241164)
@@ -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: branches/safari-607-branch/Source/WebCore/Modules/fetch/FetchRequestInit.h (241163 => 241164)


--- branches/safari-607-branch/Source/WebCore/Modules/fetch/FetchRequestInit.h	2019-02-07 23:37:13 UTC (rev 241163)
+++ branches/safari-607-branch/Source/WebCore/Modules/fetch/FetchRequestInit.h	2019-02-07 23:37:17 UTC (rev 241164)
@@ -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: branches/safari-607-branch/Source/WebCore/Modules/fetch/FetchRequestInit.idl (241163 => 241164)


--- branches/safari-607-branch/Source/WebCore/Modules/fetch/FetchRequestInit.idl	2019-02-07 23:37:13 UTC (rev 241163)
+++ branches/safari-607-branch/Source/WebCore/Modules/fetch/FetchRequestInit.idl	2019-02-07 23:37:17 UTC (rev 241164)
@@ -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