Hacking, Software

Firefox Addon: Html Validator

Note: This tutorial is based on Html Validator version 0.8.5.2. The details outlined below may not work in future versions.

When I make web sites, I use quite a few different Firefox extensions.

One of the extensions that I use is called Html Validator https://addons.mozilla.org/en-US/firefox/addon/249

This extension is great.
It main use is to validator the html code when you "view source" in Firefox.
It also has secondary benefit is syntax highlighting.

Html Validator in action.

The Problem

However there is one problem that makes my job harder.

Error: oTidyBrowser is not defined
Source File: chrome://tidy/content/tidyBrowser.js
Line: 220

This shows up countless times in Firefox's error console, making the job of finding other errors really hard.

I am going to show you how to stop this error.
(If this bug isn't fix in the latest release, then you have to reapply this patch)

Solution to "oTidyBrowser is not defined"

The first step is locating the above file.

I can't give you direct link to it, because of Firefox stores it in profile folder.
The Firefox profile folder, which will have a different name.

My Html Validator location is:
C:UsersDanAppDataRoamingMozillaFirefoxProfilesvqy7rs08.defaultextensions{3b56bcc7-54e5-44a2-9b44-66c3ef58c13e}chrome

Clicking on the file, "chrome://tidy/content/tidyBrowser.js," in the error console, will bring up the source code for this file.
The title of the window will be actual file path to the file in question.

When you get to the chrome folder you will be looking for a file called "tidy.jar"

The file "tidy.jar" is really a zip file.

Now duplicate this file and call it "tidy.zip".

Open "tidy.zip" in your favourite file compression utility (Try Winzip or Winrar, if you don't have one).

You now need to edit the file "content/tidyBrowser.js".

The section of code you are looking for is:

  1. if( oTidyBrowser.bTopLoadBusy==false )
  2. {
  3.  oTidyUtil.tidy.log( '<javascript>tidyEndDocumentLoadObserver' );
  4.  oTidyBrowser.bTopLoadBusy = true;
  5.  try
  6.  {
  7.   // Validate the 1rst request
  8.   oTidyBrowser.bIgnorePageShow = true;
  9.   oTidyBrowser.validateFrame( window.content );
  10.   // oTidyBrowser.validateCache( subject.document, true );
  11.  
  12.   // Process the events that fired during the 1rst one
  13.   // ex: page with frames.
  14.   var doc = oTidyBrowser.oEventQueue.pop();
  15.   while( doc )
  16.   {
  17.    oTidyBrowser.validateCache( doc, true );
  18.    doc = oTidyBrowser.oEventQueue.pop();
  19.   }
  20.  }
  21.  catch(ex)
  22.  {
  23.   tidyShowExceptionInConsole( ex );
  24.  }
  25.  oTidyBrowser.bTopLoadBusy = false;
  26. }
  27. else
  28. {
  29.  // Parallel events are placed in a event queue.
  30.  oTidyBrowser.oEventQueue.push( event.originalTarget );
  31. }

What you need to do is add an if statement to check if "oTidyBrowser" is not defined.
This will have the effect of stopping the error from appearing in the error console.

  1. if( !window.oTidyBrowser )
  2. {
  3.  // Do nothing
  4. }
  5. else if( oTidyBrowser.bTopLoadBusy==false )
  6. {
  7.  oTidyUtil.tidy.log( '<javascript>tidyEndDocumentLoadObserver' );
  8.  oTidyBrowser.bTopLoadBusy = true;
  9.  try
  10.  {
  11.   // Validate the 1rst request
  12.   oTidyBrowser.bIgnorePageShow = true;
  13.   oTidyBrowser.validateFrame( window.content );
  14.   // oTidyBrowser.validateCache( subject.document, true );
  15.  
  16.   // Process the events that fired during the 1rst one
  17.   // ex: page with frames.
  18.   var doc = oTidyBrowser.oEventQueue.pop();
  19.   while( doc )
  20.   {
  21.    oTidyBrowser.validateCache( doc, true );
  22.    doc = oTidyBrowser.oEventQueue.pop();
  23.   }
  24.  }
  25.  catch(ex)
  26.  {
  27.   tidyShowExceptionInConsole( ex );
  28.  }
  29.  oTidyBrowser.bTopLoadBusy = false;
  30. }
  31. else
  32. {
  33.  // Parallel events are placed in a event queue.
  34.  oTidyBrowser.oEventQueue.push( event.originalTarget );
  35. }

Now save tidyBrowser.js back to "tidy.zip".

At this point you will need to close Firefox, as it will currently have locked the original file.

You can now either delete "tidy.jar" or rename it.
Renaming the file is good idea, as you you can easily revert back if you encounter problems.
Rename "tidy.zip" to "tidy.jar".

Now you can restart Firefox.
You will now no longer suffer the error message, "oTidyBrowser is not defined".

Cheat

If you want to save time, you can download "tidy.jar", to replace your own copy.

I can't make any warrenties to the file's safety. If there is any doubt use my instructions.

Use this file at your own risk.

Tags: 0.8.5.2, bug, error console, firefox, html validator, Line 220, oTidyBrowser is not defined, Source File chrome tidyBrowser.js

comments powered by Disqus