Abort previous pending XHR when navigating #114
@@ -10,7 +10,7 @@
|
||||
<div class='body'>
|
||||
<h1>Index</h1>
|
||||
Hello.
|
||||
Go to <a href='page2.html' class="js-Pjax">Page 2</a> and view your console to see Pjax events.
|
||||
Go to <a href='page2.html' class="js-Pjax">Page 2</a> or <a href='page3.html' class="js-Pjax">Page 3</a> and view your console to see Pjax events.
|
||||
Clicking on <a href='index.html'>this page</a> will just reload the page entirely.
|
||||
</div>
|
||||
</body>
|
||||
|
||||
15
example/page3.html
Normal file
@@ -0,0 +1,15 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset='utf-8'>
|
||||
<title>Hello</title>
|
||||
<script src='../pjax.js'></script>
|
||||
<script src='example.js'></script>
|
||||
</head>
|
||||
<body>
|
||||
<div class='body'>
|
||||
<h1>Page 3</h1>
|
||||
Hello. Go to <a href='index.html' class="js-Pjax">Index</a>.
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
9
index.js
@@ -145,16 +145,21 @@ Pjax.prototype = {
|
||||
// }
|
||||
},
|
||||
|
||||
doRequest: require("./lib/request.js"),
|
||||
abortRequest: require("./lib/abort-request.js"),
|
||||
|
||||
doRequest: require("./lib/send-request.js"),
|
||||
|
||||
loadUrl: function(href, options) {
|
||||
this.log("load href", href, options)
|
||||
|
||||
// Abort any previous request
|
||||
this.abortRequest(this.request)
|
||||
|
||||
trigger(document, "pjax:send", options);
|
||||
|
||||
// Do the request
|
||||
options.requestOptions.timeout = this.options.timeout
|
||||
this.doRequest(href, options.requestOptions, function(html, request) {
|
||||
this.request = this.doRequest(href, options.requestOptions, function(html, request) {
|
||||
// Fail if unable to load HTML via AJAX
|
||||
if (html === false) {
|
||||
trigger(document,"pjax:complete pjax:error", options)
|
||||
|
||||
8
lib/abort-request.js
Normal file
@@ -0,0 +1,8 @@
|
||||
var noop = require("./util/noop")
|
||||
|
|
||||
|
||||
module.exports = function(request) {
|
||||
if (request && request.readyState < 4) {
|
||||
request.onreadystatechange = noop
|
||||
request.abort()
|
||||
}
|
||||
}
|
||||
1
lib/util/noop
Normal file
@@ -0,0 +1 @@
|
||||
|
Is there any reason not to inline this? Is there any reason not to inline this?
Is there any reason not to inline this? Is there any reason not to inline this?
I broke this out as a separate module so that it could be used whereever a noop function is required, which is currently in 2 places in the library... but didn't then update the second usage (in the 'stupidPjax' fallback) 😊 I broke this out as a separate module so that it could be used whereever a noop function is required, which is currently in 2 places in the library... but didn't then update the second usage (in the 'stupidPjax' fallback) 😊
I broke this out as a separate module so that it could be used whereever a noop function is required, which is currently in 2 places in the library... but didn't then update the second usage (in the 'stupidPjax' fallback) 😊 I broke this out as a separate module so that it could be used whereever a noop function is required, which is currently in 2 places in the library... but didn't then update the second usage (in the 'stupidPjax' fallback) 😊
Can you rename the file to Can you rename the file to `noop.js`?
Can you rename the file to Can you rename the file to `noop.js`?
Yes, nice catch, this is why code reviews are important 😉 Yes, nice catch, this is why code reviews are important 😉
Yes, nice catch, this is why code reviews are important 😉 Yes, nice catch, this is why code reviews are important 😉
|
||||
module.exports = function() {}
|
||||
|
Is there any reason not to inline this? Is there any reason not to inline this?
I broke this out as a separate module so that it could be used whereever a noop function is required, which is currently in 2 places in the library... but didn't then update the second usage (in the 'stupidPjax' fallback) 😊 I broke this out as a separate module so that it could be used whereever a noop function is required, which is currently in 2 places in the library... but didn't then update the second usage (in the 'stupidPjax' fallback) 😊
Can you rename the file to Can you rename the file to `noop.js`?
Yes, nice catch, this is why code reviews are important 😉 Yes, nice catch, this is why code reviews are important 😉
|
||||
54
tests/lib/abort-request.js
Normal file
@@ -0,0 +1,54 @@
|
||||
|
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.
|
||||
var tape = require("tape")
|
||||
|
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.
|
||||
var abortRequest = require("../../lib/abort-request.js")
|
||||
|
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 sendRequest = require("../../lib/send-request.js")
|
||||
|
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.
|
||||
// Polyfill responseURL property into XMLHttpRequest if it doesn't exist,
|
||||
|
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.
|
||||
// just for the purposes of this test
|
||||
|
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.
|
||||
// This polyfill is not complete; it won't show the updated location if a
|
||||
|
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.
|
||||
// redirection occurred, but it's fine for our purposes.
|
||||
|
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.
|
||||
if (!("responseURL" in XMLHttpRequest.prototype)) {
|
||||
|
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 nativeOpen = XMLHttpRequest.prototype.open
|
||||
|
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.
|
||||
XMLHttpRequest.prototype.open = function(method, url) {
|
||||
|
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.
|
||||
this.responseURL = url
|
||||
|
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.
|
||||
return nativeOpen.apply(this, arguments)
|
||||
|
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.
|
||||
}
|
||||
|
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.
|
||||
tape("test aborting xhr request", function(t) {
|
||||
|
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 requestCacheBust = sendRequest.bind({
|
||||
|
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.
|
||||
options: {
|
||||
|
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.
|
||||
cacheBust: true,
|
||||
|
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.
|
||||
})
|
||||
|
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.test("- pending request is aborted", function(t) {
|
||||
|
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.equal(r.readyState, 1, "xhr readyState is '1' (SENT)")
|
||||
|
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.
|
||||
abortRequest(r)
|
||||
|
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, 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?
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.status, 0, "xhr HTTP status 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?
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.responseText, "", "xhr response is empty")
|
||||
|
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.end()
|
||||
|
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.test("- request is not aborted if it has already completed", function(t) {
|
||||
|
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/get", {}, 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.
|
||||
abortRequest(r)
|
||||
|
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, 4, "xhr readyState is '4' (DONE)")
|
||||
|
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.status, 200, "xhr HTTP status is '200' (OK)")
|
||||
|
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.end()
|
||||
|
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.
|
||||
})
|
||||
|
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.test("- request is not aborted if it is undefined", function(t) {
|
||||
|
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
|
||||
|
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.
|
||||
try {
|
||||
|
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.
|
||||
abortRequest(r)
|
||||
|
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.
|
||||
catch (e) {
|
||||
|
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("aborting an undefined request threw an error")
|
||||
|
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(typeof r, "undefined", "undefined xhr was ignored")
|
||||
|
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.end()
|
||||
|
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.end()
|
||||
|
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.
|
||||
@@ -1,6 +1,6 @@
|
||||
var tape = require("tape")
|
||||
|
||||
var request = require("../../lib/request.js")
|
||||
var sendRequest = require("../../lib/send-request.js")
|
||||
|
||||
// Polyfill responseURL property into XMLHttpRequest if it doesn't exist,
|
||||
// just for the purposes of this test
|
||||
@@ -18,7 +18,7 @@ tape("test xhr request", function(t) {
|
||||
var url = "https://httpbin.org/get"
|
||||
|
||||
t.test("- request is made, gets a result, and is cache-busted", function(t) {
|
||||
var requestCacheBust = request.bind({
|
||||
var requestCacheBust = sendRequest.bind({
|
||||
options: {
|
||||
cacheBust: true,
|
||||
},
|
||||
@@ -36,7 +36,7 @@ tape("test xhr request", function(t) {
|
||||
})
|
||||
})
|
||||
t.test("- request is not cache-busted when configured not to be", function(t) {
|
||||
var requestNoCacheBust = request.bind({
|
||||
var requestNoCacheBust = sendRequest.bind({
|
||||
options: {
|
||||
cacheBust: false,
|
||||
},
|
||||
Can you change this as well to
noop.js?I can, although half the library uses this Node convention of not appending the module file extension to the require call -- we should probably standardise this one way or the other -- something for #97?
You're right; I didn't notice that.
I guess leave it for now, and make a comment in #97.