Playing with inserting JS into apps

Thanks to one of our contributors ( Jamie_ ), I learned that we can insert some JS code into the simulator to have it trigger certain things.

Here are the steps to get to the scratch pad in WebIDE:

1. launch browser

2. go to Tools -> Web Developer -> WebIDE

3. select Runtime and select a simulator ( if you don’t have a simulator installed you will want to install one first ).  For this example, we’ll use 2.2

4. on the left side, select the app you want to use JS to trigger an event.  For this example, we’ll use the main process.

5. select the wrench icon and select Scratchpad

6. you should then be able to place in your js script : For this example, we’ll use some code snippet from :

function popup(title, text) {
  try {
              .showAlertNotification(null, title, text, false, '', null);
  } catch(e) {
    // prevents runtime error on platforms that don't implement nsIAlertsService

popup('Test', 'This is a test; So exciting!')

Screen Shot 2015-04-01 at 10.56.10 AM

7.  Click on Run.

You should get an output like this :

Screen Shot 2015-04-01 at 10.55.22 AM


About shizen008

Breaking things and getting in trouble for it since '74. Disclaimer: I am not responsible if I make your head explode reading this blog! The writings here are my own expression and not of any companies. I currently work on being a QA for B2G aka Firefox OS
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s