HTML and CSS Reference
In-Depth Information
Abstracting Browser
Differences: Ajax
A jax, (asynchronous JavaScript and XML) is a marketing term coined to
describe client technologies used to create rich internet applications, with the
XMLHttpRequest object at the center stage. It's used heavily across the web,
usually through some JavaScript library.
In this chapter we will get to know XMLHttpRequest better by implementing
our own higher level API using test-driven development. Doing so will allow us to
touch ever so lightly on the inner workings of an “ajax call”; it will teach us how to
use test-driven development to abstract browser inconsistencies; and most impor-
tantly, it will give us an introduction to the concept of stubbing.
The API we will build in this chapter will not be the ultimate XMLHttp-
Request abstraction, but it will provide a bare minimum to work with asyn-
chronous requests. Implementing just what we need is one of the guiding principles
of test-driven development, and paving the road with tests will allow us to go just
as far as we need, providing a solid base for future extension.
12.1 Test Driving a Request API
Before we get started, we need to plan how we will be using test-driven development
to abstract browser inconsistencies. TDD can help discover inconsistencies to some
degree, but the nature of some bugs are so obscure that unit tests are unlikely to
discover them all by accident.
Search WWH ::

Custom Search