Commit f8daa682 authored by Raphael Kubo da Costa's avatar Raphael Kubo da Costa Committed by Commit Bot

fetch: Add [NewObject] to IDL declarations that have it in the spec.

Several IDL methods have been annotated with the [NewObject] extended
attribute since 2014 (Fetch spec commit 92f9337cd2, "Sprinkle [NewObject],
[SameObject] love").

Add it to our IDLs for spec compliance. In practice, at the moment this is a
no-op for methods that return promises and it adds a DCHECK for methods that
return interface types.

Request.clone() and Response.clone() also need the Blink-specific
[DoNotTestNewObject] extended attribute, as their C++ implementations call
ToV8() on the new object they return, which causes the DCHECKs to fail (in
other words, [NewObject] becomes a no-op for them as well).

Bug: 769221

Change-Id: If1d598660efef656d165a79618a45ea8ddc99e30
Reviewed-on: https://chromium-review.googlesource.com/685658Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Commit-Queue: Raphael Kubo da Costa (rakuco) <raphael.kubo.da.costa@intel.com>
Cr-Commit-Position: refs/heads/master@{#504717}
parent 331bfdfc
...@@ -11,11 +11,11 @@ ...@@ -11,11 +11,11 @@
NoInterfaceObject NoInterfaceObject
] interface Body { ] interface Body {
readonly attribute boolean bodyUsed; readonly attribute boolean bodyUsed;
[CallWith=ScriptState] Promise<ArrayBuffer> arrayBuffer(); [CallWith=ScriptState, NewObject] Promise<ArrayBuffer> arrayBuffer();
[CallWith=ScriptState] Promise<Blob> blob(); [CallWith=ScriptState, NewObject] Promise<Blob> blob();
[CallWith=ScriptState] Promise<FormData> formData(); [CallWith=ScriptState, NewObject] Promise<FormData> formData();
[CallWith=ScriptState] Promise<JSON> json(); [CallWith=ScriptState, NewObject] Promise<JSON> json();
[CallWith=ScriptState] Promise<USVString> text(); [CallWith=ScriptState, NewObject] Promise<USVString> text();
// body attribute is defined in sub-interfaces, because the IDL processor // body attribute is defined in sub-interfaces, because the IDL processor
// cannot deal with attribute inheritance with runtime enabled flag. // cannot deal with attribute inheritance with runtime enabled flag.
......
...@@ -42,7 +42,7 @@ enum ReferrerPolicy { ...@@ -42,7 +42,7 @@ enum ReferrerPolicy {
readonly attribute RequestRedirect redirect; readonly attribute RequestRedirect redirect;
readonly attribute DOMString integrity; readonly attribute DOMString integrity;
[RaisesException, CallWith=ScriptState] Request clone(); [RaisesException, CallWith=ScriptState, DoNotTestNewObject, NewObject] Request clone();
}; };
Request implements Body; Request implements Body;
...@@ -16,8 +16,8 @@ enum ResponseType { "basic", "cors", "default", "error", "opaque", "opaqueredire ...@@ -16,8 +16,8 @@ enum ResponseType { "basic", "cors", "default", "error", "opaque", "opaqueredire
Exposed=(Window,Worker), Exposed=(Window,Worker),
RaisesException=Constructor RaisesException=Constructor
] interface Response { ] interface Response {
[CallWith=ScriptState] static Response error(); [CallWith=ScriptState, NewObject] static Response error();
[CallWith=ScriptState, RaisesException] static Response redirect(USVString url, optional unsigned short status = 302); [CallWith=ScriptState, NewObject, RaisesException] static Response redirect(USVString url, optional unsigned short status = 302);
readonly attribute ResponseType type; readonly attribute ResponseType type;
readonly attribute USVString url; readonly attribute USVString url;
readonly attribute boolean redirected; readonly attribute boolean redirected;
...@@ -26,7 +26,7 @@ enum ResponseType { "basic", "cors", "default", "error", "opaque", "opaqueredire ...@@ -26,7 +26,7 @@ enum ResponseType { "basic", "cors", "default", "error", "opaque", "opaqueredire
readonly attribute ByteString statusText; readonly attribute ByteString statusText;
readonly attribute Headers headers; readonly attribute Headers headers;
[RaisesException, CallWith=ScriptState] Response clone(); [RaisesException, CallWith=ScriptState, DoNotTestNewObject, NewObject] Response clone();
[CallWith=ScriptState, MeasureAs=FetchBodyStream] readonly attribute any body; [CallWith=ScriptState, MeasureAs=FetchBodyStream] readonly attribute any body;
}; };
......
...@@ -5,5 +5,5 @@ ...@@ -5,5 +5,5 @@
[ [
ImplementedAs=GlobalFetch ImplementedAs=GlobalFetch
] partial interface Window { ] partial interface Window {
[CallWith=ScriptState, RaisesException] Promise<Response> fetch(RequestInfo input, optional Dictionary init); [CallWith=ScriptState, NewObject, RaisesException] Promise<Response> fetch(RequestInfo input, optional Dictionary init);
}; };
...@@ -5,5 +5,5 @@ ...@@ -5,5 +5,5 @@
[ [
ImplementedAs=GlobalFetch ImplementedAs=GlobalFetch
] partial interface WorkerGlobalScope { ] partial interface WorkerGlobalScope {
[CallWith=ScriptState, RaisesException] Promise<Response> fetch(RequestInfo input, optional Dictionary init); [CallWith=ScriptState, NewObject, RaisesException] Promise<Response> fetch(RequestInfo input, optional Dictionary init);
}; };
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment