[Dojo-interest] [1.02] ReferenceError: "navigator" running tests in Rhino

James Burke jburke at dojotoolkit.org
Mon Dec 24 16:59:16 UTC 2007


The built version that you get from the 1.0.2 download location (not
the -src file) is built for the browser, and not for rhino. Running
that version with rhino and DOH can produce the "navigator" issue.

Dojo can be run in the browser or in rhino, but the built versions we
put on the website are only for running in the browser. We do not
support auto-detection of the environment in the built version to cut
down on the size of dojo.js and the vast majority of users only care
about the browser version. So, for running in rhino, you will need to
get the -src download or grab the source from subversion.

DOH does not provide a simulation of the browser environment in rhino.
Instead, it runs directly in a browser. If you go to the tests
directory in each major project (like dojo or dijit), you should see a
runTests.html. Open that in the browser of your choice, and DOH will
run the tests in that browser.

The tests that run in rhino are the non-browser tests (normally the
pure JS tests). There may be a reporting issue with the number of
tests (I have not confirmed how it calculates the numbers or how it
reports what tests are run), but while it does use the same master
test file for Dojo core (dojo/tests/module.js), some tests are
excluded by checking to see if dojo.isBrowser is true. It will be
false for the rhino case, so those tests will be skipped. Also note
that while it looks like some tests in dojo/tests/module.js seem to be
included for the rhino enviroment, if you look inside the specific
tests being dojo.required, they may do the dojo.isBrowser check within
that test file.

James

On Dec 23, 2007 10:47 PM, Kalle Korhonen <kalle.o.korhonen at gmail.com> wrote:
> Well, what do you know, that's exactly true: I checked out the tag for 1.0.2
> and running the tests in rhino does work! Then I searched for "navigator" in
> dojo.js and I found no references. However, if I get the zipped up release
> from http://download.dojotoolkit.org/release-1.0.2/ and open dojo.js, I
> found multiple references. So, I wonder what's going on? Is this some
> special build of the same source or just completely different versions?
>
> Furthermore, making the navigator object exist alone doesn't solve the whole
> browser emulation problem. I found no references in the documentation as to
> how and where it's done in Dojo and its DOH framework; only the one liner "
> When run from the command line, only pure-JS test are run" in
> http://dojotoolkit.org/book/dojo-book-0-9/part-4-meta-dojo/d-o-h-unit-testing.
> However, running from against the sources of 1.0.2 tag, it seems all 326
> tests were run. Crosscheck (http://www.thefrontside.net/crosscheck) seems to
> do a better job at explaining the browser testing issues and explicitly
> supporting multiple different browser emulation environment.
>
> From the dojo documentation, it's really not clear to me whether or not I
> can expect pure Javascript/Dojo tests to succeed in non-browser environments
> and whether DOH supports emulating any parts of browser environment or not.
>
> Kalle
>
>
>
>
> On 12/22/07, James Burke <jburke at dojotoolkit.org> wrote:
> >
> >
> >
> > On Dec 18, 2007 8:41 AM, Kalle Korhonen <kalle.o.korhonen at gmail.com>
> wrote:
> > > I'm trying to run the core dojo tests with java -jar custom_rhino.jar
> > > runner.js , but it fails with:
> > > js: uncaught JavaScript runtime exception: ReferenceError: "navigator"
> is
> > > not defined. The same works in browser and with an older version of dojo
> (
> > > 0.9). runner.html doesn't seem require any other dependencies, but
> obviously
> > > the navigator object is created by the browser. The custom_rhino.jar is
> from
> > > 0.9 (the latest in trunk looks corrupted).  If I create a fake navigator
> > > object myself in dojo.js, I get further along. Any ideas how to fix
> this?
> >
> > I just downloaded the 1.0.2 source, and ran this command from the
> > util/doh directory:
> > > java -jar ../shrinksafe/custom_rhino.jar runner.js
> >
> > and that seemed to complete without a "navigator" error.
> >
> > James
> > _______________________________________________
> > FAQ: http://dojotoolkit.org/support/faq
> > Book: http://dojotoolkit.org/docs/book
> > Forums: http://dojotoolkit.org/forum
> > Dojo-interest at dojotoolkit.org
> > http://dojotoolkit.org/mailman/listinfo/dojo-interest
> >
>
>
> _______________________________________________
> FAQ: http://dojotoolkit.org/support/faq
> Book: http://dojotoolkit.org/docs/book
> Forums: http://dojotoolkit.org/forum
> Dojo-interest at dojotoolkit.org
> http://dojotoolkit.org/mailman/listinfo/dojo-interest
>
>


More information about the Dojo-interest mailing list