Diff
Modified: trunk/Source/WebCore/ChangeLog (207036 => 207037)
--- trunk/Source/WebCore/ChangeLog 2016-10-11 00:45:45 UTC (rev 207036)
+++ trunk/Source/WebCore/ChangeLog 2016-10-11 02:21:58 UTC (rev 207037)
@@ -1,3 +1,48 @@
+2016-10-10 Darin Adler <[email protected]>
+
+ Move Fetch from legacy to new DOM exceptions
+ https://bugs.webkit.org/show_bug.cgi?id=163195
+
+ Reviewed by Chris Dumez.
+
+ * Modules/fetch/FetchHeaders.cpp:
+ (WebCore::canWriteHeader): Use ExceptionOr.
+ (WebCore::FetchHeaders::append): Ditto.
+ (WebCore::FetchHeaders::remove): Ditto.
+ (WebCore::FetchHeaders::get): Ditto.
+ (WebCore::FetchHeaders::has): Ditto.
+ (WebCore::FetchHeaders::set): Ditto.
+ (WebCore::FetchHeaders::filterAndFill): Ditto.
+ (WebCore::FetchHeaders::Iterator::next): Got rid of unneeded code to
+ clear out m_keys after the last call to next, since it will be deleted
+ as soon as the iterator is deleted.
+
+ * Modules/fetch/FetchHeaders.h: Use pragma once. Use ExceptionOr.
+
+ * Modules/fetch/FetchHeaders.idl: Move to non-legacy exceptions.
+
+ * Modules/fetch/FetchRequest.cpp:
+ (WebCore::FetchRequest::setBody): Use ExceptionOr.
+ (WebCore::FetchRequest::clone): Ditto.
+
+ * Modules/fetch/FetchRequest.h: Use pragma once. Use ExceptionOr.
+
+ * Modules/fetch/FetchRequest.idl: Move to non-legacy exceptions.
+
+ * Modules/fetch/FetchResponse.cpp:
+ (WebCore::FetchResponse::redirect): Use ExceptionOr.
+ (WebCore::FetchResponse::setStatus): Ditto.
+
+ * Modules/fetch/FetchResponse.h: Use ExceptionOr.
+
+ * Modules/fetch/FetchResponse.idl: Move to non-legacy exceptions.
+
+ * bindings/js/JSDOMBinding.h: Added implementation of toJSNullableString.
+
+ * bindings/scripts/CodeGeneratorJS.pm:
+ (NativeToJSValue): Call toJSNullableString and toJSString for
+ functions that return ExceptionOr<String>.
+
2016-10-10 Nan Wang <[email protected]>
AX: Expose invalid status for input types with that information
Modified: trunk/Source/WebCore/Modules/fetch/FetchHeaders.cpp (207036 => 207037)
--- trunk/Source/WebCore/Modules/fetch/FetchHeaders.cpp 2016-10-11 00:45:45 UTC (rev 207036)
+++ trunk/Source/WebCore/Modules/fetch/FetchHeaders.cpp 2016-10-11 02:21:58 UTC (rev 207037)
@@ -36,16 +36,12 @@
namespace WebCore {
-static bool canWriteHeader(const String& name, const String& value, FetchHeaders::Guard guard, ExceptionCode& ec)
+static ExceptionOr<bool> canWriteHeader(const String& name, const String& value, FetchHeaders::Guard guard)
{
- if (!isValidHTTPToken(name) || !isValidHTTPHeaderValue(value)) {
- ec = TypeError;
- return false;
- }
- if (guard == FetchHeaders::Guard::Immutable) {
- ec = TypeError;
- return false;
- }
+ if (!isValidHTTPToken(name) || !isValidHTTPHeaderValue(value))
+ return Exception { TypeError };
+ if (guard == FetchHeaders::Guard::Immutable)
+ return Exception { TypeError };
if (guard == FetchHeaders::Guard::Request && isForbiddenHeaderName(name))
return false;
if (guard == FetchHeaders::Guard::RequestNoCors && !isSimpleHeader(name, value))
@@ -55,67 +51,75 @@
return true;
}
-void FetchHeaders::append(const String& name, const String& value, ExceptionCode& ec)
+ExceptionOr<void> FetchHeaders::append(const String& name, const String& value)
{
String normalizedValue = stripLeadingAndTrailingHTTPSpaces(value);
- if (!canWriteHeader(name, normalizedValue, m_guard, ec))
- return;
+ auto canWriteResult = canWriteHeader(name, normalizedValue, m_guard);
+ if (canWriteResult.hasException())
+ return canWriteResult.releaseException();
+ if (!canWriteResult.releaseReturnValue())
+ return { };
m_headers.add(name, normalizedValue);
+ return { };
}
-void FetchHeaders::remove(const String& name, ExceptionCode& ec)
+ExceptionOr<void> FetchHeaders::remove(const String& name)
{
- if (!canWriteHeader(name, String(), m_guard, ec))
- return;
+ auto canWriteResult = canWriteHeader(name, { }, m_guard);
+ if (canWriteResult.hasException())
+ return canWriteResult.releaseException();
+ if (!canWriteResult.releaseReturnValue())
+ return { };
m_headers.remove(name);
+ return { };
}
-String FetchHeaders::get(const String& name, ExceptionCode& ec) const
+ExceptionOr<String> FetchHeaders::get(const String& name) const
{
- if (!isValidHTTPToken(name)) {
- ec = TypeError;
- return String();
- }
+ if (!isValidHTTPToken(name))
+ return Exception { TypeError };
return m_headers.get(name);
}
-bool FetchHeaders::has(const String& name, ExceptionCode& ec) const
+ExceptionOr<bool> FetchHeaders::has(const String& name) const
{
- if (!isValidHTTPToken(name)) {
- ec = TypeError;
- return false;
- }
+ if (!isValidHTTPToken(name))
+ return Exception { TypeError };
return m_headers.contains(name);
}
-void FetchHeaders::set(const String& name, const String& value, ExceptionCode& ec)
+ExceptionOr<void> FetchHeaders::set(const String& name, const String& value)
{
String normalizedValue = stripLeadingAndTrailingHTTPSpaces(value);
- if (!canWriteHeader(name, normalizedValue, m_guard, ec))
- return;
+ auto canWriteResult = canWriteHeader(name, normalizedValue, m_guard);
+ if (canWriteResult.hasException())
+ return canWriteResult.releaseException();
+ if (!canWriteResult.releaseReturnValue())
+ return { };
m_headers.set(name, normalizedValue);
+ return { };
}
void FetchHeaders::fill(const FetchHeaders* headers)
{
ASSERT(m_guard != Guard::Immutable);
-
if (!headers)
return;
-
filterAndFill(headers->m_headers, m_guard);
}
void FetchHeaders::filterAndFill(const HTTPHeaderMap& headers, Guard guard)
{
- ExceptionCode ec;
for (auto& header : headers) {
- if (canWriteHeader(header.key, header.value, guard, ec)) {
- if (header.keyAsHTTPHeaderName)
- m_headers.add(header.keyAsHTTPHeaderName.value(), header.value);
- else
- m_headers.add(header.key, header.value);
- }
+ auto canWriteResult = canWriteHeader(header.key, header.value, guard);
+ if (canWriteResult.hasException())
+ continue;
+ if (!canWriteResult.releaseReturnValue())
+ continue;
+ if (header.keyAsHTTPHeaderName)
+ m_headers.add(header.keyAsHTTPHeaderName.value(), header.value);
+ else
+ m_headers.add(header.key, header.value);
}
}
@@ -122,12 +126,11 @@
Optional<WTF::KeyValuePair<String, String>> FetchHeaders::Iterator::next()
{
while (m_currentIndex < m_keys.size()) {
- String key = m_keys[m_currentIndex++];
- String value = m_headers->m_headers.get(key);
+ auto key = m_keys[m_currentIndex++];
+ auto value = m_headers->m_headers.get(key);
if (!value.isNull())
- return WTF::KeyValuePair<String, String>(WTFMove(key), WTFMove(value));
+ return WTF::KeyValuePair<String, String> { WTFMove(key), WTFMove(value) };
}
- m_keys.clear();
return Nullopt;
}
@@ -137,7 +140,6 @@
m_keys.reserveInitialCapacity(headers.m_headers.size());
for (auto& header : headers.m_headers)
m_keys.uncheckedAppend(header.key.convertToASCIILowercase());
-
std::sort(m_keys.begin(), m_keys.end(), WTF::codePointCompareLessThan);
}
Modified: trunk/Source/WebCore/Modules/fetch/FetchHeaders.h (207036 => 207037)
--- trunk/Source/WebCore/Modules/fetch/FetchHeaders.h 2016-10-11 00:45:45 UTC (rev 207036)
+++ trunk/Source/WebCore/Modules/fetch/FetchHeaders.h 2016-10-11 02:21:58 UTC (rev 207037)
@@ -30,14 +30,12 @@
#if ENABLE(FETCH_API)
+#include "ExceptionOr.h"
#include "HTTPHeaderMap.h"
#include <wtf/HashTraits.h>
-#include <wtf/Optional.h>
namespace WebCore {
-typedef int ExceptionCode;
-
class FetchHeaders : public RefCounted<FetchHeaders> {
public:
enum class Guard {
@@ -48,17 +46,16 @@
Response
};
- static Ref<FetchHeaders> create(Guard guard = Guard::None) { return adoptRef(*new FetchHeaders(guard)); }
- static Ref<FetchHeaders> create(const FetchHeaders& headers) { return adoptRef(*new FetchHeaders(headers.m_guard, headers.m_headers)); }
+ static Ref<FetchHeaders> create(Guard guard = Guard::None) { return adoptRef(*new FetchHeaders { guard }); }
+ static Ref<FetchHeaders> create(const FetchHeaders& headers) { return adoptRef(*new FetchHeaders { headers }); }
- void append(const String& name, const String& value, ExceptionCode&);
- void remove(const String&, ExceptionCode&);
- String get(const String&, ExceptionCode&) const;
- bool has(const String&, ExceptionCode&) const;
- void set(const String& name, const String& value, ExceptionCode&);
+ ExceptionOr<void> append(const String& name, const String& value);
+ ExceptionOr<void> remove(const String&);
+ ExceptionOr<String> get(const String&) const;
+ ExceptionOr<bool> has(const String&) const;
+ ExceptionOr<void> set(const String& name, const String& value);
void fill(const FetchHeaders*);
-
void filterAndFill(const HTTPHeaderMap&, Guard);
String fastGet(HTTPHeaderName name) const { return m_headers.get(name); }
@@ -71,10 +68,10 @@
private:
Ref<FetchHeaders> m_headers;
- size_t m_currentIndex = 0;
+ size_t m_currentIndex { 0 };
Vector<String> m_keys;
};
- Iterator createIterator() { return Iterator(*this); }
+ Iterator createIterator() { return Iterator { *this }; }
const HTTPHeaderMap& internalHeaders() const { return m_headers; }
@@ -82,12 +79,19 @@
private:
FetchHeaders(Guard guard) : m_guard(guard) { }
- FetchHeaders(Guard guard, const HTTPHeaderMap& headers) : m_guard(guard), m_headers(headers) { }
+ FetchHeaders(const FetchHeaders&);
Guard m_guard;
HTTPHeaderMap m_headers;
};
+inline FetchHeaders::FetchHeaders(const FetchHeaders& other)
+ : RefCounted()
+ , m_guard(other.m_guard)
+ , m_headers(other.m_headers)
+{
+}
+
inline void FetchHeaders::setGuard(Guard guard)
{
ASSERT(!m_headers.size());
Modified: trunk/Source/WebCore/Modules/fetch/FetchHeaders.idl (207036 => 207037)
--- trunk/Source/WebCore/Modules/fetch/FetchHeaders.idl 2016-10-11 00:45:45 UTC (rev 207036)
+++ trunk/Source/WebCore/Modules/fetch/FetchHeaders.idl 2016-10-11 02:21:58 UTC (rev 207037)
@@ -34,16 +34,16 @@
InterfaceName=Headers,
JSBuiltinConstructor,
PrivateIdentifier,
- PublicIdentifier]
-interface FetchHeaders {
- [MayThrowLegacyException] void append(DOMString name, DOMString value);
- [MayThrowLegacyException, ImplementedAs=remove] void delete(DOMString name);
- [MayThrowLegacyException] DOMString? get(DOMString name);
- [MayThrowLegacyException] boolean has(DOMString name);
- [MayThrowLegacyException] void set(DOMString name, DOMString value);
+ PublicIdentifier,
+] interface FetchHeaders {
+ [MayThrowException] void append(DOMString name, DOMString value);
+ [MayThrowException, ImplementedAs=remove] void delete(DOMString name);
+ [MayThrowException] DOMString? get(DOMString name);
+ [MayThrowException] boolean has(DOMString name);
+ [MayThrowException] void set(DOMString name, DOMString value);
[EnabledAtRuntime=DOMIterator] iterable<DOMString, DOMString>;
- [PrivateIdentifier, MayThrowLegacyException, ImplementedAs=append] void appendFromJS(DOMString name, DOMString value);
- [PrivateIdentifier, ImplementedAs=fill] void fillFromJS(FetchHeaders? headers);
+ [ImplementedAs=append, MayThrowException, PrivateIdentifier] void appendFromJS(DOMString name, DOMString value);
+ [ImplementedAs=fill, PrivateIdentifier] void fillFromJS(FetchHeaders? headers);
};
Modified: trunk/Source/WebCore/Modules/fetch/FetchRequest.cpp (207036 => 207037)
--- trunk/Source/WebCore/Modules/fetch/FetchRequest.cpp 2016-10-11 00:45:45 UTC (rev 207036)
+++ trunk/Source/WebCore/Modules/fetch/FetchRequest.cpp 2016-10-11 02:21:58 UTC (rev 207037)
@@ -261,30 +261,23 @@
return initializeOptions(init);
}
-void FetchRequest::setBody(JSC::ExecState& execState, JSC::JSValue body, FetchRequest* request, ExceptionCode& ec)
+ExceptionOr<void> FetchRequest::setBody(JSC::ExecState& execState, JSC::JSValue body, FetchRequest* request)
{
if (!body.isNull()) {
- if (!methodCanHaveBody(m_internalRequest)) {
- ec = TypeError;
- return;
- }
-
+ if (!methodCanHaveBody(m_internalRequest))
+ return Exception { TypeError };
ASSERT(scriptExecutionContext());
extractBody(*scriptExecutionContext(), execState, body);
- if (isBodyNull()) {
- ec = TypeError;
- return;
- }
+ if (isBodyNull())
+ return Exception { TypeError };
} else if (request && !request->isBodyNull()) {
- if (!methodCanHaveBody(m_internalRequest)) {
- ec = TypeError;
- return;
- }
-
+ if (!methodCanHaveBody(m_internalRequest))
+ return Exception { TypeError };
m_body = WTFMove(request->m_body);
request->setDisturbed();
}
updateContentType();
+ return { };
}
String FetchRequest::referrer() const
@@ -316,12 +309,10 @@
return request;
}
-RefPtr<FetchRequest> FetchRequest::clone(ScriptExecutionContext& context, ExceptionCode& ec)
+ExceptionOr<Ref<FetchRequest>> FetchRequest::clone(ScriptExecutionContext& context)
{
- if (isDisturbedOrLocked()) {
- ec = TypeError;
- return nullptr;
- }
+ if (isDisturbedOrLocked())
+ return Exception { TypeError };
auto clone = adoptRef(*new FetchRequest(context, Nullopt, FetchHeaders::create(m_headers.get()), FetchRequest::InternalRequest(m_internalRequest)));
clone->cloneBody(*this);
Modified: trunk/Source/WebCore/Modules/fetch/FetchRequest.h (207036 => 207037)
--- trunk/Source/WebCore/Modules/fetch/FetchRequest.h 2016-10-11 00:45:45 UTC (rev 207036)
+++ trunk/Source/WebCore/Modules/fetch/FetchRequest.h 2016-10-11 02:21:58 UTC (rev 207037)
@@ -26,8 +26,7 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef FetchRequest_h
-#define FetchRequest_h
+#pragma once
#if ENABLE(FETCH_API)
@@ -42,8 +41,6 @@
class Dictionary;
class ScriptExecutionContext;
-typedef int ExceptionCode;
-
class FetchRequest final : public FetchBodyOwner {
public:
static Ref<FetchRequest> create(ScriptExecutionContext& context) { return adoptRef(*new FetchRequest(context, Nullopt, FetchHeaders::create(FetchHeaders::Guard::Request), { })); }
@@ -50,7 +47,7 @@
ExceptionOr<Ref<FetchHeaders>> initializeWith(FetchRequest&, const Dictionary&);
ExceptionOr<Ref<FetchHeaders>> initializeWith(const String&, const Dictionary&);
- void setBody(JSC::ExecState&, JSC::JSValue, FetchRequest*, ExceptionCode&);
+ ExceptionOr<void> setBody(JSC::ExecState&, JSC::JSValue, FetchRequest*);
const String& method() const { return m_internalRequest.request.httpMethod(); }
const String& url() const;
@@ -81,7 +78,7 @@
const String& integrity() const { return m_internalRequest.integrity; }
- RefPtr<FetchRequest> clone(ScriptExecutionContext&, ExceptionCode&);
+ ExceptionOr<Ref<FetchRequest>> clone(ScriptExecutionContext&);
struct InternalRequest {
ResourceRequest request;
@@ -100,7 +97,6 @@
ExceptionOr<Ref<FetchHeaders>> initializeOptions(const Dictionary&);
- // ActiveDOMObject API.
const char* activeDOMObjectName() const final;
bool canSuspendForDocumentSuspension() const final;
@@ -152,5 +148,3 @@
} // namespace WebCore
#endif // ENABLE(FETCH_API)
-
-#endif // FetchRequest_h
Modified: trunk/Source/WebCore/Modules/fetch/FetchRequest.idl (207036 => 207037)
--- trunk/Source/WebCore/Modules/fetch/FetchRequest.idl 2016-10-11 00:45:45 UTC (rev 207036)
+++ trunk/Source/WebCore/Modules/fetch/FetchRequest.idl 2016-10-11 02:21:58 UTC (rev 207037)
@@ -44,8 +44,7 @@
JSBuiltinConstructor,
PrivateIdentifier,
PublicIdentifier,
-]
-interface FetchRequest {
+] interface FetchRequest {
readonly attribute DOMString method;
readonly attribute DOMString url;
readonly attribute FetchHeaders headers;
@@ -60,10 +59,11 @@
readonly attribute RequestRedirect redirect;
readonly attribute DOMString integrity;
- [NewObject, CallWith=ScriptExecutionContext, MayThrowLegacyException] FetchRequest clone();
+ [CallWith=ScriptExecutionContext, MayThrowException, NewObject] FetchRequest clone();
[MayThrowException, NewObject, PrivateIdentifier] FetchHeaders initializeWith(FetchRequest input, Dictionary init);
[MayThrowException, NewObject, PrivateIdentifier] FetchHeaders initializeWith(DOMString input, Dictionary init);
- [CallWith=ScriptState, MayThrowLegacyException, PrivateIdentifier] void setBody(any body, FetchRequest? request);
+ [CallWith=ScriptState, MayThrowException, PrivateIdentifier] void setBody(any body, FetchRequest? request);
};
+
FetchRequest implements FetchBody;
Modified: trunk/Source/WebCore/Modules/fetch/FetchResponse.cpp (207036 => 207037)
--- trunk/Source/WebCore/Modules/fetch/FetchResponse.cpp 2016-10-11 00:45:45 UTC (rev 207036)
+++ trunk/Source/WebCore/Modules/fetch/FetchResponse.cpp 2016-10-11 02:21:58 UTC (rev 207037)
@@ -52,18 +52,14 @@
return response;
}
-RefPtr<FetchResponse> FetchResponse::redirect(ScriptExecutionContext& context, const String& url, int status, ExceptionCode& ec)
+ExceptionOr<Ref<FetchResponse>> FetchResponse::redirect(ScriptExecutionContext& context, const String& url, int status)
{
// FIXME: Tighten the URL parsing algorithm according https://url.spec.whatwg.org/#concept-url-parser.
URL requestURL = context.completeURL(url);
- if (!requestURL.isValid() || !requestURL.user().isEmpty() || !requestURL.pass().isEmpty()) {
- ec = TypeError;
- return nullptr;
- }
- if (!isRedirectStatus(status)) {
- ec = RangeError;
- return nullptr;
- }
+ if (!requestURL.isValid() || !requestURL.user().isEmpty() || !requestURL.pass().isEmpty())
+ return Exception { TypeError };
+ if (!isRedirectStatus(status))
+ return Exception { RangeError };
auto redirectResponse = adoptRef(*new FetchResponse(context, { }, FetchHeaders::create(FetchHeaders::Guard::Immutable), { }));
redirectResponse->m_response.setHTTPStatusCode(status);
redirectResponse->m_headers->fastSet(HTTPHeaderName::Location, requestURL.string());
@@ -70,14 +66,13 @@
return WTFMove(redirectResponse);
}
-void FetchResponse::setStatus(int status, const String& statusText, ExceptionCode& ec)
+ExceptionOr<void> FetchResponse::setStatus(int status, const String& statusText)
{
- if (!isValidReasonPhrase(statusText)) {
- ec = TypeError;
- return;
- }
+ if (!isValidReasonPhrase(statusText))
+ return Exception { TypeError };
m_response.setHTTPStatusCode(status);
m_response.setHTTPStatusText(statusText);
+ return { };
}
void FetchResponse::initializeWith(JSC::ExecState& execState, JSC::JSValue body)
Modified: trunk/Source/WebCore/Modules/fetch/FetchResponse.h (207036 => 207037)
--- trunk/Source/WebCore/Modules/fetch/FetchResponse.h 2016-10-11 00:45:45 UTC (rev 207036)
+++ trunk/Source/WebCore/Modules/fetch/FetchResponse.h 2016-10-11 02:21:58 UTC (rev 207037)
@@ -35,7 +35,6 @@
#include <runtime/TypedArrays.h>
namespace JSC {
-class ArrayBuffer;
class ExecState;
class JSValue;
};
@@ -46,8 +45,6 @@
class FetchRequest;
class ReadableStreamSource;
-typedef int ExceptionCode;
-
class FetchResponse final : public FetchBodyOwner {
public:
using Type = ResourceResponse::Type;
@@ -54,7 +51,7 @@
static Ref<FetchResponse> create(ScriptExecutionContext& context) { return adoptRef(*new FetchResponse(context, Nullopt, FetchHeaders::create(FetchHeaders::Guard::Response), ResourceResponse())); }
static Ref<FetchResponse> error(ScriptExecutionContext&);
- static RefPtr<FetchResponse> redirect(ScriptExecutionContext&, const String&, int, ExceptionCode&);
+ static ExceptionOr<Ref<FetchResponse>> redirect(ScriptExecutionContext&, const String& url, int status);
using FetchPromise = DOMPromise<FetchResponse>;
static void fetch(ScriptExecutionContext&, FetchRequest&, FetchPromise&&);
@@ -66,7 +63,7 @@
void finishConsumingStream(Ref<DeferredPromise>&&);
#endif
- void setStatus(int, const String&, ExceptionCode&);
+ ExceptionOr<void> setStatus(int status, const String& statusText);
void initializeWith(JSC::ExecState&, JSC::JSValue);
Type type() const { return m_response.type(); }
@@ -85,6 +82,7 @@
void feedStream();
void cancel();
#endif
+
bool isLoading() const { return !!m_bodyLoader; }
private:
@@ -92,7 +90,6 @@
static void startFetching(ScriptExecutionContext&, const FetchRequest&, FetchPromise&&);
- // ActiveDOMObject API
void stop() final;
const char* activeDOMObjectName() const final;
bool canSuspendForDocumentSuspension() const final;
Modified: trunk/Source/WebCore/Modules/fetch/FetchResponse.idl (207036 => 207037)
--- trunk/Source/WebCore/Modules/fetch/FetchResponse.idl 2016-10-11 00:45:45 UTC (rev 207036)
+++ trunk/Source/WebCore/Modules/fetch/FetchResponse.idl 2016-10-11 02:21:58 UTC (rev 207037)
@@ -25,22 +25,22 @@
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+
enum ResponseType { "basic", "cors", "default", "error", "opaque", "opaqueredirect" };
[
ActiveDOMObject,
Conditional=FETCH_API,
+ ConstructorCallWith=ScriptExecutionContext,
EnabledAtRuntime=FetchAPI,
- ConstructorCallWith=ScriptExecutionContext,
Exposed=(Window,Worker),
InterfaceName=Response,
JSBuiltinConstructor,
PrivateIdentifier,
- PublicIdentifier
-]
-interface FetchResponse {
- [NewObject, CallWith=ScriptExecutionContext] static FetchResponse error();
- [NewObject, CallWith=ScriptExecutionContext, MayThrowLegacyException] static FetchResponse redirect(DOMString url, optional unsigned short status = 302);
+ PublicIdentifier,
+] interface FetchResponse {
+ [CallWith=ScriptExecutionContext, NewObject] static FetchResponse error();
+ [CallWith=ScriptExecutionContext, MayThrowException, NewObject] static FetchResponse redirect(DOMString url, optional unsigned short status = 302);
readonly attribute ResponseType type;
@@ -49,8 +49,7 @@
readonly attribute unsigned short status;
readonly attribute boolean ok;
readonly attribute DOMString statusText;
- // FIXME: Add support for SameObject keyword for headers
- readonly attribute FetchHeaders headers;
+ readonly attribute FetchHeaders headers; // FIXME: Add support for SameObject keyword; use it here.
[JSBuiltin] readonly attribute ReadableStream? body;
// Copy of FetchBody IDL as we want to implement some of these as built-ins.
@@ -63,7 +62,7 @@
[JSBuiltin] FetchResponse clone();
- [PrivateIdentifier, NewObject] FetchResponse cloneForJS();
+ [NewObject, PrivateIdentifier] FetchResponse cloneForJS();
[Conditional=READABLE_STREAM_API, PrivateIdentifier] void startConsumingStream(unsigned short type);
[Conditional=READABLE_STREAM_API, PrivateIdentifier] void consumeChunk(Uint8Array chunk);
@@ -71,8 +70,8 @@
[PrivateIdentifier] Promise consume(unsigned short type);
[PrivateIdentifier] boolean isLoading();
- [PrivateIdentifier, MayThrowLegacyException] void setStatus(unsigned short status, DOMString statusText);
+ [MayThrowException, PrivateIdentifier] void setStatus(unsigned short status, DOMString statusText);
[CallWith=ScriptState, PrivateIdentifier] void initializeWith(any body);
- [PrivateIdentifier, NewObject] ReadableStreamSource createReadableStreamSource();
+ [NewObject, PrivateIdentifier] ReadableStreamSource createReadableStreamSource();
[PrivateIdentifier] boolean isDisturbed();
};
Modified: trunk/Source/WebCore/bindings/js/JSDOMBinding.h (207036 => 207037)
--- trunk/Source/WebCore/bindings/js/JSDOMBinding.h 2016-10-11 00:45:45 UTC (rev 207036)
+++ trunk/Source/WebCore/bindings/js/JSDOMBinding.h 2016-10-11 02:21:58 UTC (rev 207037)
@@ -948,6 +948,15 @@
return toJSNewlyCreated(&state, &globalObject, value.releaseReturnValue());
}
+inline JSC::JSValue toJSNullableString(JSC::ExecState& state, JSC::ThrowScope& throwScope, ExceptionOr<String>&& value)
+{
+ if (UNLIKELY(value.hasException())) {
+ propagateException(state, throwScope, value.releaseException());
+ return { };
+ }
+ return jsStringOrNull(&state, value.releaseReturnValue());
+}
+
template<typename T> inline JSC::JSValue toJSNumber(JSC::ExecState& state, JSC::ThrowScope& throwScope, ExceptionOr<T>&& value)
{
if (UNLIKELY(value.hasException())) {
Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm (207036 => 207037)
--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm 2016-10-11 00:45:45 UTC (rev 207036)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm 2016-10-11 02:21:58 UTC (rev 207037)
@@ -5041,7 +5041,9 @@
if ($codeGenerator->IsStringType($type)) {
AddToImplIncludes("URL.h", $conditional);
+ return "toJSNullableString($stateReference, throwScope, $value)" if $isNullable && $mayThrowException;
return "jsStringOrNull($statePointer, $value)" if $isNullable;
+ return "toJSString($stateReference, throwScope, $value)" if $mayThrowException;
AddToImplIncludes("<runtime/JSString.h>", $conditional);
return "jsStringWithCache($statePointer, $value)";
}