PhoneGap emulator in JavaScript / PhoneGap for html5 "platform"

161 views
Skip to first unread message

Gavriel Fleischer

unread,
May 8, 2012, 4:43:46 PM5/8/12
to phon...@googlegroups.com
Is there an emulator in javascript? What I want to do is build an app that can also be viewed as a webpage in a mobile browser, and it'll offer you to download the "native" phongap app.
In order not to work twice I hope to find a javascript phonegap "emulator". Or maybe I should call it phonegap for html5 platform (as opposed to android / iOS / ...). As I imagine it it would be a javascript that I include (just like I include phonegap.js in my index.html in phonegap environment) but instead of calling the native android/iOS functions it would call javascript functions. So for example FileTransfer would work with AJAX, etc

jxp

unread,
May 9, 2012, 7:59:13 AM5/9/12
to phon...@googlegroups.com
I have written a javascript simulator library. You can get the source from GitHub https://github.com/jxp/phonegap-desktop

 

It is intended for debugging/development so I'm not sure it will do what you need but it might be a place to start.
 
You can specify your own test data in a json file and the simulator will return whatever data you want. 

Diego La Monica

unread,
May 9, 2012, 10:20:57 AM5/9/12
to phon...@googlegroups.com
Really interesting,
  i've forked you and pulled a little bugfix.

However great work. ;-)

2012/5/9 jxp <prince...@hotmail.co.uk>
I have written a javascript simulator library. You can get the source from GitHub https://github.com/jxp/phonegap-desktop

 

It is intended for debugging/development so I'm not sure it will do what you need but it might be a place to start.
 
You can specify your own test data in a json file and the simulator will return whatever data you want. 

--
You received this message because you are subscribed to the Google
Groups "phonegap" group.
To post to this group, send email to phon...@googlegroups.com
To unsubscribe from this group, send email to
phonegap+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/phonegap?hl=en?hl=en
 
For more info on PhoneGap or to download the code go to www.phonegap.com

Gavriel Fleischer

unread,
May 9, 2012, 1:37:56 PM5/9/12
to phon...@googlegroups.com
Nice,

I've started to make something, but with a littlebit different goal. If I understand your project is more like a unittest tool with a bit of randomness. Kind of like the android monkey tool.

However I need only Media, File modules, and you don't have the File module yet. What I made for these is a bit like a mockup, but my functions try to act as the real ones, not with debug data, but for example when I call FileTransfer.download() it downloads the requested URL via ajax. When I click on a button that has Media.play in it's onclick, it calls my Media mockup, and it plays the mp3 file, so you can hear it in the browser.

Anyway I saw some nice ideas in your project as well, and I might also use it for testing later.

Thanks!

jxp

unread,
May 9, 2012, 3:54:09 PM5/9/12
to phon...@googlegroups.com

My library should support audio playback (depending on browser support). Please let me know if there is something that doesn't seem to work (e.g. file format and browser version) I hadn't done anything with the file API as I thought it was all based on the HTML5 FileAPI (which is implemented in Chrome). However it looks like some parts are additional.
I would like to improve my library with some of your code if you don't mind. Please let me know if there is anything you want to share.

The randomness is optional, you can have each PhoneGap API call return a single value, a sequence of values or a random value from the sequence.

The idea of my library is that it allows you to check and debug your PhoneGap app on a desktop PC. This allows much quicker development time as you don't need to deploy to an emulator or device each time you make a small change. It is also much easier to debug in the browser than remotely.

Julien Bouquillon

unread,
May 9, 2012, 8:50:53 PM5/9/12
to phonegap
Hi guys, Inspired from jxp awesome work, i took another direction.

All calls to cordova API from the desktop webapp are relayed to the
device so you can test your phonegap app from chrome but with real
data form a device.

This is still a POC but works for most of the API.

Before going further id like to have your thoughts on this solution

https://github.com/revolunet/remote-cordova


Julien

Gavriel Fleischer

unread,
May 10, 2012, 3:54:13 AM5/10/12
to phon...@googlegroups.com
Sure, I'll make my tiny code available within a few days. I'm not that well organized yet, since I just made it overnight for my needs.

Gavriel Fleischer

unread,
May 10, 2012, 3:55:31 AM5/10/12
to phon...@googlegroups.com
What is it different from build.phonegap.com's debug feature (besides that one doesn't have to commit his top-secret code :)

Gavriel Fleischer

unread,
May 17, 2012, 11:39:42 AM5/17/12
to phon...@googlegroups.com
jxp, I sent you a pull request with 3 changes:

1. fixes Media.play
2. fixes emulated touch actions
3. adds the basic functionality for FileTransfer.download()



On Wednesday, May 9, 2012 10:54:09 PM UTC+3, jxp wrote:

jxp

unread,
May 17, 2012, 5:07:28 PM5/17/12
to phon...@googlegroups.com
Thanks for the updates Gavriel. I have merged these in.

I have started looking at the File API and there is quite a bit more work needed there.
I am planning to start on this next (time permitting).

I had thought it was more widely supported by desktop browsers but it seems to be Chrome only.
I would like to offer simulation of File API calls for other browsers. I'm not sure how many that may be possible for!

Gavriel Fleischer

unread,
May 18, 2012, 6:05:52 AM5/18/12
to phon...@googlegroups.com

I've already started working on that. I am still thinking what would be the best way to do it.

In Firefox I plan to emulate FS with local storage.

However for older browsers even local storage won't work.

Another idea for certain cases, where you only download a file to cache it locally is to emulate it by saving the original URL in the FileEntry that FileTransfer.download returns, and use it via Ajax every time you need it. What's funny that in my case I would only use most files with File.toURL() anyway, so tha's a good solution for some files. Of course it won't work when someone creates a local file and wants to save something in it.

Reply all
Reply to author
Forward
0 new messages