I've been working on getting jquery to work with caja, and I just got
a jquery gadget working with caja yesterday. There are two changes
submitted to jquery itself (4251, 4270) and one more that needs to go
into caja.
> I'm currently stuck with the jQuery star rating plugin not working, it
> throws an error I haven't come across before:
>
> [Exception... "'TypeError: Cannot read property "elem" from undefined'
> when calling method: [nsIDOMEventListener::handleEvent]" nsresult:
> "0x8057001c (NS_ERROR_XPC_JS_THREW_JS_OBJECT)" location: "<unknown>"
> data: no]
>
> It is without location information or a stack trace, but happens only
> when clicking on the ratings icons.
The jquery library regularly assumes that the entire DOM is
implemented and does not check return values to see if they are
objects on which it can read properties; in this case, some method
returned undefined and it tried to read the property "elem" on it.
If you can send us jquery.html, we can have a look and see what's
causing the error--that may be a new bug in the cajoler.
--
Mike Stay - meta...@gmail.com
http://math.ucr.edu/~mike
http://reperiendi.wordpress.com
On Wed, Mar 18, 2009 at 10:32 PM, Mike Stay <meta...@gmail.com> wrote:
>
> On Wed, Mar 18, 2009 at 2:46 PM, Matthew Wild <MWi...@gmail.com> wrote:
>>
>> Hi all,
>>
>> I'm fairly new to using Caja, but have managed to get to grips with
>> most of the concepts.
>>
>> We are looking to embed third-party plugins/gadgets into our site.
>> Ideally we would like to provide jQuery to gadget developers, and am
>> wondering about the current status of jQuery in Caja at the moment.
>
> I've been working on getting jquery to work with caja, and I just got
> a jquery gadget working with caja yesterday. There are two changes
> submitted to jquery itself (4251, 4270) and one more that needs to go
> into caja.
>
I'm guessing 4251/4270 refer to jQuery changesets/revisions?
>> I'm currently stuck with the jQuery star rating plugin not working, it
>> throws an error I haven't come across before:
>>
>> [Exception... "'TypeError: Cannot read property "elem" from undefined'
>> when calling method: [nsIDOMEventListener::handleEvent]" nsresult:
>> "0x8057001c (NS_ERROR_XPC_JS_THREW_JS_OBJECT)" location: "<unknown>"
>> data: no]
>>
>> It is without location information or a stack trace, but happens only
>> when clicking on the ratings icons.
>
> The jquery library regularly assumes that the entire DOM is
> implemented and does not check return values to see if they are
> objects on which it can read properties; in this case, some method
> returned undefined and it tried to read the property "elem" on it.
>
So I guess this is also a problem in my code. I'll check it over.
>> Suggestions on where to begin debugging would be appreciated. I tried
>> the "sidebyside" renderer without success, receiving this unhandled
>> exception:
>>
>> Command: $ ./pristine/google-caja-read-only/bin/cajole_html -i
>> jquery.html -a -r sidebyside
>>
>> java.lang.IndexOutOfBoundsException: Index: 5, Size: 5
>> at java.util.ArrayList.rangeCheck(ArrayList.java:571)
>> at java.util.ArrayList.get(ArrayList.java:349)
>> at
>> com.google.caja.render.SourceSnippetRenderer.addEvidenceForCurrentMark
>> (SourceSnippetRenderer.java:243)
>> at com.google.caja.render.SourceSnippetRenderer.processCurrentMark
>> (SourceSnippetRenderer.java:225)
>> at com.google.caja.render.SourceSnippetRenderer.noMoreTokens
>> (SourceSnippetRenderer.java:196)
>> at com.google.caja.plugin.PluginCompilerMain.writeFileNonDebug
>> (PluginCompilerMain.java:243)
>> at com.google.caja.plugin.PluginCompilerMain.writeFile
>> (PluginCompilerMain.java:212)
>> at com.google.caja.plugin.PluginCompilerMain.run
>> (PluginCompilerMain.java:125)
>> at com.google.caja.plugin.PluginCompilerMain.main
>> (PluginCompilerMain.java:329)
>>
>> I'm using the latest code from SVN. Is this my mistake, or a bug?
>>
> If you can send us jquery.html, we can have a look and see what's
> causing the error--that may be a new bug in the cajoler.
>
I trimmed it right down to just this line:
<script type="text/javascript" src="jquery.js"></script>
and jquery.js in the same folder, version 1.2.6 from the Caja
experimental/jquery/tests/ folder.
I still get the traceback, although the index in
"java.lang.IndexOutOfBoundsException: Index: 1, Size: 1" decreased
with each line I removed (it essentially stays in step with the number
of lines in the file).
I have uploaded the exact files I am using to:
http://matthewwild.co.uk/uploads/jquery-caja-fail.tar.gz (unpacks
jquery.html and jquery.js into the current directory)
Hope this helps,
Matthew.
Yes, on the latest revision of jQuery 1.3.2
> and jquery.js in the same folder, version 1.2.6 from the Caja
Oh! That version is horribly out of date, sorry! Find attached a
patch for the latest version of jQuery (6292) [this includes the
patches mentioned above].
Cajole the index page in the test folder:
google-caja/bin/cajole_html -i index.html -o index.js -a
Included in the patch is hostpage.html that hosts the cajoled output, index.js.
Also attached is a stopgap patch for FileSystemEnvironment.java. At
the moment (in trunk) you're only allowed to link to files under the
same directory. This patch allows you to link to arbitrary URLs. If
you want to rewrite those URLs to use your proxy or something, then
change this file. Eventually we'll have a config file for this.
Thanks. When building the index.html for jQuery, I get:
WARNING: index.html:14+33 - 36: failed to load external url
../dist/jquery.js
I added || uristr.startsWith("../") [also tried file://] to the
condition in FileSystemEnvironment.java, but it seemed to make no
difference. I suspect I'm looking in the wrong place.
Anyhow, I copied jquery.js to the test/ directory, and fixed
index.html for this. Next cajole_html failed with:
ERROR: testsuite.css:50+11 - 15: css property opacity has bad
value: ==>auto<==
I commented out the <link> line from index.html and cajole_html
succeeded (with some LINT/WARNING messages about folding tags).
Loading up the hostpage.html in Firefox caused Firefox to lock up. No
idea how to debug that one. Eventually I managed to get the page
loaded, and was greeted with nothing but these errors in Firebug:
http://matthewwild.co.uk/uploads/jquery-cajoled-test-errors.png
Changing course I decided to try the new cajoled jquery with my simple
test gadget. Everything works fine until I load it up in Firefox,
where it throws: "not found: $".
I have collected together what I hope to be all the files and
dependencies into this tarball, should you wish to have a look:
http://matthewwild.co.uk/uploads/caja-jquery-not-found.tar.gz
Hopefully I'm missing something simple.
Also, attempting to use -r sidebyside on jquery.html still triggers an
exception (see previous email).
Many thanks for your help so far!
Matthew.
--
On Tue, Mar 24, 2009 at 3:49 PM, Mike Stay <meta...@gmail.com> wrote:
>
> Hi--I spent a while yesterday working on this. Turns out that "svn
> diff" won't give you differences in external dependencies (like qunit/
> under test/) so there were bits missing from the patch I sent you.
> Also, when I updated both jquery and caja, something stopped working.
That's the way it tends to go in computing. :)
> I won't be working on it today--I'm moving house--but I'll probably
> have it all working for you by the end of Wednesday.
>
Likewise, so I know how it is.
Many thanks for your help, I'll be standing by.
Matthew.
cd ~/caja/svn-changes
mkdir fresh
cd fresh
svn checkout http://google-caja.googlecode.com/svn/trunk/ google-caja
cd google-caja
patch -p0 < /tmp/fsediff
ant
ant testbed
cd ~/jquery
svn co http://jqueryjs.googlecode.com/svn/trunk .
cd jquery
patch -p0 < /tmp/jqdiff
make
cd test
ln -s ~/caja/svn-changes/fresh/google-caja/ant-www/testbed caja
ln -s ../dist/jquery.js
~/caja/svn-changes/fresh/google-caja/bin/cajole_html -i index.html -o
index.js -a -r sidebyside
Now browse to ~/jquery/jquery/test/hostpage.html to see the jquery tests.
This will take a *long* time (minutes) to render completely, and locks
up the browser thread in the meantime. But it eventually finishes, so
just let it go.