Jquery Unit Test as Page Mod

48 views
Skip to first unread message

Cid Dennis

unread,
Oct 11, 2010, 3:29:57 PM10/11/10
to mozilla-la...@googlegroups.com
So after hitting my head against the wall for a while I decided to port the current jquery unit test to a page-mod to see what will not or does not work at this point. Attached is that test page-mode with everything need to to run the test in side a page-mod and outside the page-mod.

As you will see when run outside the page-mod most of the test pass in firefox. But when done inside a page-mode only a few pass and the test end before they finish because of some unknown error.

I thought this would help in testing the page-mod code so that it could run jquery and frameworks like jquery.

When you extract the file there is a readme.txt that gives instructions on how to run.


firefox_jquery_test.zip

Cid Dennis

unread,
Oct 21, 2010, 1:22:31 PM10/21/10
to mozilla-labs-jetpack
I just tried the test again with 0.9 and the test still fail.

I think we these test were to pass it would be a good way to verify
that complex javascript libraries would in fact work with jetpacks.

Any idea when or if full jquery support will be avaiable?

BTW: Thanks a lot for all the hard work I really think jetpack are
going to make plugin development a lot easier.

mark

unread,
Oct 27, 2010, 3:09:45 AM10/27/10
to mozilla-labs-jetpack
Hey, would you mind posting the results of this test on 0.9
somewhere?
I haven't been able to set up a local web server to run it myself, but
am curious as to which parts of jQuery will work.
(is it possible to use the web server launched by 'cfx docs'? i'm not
sure where it's setting up the webserver filesystem)

mark

unread,
Oct 27, 2010, 3:22:13 AM10/27/10
to mozilla-labs-jetpack
Posted too soon, I figured it out.
- run 'cfx docs' to luanch the webserver
- copy zip file contents to jetpack-sdk-0.9/static-files/
- 'cfx run' in the jetpack-sdk-0.9/static-files/ folder
- in the browser, type address http://127.0.0.1:8888/test_in_pagemod.html

Hmm... the results are rather disappointing. I was trying to port over
a google chrome extension to firefox, but most of the jQuery appears
to not work.

I agree, jetpack is a great project and it's making ff extension
development a lot easier. I hope to see more of jQuery supported soon!

Nabor

unread,
Oct 27, 2010, 8:33:41 AM10/27/10
to mozilla-labs-jetpack
Hi, I changed the main.js a bit and now an external server is not
needed anymore.

pageMod.add(new pageMod.PageMod({
include: ["file:///*"],
contentScriptWhen: 'ready',
contentScriptURL: [
packaging.getURLForData("testloaded.js"),
packaging.getURLForData("data/testinit.js"),
packaging.getURLForData("src/core.js"),
packaging.getURLForData("src/support.js"),
packaging.getURLForData("src/data.js"),
packaging.getURLForData("src/queue.js"),
packaging.getURLForData("src/attributes.js"),
packaging.getURLForData("src/event.js"),
packaging.getURLForData("src/sizzle/sizzle.js"),
packaging.getURLForData("src/sizzle-jquery.js"),
packaging.getURLForData("src/traversing.js"),
packaging.getURLForData("src/manipulation.js"),
packaging.getURLForData("src/ajax.js"),
packaging.getURLForData("src/effects.js"),
packaging.getURLForData("src/offset.js"),
packaging.getURLForData("src/dimensions.js"),
packaging.getURLForData("qunit/qunit/qunit.js"),
packaging.getURLForData("data/testrunner.js"),
packaging.getURLForData("unit/core.js"),
packaging.getURLForData("unit/data.js"),
packaging.getURLForData("unit/attributes.js"),
packaging.getURLForData("unit/event.js"),
packaging.getURLForData("unit/selector.js"),
packaging.getURLForData("unit/traversing.js"),
packaging.getURLForData("unit/manipulation.js"),
packaging.getURLForData("unit/css.js"),
packaging.getURLForData("unit/ajax.js"),
packaging.getURLForData("unit/effects.js"),
packaging.getURLForData("unit/offset.js"),
packaging.getURLForData("unit/dimensions.js")
]
})
);

I also looked at some of the tests and don't think, that Jetpack
should be blamed for the jQuery implementation.
There is for example a test, that checks the following...

same( jQuery.parseJSON("{}"), {}, "Plain object parsing." );

but two Objects are never the same...

{} is not equal to {}

Try that simple thing in a browser without using Jetpack and jQuery.

alert({} === {});

I'm not sure about all the other problems with jQuery but it may be
that this problems are made by jQuery and not by the JavaScript
implementation of Jetpack.
>  firefox_jquery_test.zip
> 1701KAnzeigenHerunterladen
>
>
>
> Thanks
> Cid Dennis

Cid Dennis

unread,
Oct 27, 2010, 10:21:03 AM10/27/10
to mozilla-la...@googlegroups.com
I guess what I was getting at is why would most of the test pass when not in a jetpack and it not even complete when in a jet pack. I would expect the same number of test to pass and fail either way.

> --
> You received this message because you are subscribed to the Google Groups "mozilla-labs-jetpack" group.
> To post to this group, send email to mozilla-la...@googlegroups.com.
> To unsubscribe from this group, send email to mozilla-labs-jet...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/mozilla-labs-jetpack?hl=en.
>

Nabor

unread,
Oct 27, 2010, 10:31:49 AM10/27/10
to mozilla-labs-jetpack
I would not expect that, because you have additional functionality.
The postMessage for example.

Besides the script get inserted by Jetpack... what does this mean? It
works different then just having <script src...>
Jetpacks takes care, that your script can't be accessed by the page...

All this point's tell me that you may expect problems, when working
with frameworks like jQuery or Dojo.
These frameworks do a lot for you, that is true, but some times they
do it in a very strange way... I only say XHR implementation of both
and loading for resources using this XHR...

Cid Dennis

unread,
Oct 27, 2010, 10:45:42 AM10/27/10
to mozilla-la...@googlegroups.com
The main problem I am having is that I have developed two other add-ons for Chrome and Safari and they work with what they call their isolated world with out any issue. I get the same "sandbox" features which a page can not see my scripts code and in fact I can not see theres. So there are no chances of collations in namespace.

However when trying to port the same functionality over to jetpack it does not work. This is caused by the firefox sandbox not implementing all the methods and features that are available in the normal page. What I think would be really great is if the jetpack and firefox code worked more like chromes isolated worlds so that any javascript can be written against the page but only have access to the DOM. This would allow any currently usable javascript framework to work just as it does in a page now but instead be used in a jetpack.

My main reason for using already existing frameworks like Jquery and its plugins is they isolate me from writing browser specific code for my main functionality which saves me a considerable amount of time.

Reply all
Reply to author
Forward
0 new messages