firefox extension to cache ajax pages

28
Total Recall for Ajax Applications – Firefox extension Smita Periyapatna 15 th May, 2009 Advisor: Dr.Pollett

Upload: sampetruda

Post on 01-Nov-2014

1.916 views

Category:

Documents


2 download

DESCRIPTION

 

TRANSCRIPT

Page 1: Firefox extension to cache Ajax pages

Total Recall for Ajax Applications – Firefox extension

Smita Periyapatna

15th May, 2009

Advisor: Dr.Pollett

Page 2: Firefox extension to cache Ajax pages

Agenda

Problem Solution Technologies Used Extension Creation User Interface Caching mechanism Flex Application Usability Testing Conclusion

Page 3: Firefox extension to cache Ajax pages

Problem

Ajax, or AJAX (Asynchronous JavaScript and XML), is a group of interrelated web development techniques used to create interactive web applications or rich Internet applications.

Ajax applications update parts of the page at any time, giving users an instantaneous response to their inputs and queries.

One of the biggest problem of these AJAX applications is the stateless ness.

The states of the applications are not cached within the browser and stored in the user’s computer for fast reference in case the user opted to use the back button.

Page 4: Firefox extension to cache Ajax pages

Solution We have developed an addon to the Mozilla’s

Firefox browser

Our project involved extending the functionality of the browser to save the states of an Ajax page.

The states are cached in a way similar to storing normal history items.

This will allow users to go back to the last place they left it, instead of going to the original state of their AJAX application.

Page 5: Firefox extension to cache Ajax pages

Technologies Used XUL

XUL is an XML based user interface markup language developed by Mozilla. XUL provides a rich set of UI components.

For my extension, XUL is used to create the user interface (buttons on the tool bar) and the preference system.

Javascript The scripting language used in the browser Chrome to handle

events and programming. Javascript is used to handle all the user generated events and to

communicate with the XPCOM interfaces used in our extension. XPCOM

XPCOM is a standard cross-platform object model provided by Mozilla that exposes a core set of components and interfaces.

XPCOM interfaces were used for the preference system, storing and retrieving of pages from the cache.

Page 6: Firefox extension to cache Ajax pages

Technologies Used….(contd)

CSS Cascading Style Sheets (CSS) are used to describe the look and

formatting of a document written in a markup language. For our extension CSS was used to style the icons on the

toolbar. The icons were taken from http://www.icons-gallery.com/ Flex/Actionscript

Our extension supports saving states of a page in a Flex application, written by using our jsChromeBridge API. A test application is developed using Flex and show the saving of states.

Flex is used for development and deployment of cross-platform rich Internet applications(RIA). ActionScript is used primarily for the development of websites and software using the Adobe Flash Player platform.

Page 7: Firefox extension to cache Ajax pages

Setting up directory structure

install.rdf is used to determine information about an extension as it is being installed. It contains metadata identifying the extension, providing information about who created it, version, etc

The chrome.manifest tells Firefox the location of the chrome packages files and overlays.

The chrome.manifest files also contains the location of the content directory which has the XUL and Javascript files, Skin which has the images and CSS files and Locale which has the DTD and .properties files.

Page 8: Firefox extension to cache Ajax pages

User Interface

The user interface consists of four buttons: Start, Stop, microForward, and microBack.

Caching starts when a user clicks the play button on the toolbar. Clicking on the stop button will stop the caching.

microForward and microBack button allows users to navigate through the cache history.

Page 9: Firefox extension to cache Ajax pages

User Interface….(contd)

