HTML and CSS Reference
In-Depth Information
Listing 13.40 Adding a cache buster
function start() {
/* ... */
var requestStart = new Date().getTime();
/* ... */
ajax.request(this.url + "?" + requestStart, {
/* ... */
Although the cache buster test passes, the test from Listing 13.11 now fails
because it is expecting the unmodified URL to be used. The URL is now being
tested in a dedicated test, and the URL comparison in the original test can be
As we discussed in the previous chapter, adding query parameters to arbitrary
URLs such as here will break if the URL already includes query parameters. Testing
for such a URL and updating the implementation is left as an exercise.
13.3.3 Feature Tests
As we did with the request interface, we will guard the poller with feature de-
tection, making sure we don't define the interface if it cannot be successfully used.
Listing 13.41 shows the required tests.
Listing 13.41 Poller feature tests
(function () {
if (typeof tddjs == "undefined") {
var ajax = tddjs.namespace("ajax");
if (!ajax.request
!Object.create) {
/* ... */
Search WWH ::

Custom Search