WebKit Bugzilla
Attachment 361535 Details for
Bug 194404
: Make Request constructor throw if FetchRequestInit.signal is not undefined, null or an AbortSignal object
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-194404-20190208142337.patch (text/plain), 5.52 KB, created by
youenn fablet
on 2019-02-08 14:23:38 PST
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
youenn fablet
Created:
2019-02-08 14:23:38 PST
Size:
5.52 KB
patch
obsolete
>Subversion Revision: 241123 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 5d7b105cb2dd658685bad40936f36b49737b1b15..bd4a49cd0e4e62202aa81b86976c3033ebddd58c 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,19 @@ >+2019-02-08 Youenn Fablet <youenn@apple.com> >+ >+ Make Request constructor throw if FetchRequestInit.signal is not undefined, null or an AbortSignal object >+ https://bugs.webkit.org/show_bug.cgi?id=194404 >+ <rdar://problem/47891915> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Align with the spec, except for known problematic web sites. >+ Covered by updated test. >+ >+ * Modules/fetch/FetchRequest.cpp: >+ (WebCore::needsSignalQuirk): >+ (WebCore::processInvalidSignal): >+ (WebCore::FetchRequest::initializeWith): >+ > 2019-02-08 Youenn Fablet <youenn@apple.com> > > Unable to sign in leetcode. >diff --git a/Source/WebCore/Modules/fetch/FetchRequest.cpp b/Source/WebCore/Modules/fetch/FetchRequest.cpp >index cfb9c4be58f972f772ddced8d172f3b3f305d303..0b978392b0616ec36e969bcd8c4c05a9b897b92d 100644 >--- a/Source/WebCore/Modules/fetch/FetchRequest.cpp >+++ b/Source/WebCore/Modules/fetch/FetchRequest.cpp >@@ -29,10 +29,13 @@ > #include "config.h" > #include "FetchRequest.h" > >+#include "Document.h" > #include "HTTPParsers.h" > #include "JSAbortSignal.h" >+#include "Logging.h" > #include "ScriptExecutionContext.h" > #include "SecurityOrigin.h" >+#include "Settings.h" > > namespace WebCore { > >@@ -141,6 +144,31 @@ ExceptionOr<void> FetchRequest::initializeOptions(const Init& init) > return { }; > } > >+static inline bool needsSignalQuirk(ScriptExecutionContext& context) >+{ >+ if (!is<Document>(context)) >+ return false; >+ >+ auto& document = downcast<Document>(context); >+ if (!document.settings().needsSiteSpecificQuirks()) >+ return false; >+ >+ auto host = document.topDocument().url().host(); >+ return equalLettersIgnoringASCIICase(host, "leetcode.com") || equalLettersIgnoringASCIICase(host, "www.thrivepatientportal.com"); >+} >+ >+static inline Optional<Exception> processInvalidSignal(ScriptExecutionContext& context) >+{ >+ ASCIILiteral message { "FetchRequestInit.signal should be undefined, null or an AbortSignal object."_s }; >+ context.addConsoleMessage(MessageSource::JS, MessageLevel::Warning, message); >+ >+ if (needsSignalQuirk(context)) >+ return { }; >+ >+ RELEASE_LOG_ERROR(ResourceLoading, "FetchRequestInit.signal should be undefined, null or an AbortSignal object."); >+ return Exception { TypeError, message }; >+} >+ > ExceptionOr<void> FetchRequest::initializeWith(const String& url, Init&& init) > { > ASSERT(scriptExecutionContext()); >@@ -164,8 +192,8 @@ ExceptionOr<void> FetchRequest::initializeWith(const String& url, Init&& init) > 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 (auto exception = processInvalidSignal(*scriptExecutionContext())) >+ return WTFMove(*exception); > } > } > >@@ -202,8 +230,8 @@ ExceptionOr<void> FetchRequest::initializeWith(FetchRequest& input, Init&& init) > 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); >+ if (auto exception = processInvalidSignal(*scriptExecutionContext())) >+ return WTFMove(*exception); > } > > } else >diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog >index 8b10a5fcae8f45ccb903ce2128e32a1fdb3a04ca..6d634932e5a20b393d5132b68d8860356438702b 100644 >--- a/LayoutTests/ChangeLog >+++ b/LayoutTests/ChangeLog >@@ -1,3 +1,13 @@ >+2019-02-08 Youenn Fablet <youenn@apple.com> >+ >+ Make Request constructor throw if FetchRequestInit.signal is not undefined, null or an AbortSignal object >+ https://bugs.webkit.org/show_bug.cgi?id=194404 >+ <rdar://problem/47891915> >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * http/wpt/fetch/request-abort-expected.txt: >+ > 2019-02-08 Youenn Fablet <youenn@apple.com> > > Unable to sign in leetcode. >diff --git a/LayoutTests/http/wpt/fetch/request-abort-expected.txt b/LayoutTests/http/wpt/fetch/request-abort-expected.txt >index 57cd5f3e800da6ebf68d9f2f9749eddb6a3902ed..4ce025e590f490c97ea781858f67496150a29c97 100644 >--- a/LayoutTests/http/wpt/fetch/request-abort-expected.txt >+++ b/LayoutTests/http/wpt/fetch/request-abort-expected.txt >@@ -1,6 +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 >+PASS Request from URL with signal >+PASS Request from request with signal >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 194404
: 361535