this.forward.setAttribute('id',"myextension-forwardbutton");this.forward.setAttribute('label',"myForwardButton");this.forward.setAttribute('class',"toolbarbutton-1 chromeclass-toolbar-

additional");this.forward.setAttribute('tooltiptext',"cacheForwardButton");this.forward.setAttribute('type',"menu-button");this.forward.setAttribute('disabled',"true");//this.forward.setAttribute('datasources',"rdf:null");

//forwardChild = document.createElement("menupopup");this.forwardpopup.setAttribute('id',"forwardpopup");this.forwardpopup.setAttribute('context',"");this.forward.appendChild(this.forwardpopup);

var node2 = document.getElementById("reload-button");navbar.insertBefore(this.forward,node2);

Page 10: Firefox extension to cache Ajax pages

Preferences

Preferences set via user interface, usually a preference dialog, takes effect immediately.

Users can set the time interval for caching at any time.

Page 11: Firefox extension to cache Ajax pages

Caching Mechanism

The caching starts after clicking the start button. When the content is cached a new menu item is

added to the microBack button’s popup menu, with the title of the page as its label.

When the microBack button is clicked the most recent menu item gets appended to the microForward button’s popup menu while it gets deleted from the microBack button’s popup menu.

Clicking the stop button stops caching of pages.

Page 12: Firefox extension to cache Ajax pages

Caching Mechanism….(contd)var nsCacheService = Components.classes["@mozilla.org/network/cache-service;1"];var service = nsCacheService.getService(Components.interfaces.nsICacheService);var outputEntry = buttonsObj[countT].myHist.openCacheEntry(this.nsICache.ACCESS_WRITE); var output = outputEntry.openOutputStream(0, -1, 0);if (output.write(stg, stg.length) != stg.length) alert("disk cache write broken!");var inputEntry = buttonsObj[countT].myHist.openCacheEntry(this.nsICache.ACCESS_READ);var input = buttonsObj[countT].myHist.wrapInputStream(inputEntry.openInputStream(0, -1, 0));var d = input.read(input.available());

Page 13: Firefox extension to cache Ajax pages

Caching Mechanism….(contd)

Page 14: Firefox extension to cache Ajax pages

Multiple Tabbed Browsing

The functionalities provided by our extension, which is mentioned in the above sections, have been implemented in case of multiple tabs also.

The tab count is used as one of the combinations to create the key, which is used as an index to retrieve data from cache.

Page 15: Firefox extension to cache Ajax pages

Multiple Tabbed Browsing

var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"].getService(Components.interfaces.nsIWindowMediator);

var browserEnumerator = wm.getEnumerator("navigator:browser");var tabbrowser = browserEnumerator.getNext().getBrowser();

//Events to captured TabOpen,TabClose and TabMovewindow.getBrowser().addEventListener("TabOpen", function e(){callbackLoad();}, false);window.getBrowser().addEventListener("TabClose",callTabClose,false);window.getBrowser().addEventListener("TabSelect",callTabMove,false);

Page 16: Firefox extension to cache Ajax pages

Multiple Tabbed Browsing

Page 17: Firefox extension to cache Ajax pages

Flex Application

Flex applications do not allow users to navigate through the various states of the application by using the web browser's back and forward navigation commands.

Developed an API, which would allow users to capture the states of a Flex application.

Page 18: Firefox extension to cache Ajax pages

Flex Application (contd)

Page 19: Firefox extension to cache Ajax pages

Usability Test Feedback

The users were not aware of the fact that Ajax clicks are not saved as the normal history items.

They were getting confused about the actual history items and the history stored by our extension.

Page 20: Firefox extension to cache Ajax pages

Usability Test Feedback….(contd) Students from Ateneo de Davao University,

Philippines have downloaded my extension from the Mozilla addons website.

“I already tried the extension. I tried it with yahoo mail and google map. I see no problem with the back button, but when I hit the forward button, it causes the URL to change all into numeric. As I observed, there are alerts that popped up. May be those were testers alerts. It is working.”

Page 21: Firefox extension to cache Ajax pages

Response to the feedback

The alert statements were the debug statements, which have been removed.

The numeric number that comes on the address bar while navigating through the microBack and microForward buttons have been changed to the actual URL of the page.

Page 22: Firefox extension to cache Ajax pages

Websites Tested

Website ResultsNetflix’s website uses AJAX to display the movies details

on mouse-over. Achieving this without AJAX would be

very impractical, because the graphics text adds takes

long to download. AJAX makes this page interesting by

requesting the data for each movie from the server and putting it onto the page without re-loading.

Passed

A9 is Amazon.com's search engine. A9 uses AJAX to display the result of the search by dynamically adding column according to the selected resources. One can easily toggle these search areas on or off without researching or reloading the page.

Passed

Netvibes is an AJAX based website, where in users can add new widgets or delete widgets. The page’s layout is in form of tabs, each tab containing some user defined modules. Navigating between tabs, adding and deleting of widgets is done using AJAX.

Passed

Page 23: Firefox extension to cache Ajax pages
Page 24: Firefox extension to cache Ajax pages
Page 25: Firefox extension to cache Ajax pages

Submission to AMO

The extension, the .xpi file, is submitted to Mozilla’s addons website as an experimental addon. The addon works for all platforms and it works for Mozilla Firefox 3.0.* as well.

Page 26: Firefox extension to cache Ajax pages

Conclusion

Mozilla documentation to build an extension are very good.

XPCOM interfaces are poorly documented.

We had to go through the Firefox code to figure out stuff.

We also faced challenges when extending the functionality to Flex application because of lack of documentation on interaction between Chrome and Javascript.

Page 27: Firefox extension to cache Ajax pages

References

Creating Applications with Mozilla. David Boswell. O'Reilly. 2002. Official page of Mozilla.http://developer.mozilla.org/en/docs/Building_an_Extension XUL Tutorial and XPCOM Reference.http://www.xulplanet.com/ JavaScript Reference.http://www.w3schools.com/jsref/default.asp RDF referencehttp://developer.mozilla.org/en/docs/RDF_in_Fifty_Words_or_Less Mozilla Developer Center XPCOM Retrieved May 01, 2008http://developer.mozilla.org/en/docs/XPCOM Flex Developer’s Guidehttp://livedocs.adobe.com/ Icons gallery http://www.icons-gallery.com/

Page 28: Firefox extension to cache Ajax pages

Thank You

Q&A