зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1126483 - Added Response.ok. r=baku,bkelly
--HG-- extra : rebase_source : fdff9417d56b06a0556da9a95e0836148d91be0e
This commit is contained in:
Родитель
295a3bb098
Коммит
344fd0a633
|
@ -62,6 +62,13 @@ public:
|
|||
return mInternalResponse->GetStatus();
|
||||
}
|
||||
|
||||
bool
|
||||
Ok() const
|
||||
{
|
||||
return mInternalResponse->GetStatus() >= 200 &&
|
||||
mInternalResponse->GetStatus() <= 299;
|
||||
}
|
||||
|
||||
void
|
||||
GetStatusText(nsCString& aStatusText) const
|
||||
{
|
||||
|
|
|
@ -19,6 +19,7 @@ interface Response {
|
|||
|
||||
readonly attribute USVString url;
|
||||
readonly attribute unsigned short status;
|
||||
readonly attribute boolean ok;
|
||||
readonly attribute ByteString statusText;
|
||||
[SameObject] readonly attribute Headers headers;
|
||||
|
||||
|
|
|
@ -52,6 +52,20 @@ function testRedirect() {
|
|||
}
|
||||
}
|
||||
|
||||
function testOk() {
|
||||
var r1 = new Response("", { status: 200});
|
||||
ok(r1.ok, "Response with status 200 should have ok true");
|
||||
|
||||
var r2 = new Response("", { status: 204});
|
||||
ok(r2.ok, "Response with status 204 should have ok true");
|
||||
|
||||
var r3 = new Response("", { status: 299});
|
||||
ok(r3.ok, "Response with status 299 should have ok true");
|
||||
|
||||
var r4 = new Response("", { status: 302});
|
||||
ok(!r4.ok, "Response with status 302 should have ok false");
|
||||
}
|
||||
|
||||
function testBodyUsed() {
|
||||
var res = new Response("Sample body");
|
||||
ok(!res.bodyUsed, "bodyUsed is initially false.");
|
||||
|
@ -138,6 +152,7 @@ onmessage = function() {
|
|||
testDefaultCtor();
|
||||
testClone();
|
||||
testRedirect();
|
||||
testOk();
|
||||
|
||||
Promise.resolve()
|
||||
.then(testBodyCreation)
|
||||
|
|
Загрузка…
Ссылка в новой задаче