Java Reference
In-Depth Information
the technologies relevant to testing each tier. We end by looking at the unique testing
challenges presented by Google Web Toolkit ( GWT ) applications. We start by review-
ing Ajax and why testing is difficult.
13.1
Why are Ajax applications difficult to test?
In 2005, the article “A New Approach to Web Applications” 1 coined the term Ajax
to describe the architecture of a new generation of web applications like Google
Maps 2 and Google Suggest. 3 These new applications were richer, more interactive,
and more responsive than their predecessors. Critical to the user experience, they
left behind the need to constantly reload or refresh an entire web page to keep any
portion of its information updated. Although still browser based, these applications
started to give the web the look and feel of what had been strictly the domain of
desktop applications.
Although Ajax is often associated with its all-uppercase sibling AJAX , the acronym,
it's today much more than Asynchronous JavaScript and XML . You build an Ajax appli-
cation by combining the following technologies: CSS , DOM , JavaScript, server-side
scripting, HTML , HTTP , and web remoting ( XMLH ttpRequest).
Beyond its associated technologies, Ajax reflects the mindset of a new breed of web
applications built on standards and designed to give users a rich and interactive expe-
rience. In this chapter, we study how to test these applications.
To understand the challenge of testing an Ajax application, let's look at a web-
classic interaction and then step through the stages of an Ajax application interaction.
13.1.1
Web-classic interaction
In a web-classic interaction, the user opens the browser on a page, and each time the
page needs data, it asks the server for a new page. Figure 13.1 illustrates this process.
13.1.2
Ajax interaction
In an Ajax application, the page communicates with the server to get data for the
part of the page that needs updating and then updates only that part of the page.
Figure 13.2 illustrates this process.
The user starts by opening an Ajax application's start page in a browser; this
causes the HTML page to load. The browser displays the HTML using any associated
CSS and runs client-side JavaScript code to set up the page's event handlers. The
page is now ready to respond to user interactions. The user interacts with the page,
triggering a JavaScript event handler. In an application like Google Suggest, each
keystroke creates a server request for a list of suggestions that are displayed in a
drop-down list box. The JavaScript event handler builds an XHR object and calls the
server with a specific request using HTTP . The XHR object includes a JavaScript
1
http://www.adaptivepath.com/ideas/essays/archives/000385.php
2
http://maps.google.com/
3
http://www.google.com/webhp?complete=1&hl=en
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Search WWH ::




Custom Search