Title: [241265] trunk
- Revision
- 241265
- Author
- [email protected]
- Date
- 2019-02-11 09:20:07 -0800 (Mon, 11 Feb 2019)
Log Message
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 Geoffrey Garen.
Source/WebCore:
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):
LayoutTests:
* http/wpt/fetch/request-abort-expected.txt:
Modified Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (241264 => 241265)
--- trunk/LayoutTests/ChangeLog 2019-02-11 16:23:03 UTC (rev 241264)
+++ trunk/LayoutTests/ChangeLog 2019-02-11 17:20:07 UTC (rev 241265)
@@ -1,3 +1,13 @@
+2019-02-11 Youenn Fablet <[email protected]>
+
+ 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 Geoffrey Garen.
+
+ * http/wpt/fetch/request-abort-expected.txt:
+
2019-02-11 Zan Dobersek <[email protected]>
Unreviewed WPE gardening. Adding additional baselines after font variations
Modified: trunk/LayoutTests/http/wpt/fetch/request-abort-expected.txt (241264 => 241265)
--- trunk/LayoutTests/http/wpt/fetch/request-abort-expected.txt 2019-02-11 16:23:03 UTC (rev 241264)
+++ trunk/LayoutTests/http/wpt/fetch/request-abort-expected.txt 2019-02-11 17:20:07 UTC (rev 241265)
@@ -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
Modified: trunk/Source/WebCore/ChangeLog (241264 => 241265)
--- trunk/Source/WebCore/ChangeLog 2019-02-11 16:23:03 UTC (rev 241264)
+++ trunk/Source/WebCore/ChangeLog 2019-02-11 17:20:07 UTC (rev 241265)
@@ -1,3 +1,19 @@
+2019-02-11 Youenn Fablet <[email protected]>
+
+ 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 Geoffrey Garen.
+
+ 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-11 Zalan Bujtas <[email protected]>
[LFC] FormattingContext::Geometry::floatingHeightAndMargin should take UsedHorizontalValues
Modified: trunk/Source/WebCore/Modules/fetch/FetchRequest.cpp (241264 => 241265)
--- trunk/Source/WebCore/Modules/fetch/FetchRequest.cpp 2019-02-11 16:23:03 UTC (rev 241264)
+++ trunk/Source/WebCore/Modules/fetch/FetchRequest.cpp 2019-02-11 17:20:07 UTC (rev 241265)
@@ -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 @@
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 @@
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 @@
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
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes