mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-10-26 09:07:30 +09:00
moebius#312: DOM - Fix incorrect TypeError: Response body is given with a null body status
https://github.com/MoonchildProductions/moebius/issues/312
This commit is contained in:
parent
9ee1ed3eaf
commit
41ad5496ae
4 changed files with 11 additions and 6 deletions
|
|
@ -104,7 +104,7 @@ Response::Redirect(const GlobalObject& aGlobal, const nsAString& aUrl,
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
Optional<ArrayBufferOrArrayBufferViewOrBlobOrFormDataOrUSVStringOrURLSearchParams> body;
|
Optional<Nullable<ArrayBufferOrArrayBufferViewOrBlobOrFormDataOrUSVStringOrURLSearchParams>> body;
|
||||||
ResponseInit init;
|
ResponseInit init;
|
||||||
init.mStatus = aStatus;
|
init.mStatus = aStatus;
|
||||||
RefPtr<Response> r = Response::Constructor(aGlobal, body, init, aRv);
|
RefPtr<Response> r = Response::Constructor(aGlobal, body, init, aRv);
|
||||||
|
|
@ -125,7 +125,7 @@ Response::Redirect(const GlobalObject& aGlobal, const nsAString& aUrl,
|
||||||
|
|
||||||
/*static*/ already_AddRefed<Response>
|
/*static*/ already_AddRefed<Response>
|
||||||
Response::Constructor(const GlobalObject& aGlobal,
|
Response::Constructor(const GlobalObject& aGlobal,
|
||||||
const Optional<ArrayBufferOrArrayBufferViewOrBlobOrFormDataOrUSVStringOrURLSearchParams>& aBody,
|
const Optional<Nullable<ArrayBufferOrArrayBufferViewOrBlobOrFormDataOrUSVStringOrURLSearchParams>>& aBody,
|
||||||
const ResponseInit& aInit, ErrorResult& aRv)
|
const ResponseInit& aInit, ErrorResult& aRv)
|
||||||
{
|
{
|
||||||
nsCOMPtr<nsIGlobalObject> global = do_QueryInterface(aGlobal.GetAsSupports());
|
nsCOMPtr<nsIGlobalObject> global = do_QueryInterface(aGlobal.GetAsSupports());
|
||||||
|
|
@ -191,7 +191,7 @@ Response::Constructor(const GlobalObject& aGlobal,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (aBody.WasPassed()) {
|
if (aBody.WasPassed() && !aBody.Value().IsNull()) {
|
||||||
if (aInit.mStatus == 204 || aInit.mStatus == 205 || aInit.mStatus == 304) {
|
if (aInit.mStatus == 204 || aInit.mStatus == 205 || aInit.mStatus == 304) {
|
||||||
aRv.ThrowTypeError<MSG_RESPONSE_NULL_STATUS_WITH_BODY>();
|
aRv.ThrowTypeError<MSG_RESPONSE_NULL_STATUS_WITH_BODY>();
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
@ -200,7 +200,7 @@ Response::Constructor(const GlobalObject& aGlobal,
|
||||||
nsCOMPtr<nsIInputStream> bodyStream;
|
nsCOMPtr<nsIInputStream> bodyStream;
|
||||||
nsCString contentType;
|
nsCString contentType;
|
||||||
uint64_t bodySize = 0;
|
uint64_t bodySize = 0;
|
||||||
aRv = ExtractByteStreamFromBody(aBody.Value(),
|
aRv = ExtractByteStreamFromBody(aBody.Value().Value(),
|
||||||
getter_AddRefs(bodyStream),
|
getter_AddRefs(bodyStream),
|
||||||
contentType,
|
contentType,
|
||||||
bodySize);
|
bodySize);
|
||||||
|
|
|
||||||
|
|
@ -114,7 +114,7 @@ public:
|
||||||
|
|
||||||
static already_AddRefed<Response>
|
static already_AddRefed<Response>
|
||||||
Constructor(const GlobalObject& aGlobal,
|
Constructor(const GlobalObject& aGlobal,
|
||||||
const Optional<ArrayBufferOrArrayBufferViewOrBlobOrFormDataOrUSVStringOrURLSearchParams>& aBody,
|
const Optional<Nullable<ArrayBufferOrArrayBufferViewOrBlobOrFormDataOrUSVStringOrURLSearchParams>>& aBody,
|
||||||
const ResponseInit& aInit, ErrorResult& rv);
|
const ResponseInit& aInit, ErrorResult& rv);
|
||||||
|
|
||||||
nsIGlobalObject* GetParentObject() const
|
nsIGlobalObject* GetParentObject() const
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
* https://fetch.spec.whatwg.org/#response-class
|
* https://fetch.spec.whatwg.org/#response-class
|
||||||
*/
|
*/
|
||||||
|
|
||||||
[Constructor(optional BodyInit body, optional ResponseInit init),
|
[Constructor(optional BodyInit? body, optional ResponseInit init),
|
||||||
Exposed=(Window,Worker)]
|
Exposed=(Window,Worker)]
|
||||||
interface Response {
|
interface Response {
|
||||||
[NewObject] static Response error();
|
[NewObject] static Response error();
|
||||||
|
|
|
||||||
|
|
@ -65,6 +65,11 @@
|
||||||
});
|
});
|
||||||
}, "Testing empty Response Content-Type header");
|
}, "Testing empty Response Content-Type header");
|
||||||
|
|
||||||
|
test(function() {
|
||||||
|
var response = new Response(null, {status: 204});
|
||||||
|
assert_equals(response.body, null);
|
||||||
|
}, "Testing null Response body");
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue