How to Improve Web Site Compatibility

Bob Clary

bclary.com

Browser Wars I

Internet Explorer won the initial battle of the browser war which has resulted in web sites which have been developed with only one requirement:

that they work in IE.

Browser Wars II

The next battle in the Browser Wars will be led by technically savvy users demanding the right to choose their own browser.

Web Developers are faced with the ever increasing number of visitors using Mozilla, Mozilla Firefox, Safari and Opera as users defect from Internet Explorer.

But wide-spread adoption of alternative browsers is impeded by the large base Internet Explorer only content which exists on the Web.

The Web Site Developer's Dilemma

How can a web site owner update their content quickly to support the increasing number of visitors using alternative browsers while keeping the cost and effort of updating their content under control?

The Browser Developer's Dilemma

How can browser developers lower the barrier to adoption of their browser by determining which features have the best bang for the buck in terms of improving support on legacy IE-centric sites?

Use Mozilla

Mozilla's excellent support for W3C recommendations such as CSS and the DOM as well as arguably the best implementation of JavaScript provide a benchmark browser implementation with which to develop and test new content.

Mozilla's suite of interactive web developer tools such as the JavaScript Console, the Venkman JavaScript debugger and the DOM Inspector can help developers and quality assurance ensure that the web sites they build are compatible with the widest range of browsers.

Mozilla's rich set of reporting features can help locate and fix many errors which affect all modern browsers.

Mozilla as QA Tool

Mozilla's application development framework provides the ability to extend Mozilla to provide custom solutions as well as the ability to incorporate Mozilla into an automated testing framework which can test web sites for errors, test script APIs, identify common web site incompatibilities as well as test the Mozilla browser implementation itself.

Web Site Testing Strategy

  1. Locate and fix all JavaScript Errors
  2. Locate all Pages which invoke Standards Mode Layout.
  3. Locate and eliminate all CSS MIME Errors
  4. Locate and eliminate CSS Errors
  5. Check uses of ActiveX and Plugins
  6. Investigate JavaScript Warnings for potential problems
  7. Analyse Errors and educate your developers
  8. Use Mozilla to develop and test new content
  9. Require new content to pass Error checks
  10. Periodically Recheck content and investigate changes

Mozilla's Reporting Facilities

JavaScript Console

NSPR Logs

STDOUT and STDERR

For an excellent introduction to the interactive tools such as the Venkman JavaScript Debugger and the DOM Inspector which are available in Mozilla, see Henrik Gemal's Using Mozilla in testing and debugging web sites <http://gemal.dk/mozilla/mozdev.html>

Example Web Page

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>This is an Example HTML Page</title>
<link rel="stylesheet" type="text/css" href="example-css.htm">
<link rel="stylesheet" type="text/css" href="example-css.css">
<style type="text/css">
body {color: wite; background-cokor: #fff;}
#message { color: ccc; background-color: #FFFFFFF;}
</style>
<script type="text/javascript">
function init()
{
  // set a cookie
  document.cookie ='what=Cookies are delicious delicacies';
  // this call to document.all only works in MSIE browsers
  // and will cause an error in Mozilla
  var elm = document.all['message'];
  elm.style.backgroundColor = 'blue';
  elm.style.color = 'yellow';
}
</script>
</head>
<body onload="init()">
<p id="message">Hello World!</p>
<p id="message">Goodbye World!</p>
</body>
</html>

Basic JavaScript Console Output

Mozilla 1.7 and Firefox 1.0 builds report CSS Mime and JavaScript Errors and Warnings to the JavaScript Console however there is no reporting of CSS parsing errors. Mozilla 1.8 and Firefox 1.1 will automatically report CSS parsing errors.

While this level of information is useful, it falls far short of being complete. The JavaScript Console has other limitations such as the limited number of messages it can contain before older messages are lost.

NSPR Logs

set NSPR_LOG_MODULES=JSDiagnostics:3,nsHttp:3,cookie:4 
        mozilla > test.log 2>&1

This NSPR Log provides a great deal of useful information concerning the HTTP requests and responses as well as the JavaScript Warnings and Errors however it does not include the CSS MIME error found in the JavaScript Console nor does it provide any additional information on the CSS Parsing errors found in the content.

Basic Reporting Summary

Basic JavaScript Console output
  • Mozilla 1.7 and Firefox 1.0 do not include CSS Parsing errors however Mozilla 1.8 and Firefox 1.1 will.
  • Limited in number of messages it can contain.
  • Not directed to STDOUT or STDERR.
NSPR Logs
  • Provide JavaScript Errors and Warnings as well as HTTP related information, but does not contain CSS Parsing Errors or JavaScript Console messages.

Enable CSS Parsing Errors Reporting

You can enable CSS Parsing Error Reporting in Mozilla 1.7 and Firefox 1.1 by adding the following to configure.in, regenerate configure using /usr/autotool/stable/bin/autoconf then build Mozilla or Firefox.

dnl = enable CSS Parser Error Reporting
dnl =
dnl ========================================================
if test "$CSS_REPORT_PARSE_ERRORS"; then
AC_DEFINE(CSS_REPORT_PARSE_ERRORS)
fi

AC_SUBST(CSS_REPORT_PARSE_ERRORS)

dnl ========================================================

Note this is not necessary in Mozilla or Firefox trunk nightly builds.

Enhanced JavaScript Console Output

The addition of CSS Parsing Error Reporting provides extremely valuable feedback for your web developers and quality assurance teams.

Mozilla Spider

Spider is a Mozilla Web Application implemented upon a Web Spider framework first introduced on DevEdge in June 2003 as CSpider. Spider can be run as an HTML Web application, as a Remote XUL Application or as a Chrome application in Mozilla Seamonkey.

Spider is a cost-effective, free, entry level testing tool which can help web site developers and quality assurance to implement a testing strategy to locate and fix errors in a web site.

Spider Features

Can quickly visit an entire site producing a complete record of all Errors and Warnings.

Captures messages sent to the JavaScript Console and copies them to STDOUT.

Can be extended to analyse the contents of a site to report on topics such as HTML Validation, Page Layout mode, Plugins or ActiveX controls, simulate mouse over/out events, and send results to external web applications.

Case Study

Spider was used to test the 70 popular web sites in Mozilla 1.7 and Mozilla 1.8 to locate JavaScript and CSS Warnings and Errors and to use hook scripts to detect:

Concluding Thoughts

Mozilla's adherence to public standards and its ability to report errors in JavaScript and CSS can help web developers and quality assurance testers deploy higher quality content at a reduced cost.

Resources