Abort previous pending XHR when navigating #114
@@ -23,7 +23,9 @@ tape("test aborting xhr request", function(t) {
|
||||
|
|
||||
})
|
||||
|
||||
t.test("- pending request is aborted", function(t) {
|
||||
var r = requestCacheBust("https://httpbin.org/delay/10", {}, function() {})
|
||||
|
Is this callback ever called? Do you want to add a test that fails if it is? Is this callback ever called? Do you want to add a test that fails if it is?
Good idea, will do that. Good idea, will do that.
Actually, that callback is never called, because if Actually, that callback is never called, because if `abortRequest(r)` doesn't abort the request, the next assert (`t.equal(r.readyState, 0, "xhr readyState is '0' (ABORTED)"))` immediately fails, so I don't think we do need to add anything else in.
Tape has a Tape has a [`t.fail()`](https://github.com/substack/tape#tfailmsg) function. I think adding that will make it more apparent that the callback is not supposed to be called. What do you think?
I did add that and then remove it again because the callback would never fire, but I take the point about making it explicit that the callback shouldn't fire, will add that back in. I did add that and then remove it again because the callback would never fire, but I take the point about making it explicit that the callback *shouldn't* fire, will add that back in.
|
||||
var r = requestCacheBust("https://httpbin.org/delay/10", {}, function() {
|
||||
|
Is this callback ever called? Do you want to add a test that fails if it is? Is this callback ever called? Do you want to add a test that fails if it is?
Good idea, will do that. Good idea, will do that.
Actually, that callback is never called, because if Actually, that callback is never called, because if `abortRequest(r)` doesn't abort the request, the next assert (`t.equal(r.readyState, 0, "xhr readyState is '0' (ABORTED)"))` immediately fails, so I don't think we do need to add anything else in.
Tape has a Tape has a [`t.fail()`](https://github.com/substack/tape#tfailmsg) function. I think adding that will make it more apparent that the callback is not supposed to be called. What do you think?
I did add that and then remove it again because the callback would never fire, but I take the point about making it explicit that the callback shouldn't fire, will add that back in. I did add that and then remove it again because the callback would never fire, but I take the point about making it explicit that the callback *shouldn't* fire, will add that back in.
|
||||
t.fail("xhr was not aborted")
|
||||
|
Is this callback ever called? Do you want to add a test that fails if it is? Is this callback ever called? Do you want to add a test that fails if it is?
Good idea, will do that. Good idea, will do that.
Actually, that callback is never called, because if Actually, that callback is never called, because if `abortRequest(r)` doesn't abort the request, the next assert (`t.equal(r.readyState, 0, "xhr readyState is '0' (ABORTED)"))` immediately fails, so I don't think we do need to add anything else in.
Tape has a Tape has a [`t.fail()`](https://github.com/substack/tape#tfailmsg) function. I think adding that will make it more apparent that the callback is not supposed to be called. What do you think?
I did add that and then remove it again because the callback would never fire, but I take the point about making it explicit that the callback shouldn't fire, will add that back in. I did add that and then remove it again because the callback would never fire, but I take the point about making it explicit that the callback *shouldn't* fire, will add that back in.
|
||||
})
|
||||
|
Is this callback ever called? Do you want to add a test that fails if it is? Is this callback ever called? Do you want to add a test that fails if it is?
Good idea, will do that. Good idea, will do that.
Actually, that callback is never called, because if Actually, that callback is never called, because if `abortRequest(r)` doesn't abort the request, the next assert (`t.equal(r.readyState, 0, "xhr readyState is '0' (ABORTED)"))` immediately fails, so I don't think we do need to add anything else in.
Tape has a Tape has a [`t.fail()`](https://github.com/substack/tape#tfailmsg) function. I think adding that will make it more apparent that the callback is not supposed to be called. What do you think?
I did add that and then remove it again because the callback would never fire, but I take the point about making it explicit that the callback shouldn't fire, will add that back in. I did add that and then remove it again because the callback would never fire, but I take the point about making it explicit that the callback *shouldn't* fire, will add that back in.
|
||||
t.equal(r.readyState, 1, "xhr readyState is '1' (SENT)")
|
||||
abortRequest(r)
|
||||
t.equal(r.readyState, 0, "xhr readyState is '0' (ABORTED)")
|
||||
|
||||
|
Is this callback ever called? Do you want to add a test that fails if it is? Is this callback ever called? Do you want to add a test that fails if it is?
Is this callback ever called? Do you want to add a test that fails if it is? Is this callback ever called? Do you want to add a test that fails if it is?
Good idea, will do that. Good idea, will do that.
Good idea, will do that. Good idea, will do that.
Actually, that callback is never called, because if Actually, that callback is never called, because if `abortRequest(r)` doesn't abort the request, the next assert (`t.equal(r.readyState, 0, "xhr readyState is '0' (ABORTED)"))` immediately fails, so I don't think we do need to add anything else in.
Actually, that callback is never called, because if Actually, that callback is never called, because if `abortRequest(r)` doesn't abort the request, the next assert (`t.equal(r.readyState, 0, "xhr readyState is '0' (ABORTED)"))` immediately fails, so I don't think we do need to add anything else in.
Tape has a Tape has a [`t.fail()`](https://github.com/substack/tape#tfailmsg) function. I think adding that will make it more apparent that the callback is not supposed to be called. What do you think?
Tape has a Tape has a [`t.fail()`](https://github.com/substack/tape#tfailmsg) function. I think adding that will make it more apparent that the callback is not supposed to be called. What do you think?
I did add that and then remove it again because the callback would never fire, but I take the point about making it explicit that the callback shouldn't fire, will add that back in. I did add that and then remove it again because the callback would never fire, but I take the point about making it explicit that the callback *shouldn't* fire, will add that back in.
I did add that and then remove it again because the callback would never fire, but I take the point about making it explicit that the callback shouldn't fire, will add that back in. I did add that and then remove it again because the callback would never fire, but I take the point about making it explicit that the callback *shouldn't* fire, will add that back in.
|
||||
Is this callback ever called? Do you want to add a test that fails if it is?
Is this callback ever called? Do you want to add a test that fails if it is?
Good idea, will do that.
Good idea, will do that.
Actually, that callback is never called, because if
abortRequest(r)doesn't abort the request, the next assert (t.equal(r.readyState, 0, "xhr readyState is '0' (ABORTED)"))immediately fails, so I don't think we do need to add anything else in.Actually, that callback is never called, because if
abortRequest(r)doesn't abort the request, the next assert (t.equal(r.readyState, 0, "xhr readyState is '0' (ABORTED)"))immediately fails, so I don't think we do need to add anything else in.Tape has a
t.fail()function. I think adding that will make it more apparent that the callback is not supposed to be called. What do you think?Tape has a
t.fail()function. I think adding that will make it more apparent that the callback is not supposed to be called. What do you think?I did add that and then remove it again because the callback would never fire, but I take the point about making it explicit that the callback shouldn't fire, will add that back in.
I did add that and then remove it again because the callback would never fire, but I take the point about making it explicit that the callback shouldn't fire, will add that back in.