Die WebIDE ist verfügbar in Firexfox 34 und neuer
Du kannst sie aber auch schon in Firefox 33 aktivieren in dem du die Einstellungen veränderst: Besuche about:config, finde die Einstellung
devtools.webide.enabled und stelle sie auf
Die WebIDE ist der Ersatz des App Managers. Genauso wie der App Manager, kannst du mit der WebIDE Firefox OS Apps ausführen und debuggen mit dem Firefox OS Simulator oder einem richtigen Firefox OS Gerät
Darüber hinaus ist sie dir eine vollwertige Entwicklungsumgebung zur Erstellung und Bearbeitung deiner Firefox OS Apps. WebIDE bietet eine Baumansicht zur strukturierten Anzeige, Bearbeitung und Sichern aller Dateien deiner App. Für den leichten Einstieg helfen dir zwei App Templates.
Mit der WebIDE, musst du zuerst eine oder mehr Laufzeiten erstellen. Eine Laufzeit ist eine Umgebung, in der du deine App ausführst und debuggst. Eine Laufzeit kann ein Gerät mit Firefox OS sein, welches per USB verbunden ist oder auch der Firefox OS Simulator.
Als Nächstes öffnest oder erstellst du eine App. Falls du eine neue App erstellst, beginnst du mit einer Vorlage, die die Verzeichnisstruktur und die minimalen Textbausteine enthält, die du zu Anfang benötigst. Du kannst auch mit einer umfangreicheren Vorlage anfangen, die zeigt, wie du eine privilegierte API benutzt. Die WebIDE zeigt deine App-Dateien in einer Baumansicht und du kannst sie mit dem eingebauten Quelleditor bearbeiten und speichern. Natürlich kannst du deine Apps auch mit deinen bevorzugten Werkzeugen entwickeln und die WebIDE nur zur Fehlersuche benutzen.
To develop and debug apps using the WebIDE, all you need is Firefox version 33 or later. To test on a real Firefox OS device, you need a device running Firefox OS 1.2 or later, and a USB cable.
You can only use the WebIDE if you're targeting Firefox OS 1.2 or later.
In the Web Developer menu, click on the WebIDE entry and the WebIDE opens. You can also use the keybinding Shift-F8:The dropdown on the left labeled "Open App" lets you open existing apps or create new ones. The dropdown on the right labeled "Select Runtime" lets you select a runtime or set up a new runtime.
The buttons in the middle run, stop, and debug the app: they are only enabled when you have opened an app and selected a runtime.
Under the "Select Runtime" dropdown, runtimes are grouped into three types:
- USB devices: Firefox OS devices connected over USB
- Simulators: instances of the Firefox OS Simulator that you've installed
- Custom: use this to connect to the WebIDE using an arbitrary name and port.
The first time you click the dropdown, you might not see any runtimes here:
The rest of this section describes how you can add some runtimes.
Before you can connect a Firefox OS device, there's some setup you have to go through:
- check your Firefox OS version: make sure your device is running Firefox OS 1.2/Boot2Gecko 1.2 or higher. To check the version, go to the Settings app on the device, then
Device Information > Software. If you don't have a high enough version, find your device in the developer phone guide and follow the instructions for upgrading.
- enable remote debugging: in the Settings app on the device, go to
Device information > More information > Developer.
- Firefox OS 1.3 and earlier: "Remote Debugging" is just a simple checkbox. Check it.
- Firefox OS 1.4 and later: "Remote Debugging" asks you to enable for just ADB, or for ADB and DevTools. Select "ADB and DevTools".
- disable Screen lock on your device: in the Settings app on the device, go to
Screen Lockand unchecking the
Lock Screencheckbox. This is a good idea because when the screen gets locked, the phone connection gets lost, meaning it is no longer available for debugging.
- if you want to debug certified apps, including built-in apps: see the section on debugging certified apps.
- you need to install drivers, as documented in step 3 of this guide to setting up an Android device. You can find drivers for Geeksphone devices on the Geeksphone web site. Windows 8 by default will not let you install unsigned drivers. See this tutorial on "How to install an unsigned driver on Windows 8".
- if the WebIDE can't see your device after following all the steps, you may have to edit adb_usb.ini.
If there are any other Android devices connected to your computer, disconnect them. Now connect the device to the computer using USB. You should see the device appear under "USB DEVICES":
If you don't see your device, see the Troubleshooting page.
The Firefox OS Simulator is a version of the higher layers of Firefox OS that simulates a Firefox OS device, but runs on the desktop. It runs in a window the same size as a Firefox OS device, includes the Firefox OS user interface and built-in apps, and simulates many of the Firefox OS device APIs.
This means that in many cases, you don't need a real device to test and debug your app.
The Simulator is big, so it doesn't ship inside Firefox but as a Firefox add-on. If you click "Install Simulator" in the Runtimes dropdown menu, you will go to a page from which you can install Simulators for various versions of Firefox OS.
You can install as many as you like. Be patient, though: the Simulator is large and may take a few minutes to download. Once you've installed some Simulators you can close this "Extra Components" window, and the Simulators you've installed appear as options in the Runtimes dropdown menu:
To learn more about the Simulator, see its documentation page.
With a custom runtime you can use an arbitrary hostname and port to connect to the remote device.
Under the hood, Firefox OS devices and Android devices connect to the desktop using a program called the Android Debug Bridge, or ADB. By default, the WebIDE uses an add-on called the ADB Helper: this simplifies the process for you by installing ADB and setting up port forwarding so the Firefox desktop tools can exchange messages with the device.
This is convenient in most cases, but sometimes you might want to use ADB outside of the WebIDE: for example, you might be running ADB directly from the command line. In that case you'll connect to the device by specifying a host and port using the
adb forward command.
If you then want to use WebIDE to connect as well, you should disable the ADB Helper add-on and connect WebIDE using the Custom runtime option, entering the host and port that you passed to
Also, the ADB Helper does not yet support connecting to Firefox for Android, so if you want to connect WebIDE to Firefox for Android, you'll need to set up your own port forwarding and use a custom runtime. See more about connecting to Firefox for Android using ADB.
Once you've set up a runtime you can select it using the "Select Runtime" menu.
- If you select a Simulator, the WebIDE launches the Simulator.
- If you select a Firefox OS device the WebIDE connects to the device. On the device a dialog will ask you to confirm that you wish to connect: press "OK".
Now the "play" button in the center of the WebIDE toolbar is enabled: click it to install and run the app in the selected runtime.
When a runtime is selected, the Runtimes dropdown menu has three extra items:
- Runtime Info: information on the current runtime
- Permissions Table: a table summarising app permissions for the current runtime, indicating, for each API and each app type, whether access is allowed (✓), denied (✗), or whether the user is prompted (!)
- Screenshot: a command to take a screenshot from the runtime
Under the "Open App" menu you get three options: create a new app, open a packaged app, and open a hosted app:
Select "New App..." to create a new app. You'll see a dialog offering you a choice between two templates, "Privileged Empty App" and "Privileged App".
Both templates are from Mozilla's app template collection, and provide you with the basic structure you need to get started. The "Privileged App" shows how an app can use permissions to load cross-origin content.
Once you've selected a template you'll be asked to name the app and select a directory to store the files, and then the new app is opened in the project editor.
The project editor provides an environment for editing apps. There's a tree view on the left of all the files in the app: you can add and delete files here using a context menu. There's an editor pane on the right.
When you first open or create an app, the editor pane is occupied by the app summary page, which is shown below:
You can always get back to the app summary page by clicking on the root of the tree on the left.
The WebIDE automatically checks the manifest for certain common problems. If it finds a problem it indicates that the app is invalid and describes the problem in the app's summary:
Of course, you can edit the manifest.webapp file right in the project editor as well.
The WebIDE uses the CodeMirror source editor.
Source editor shortcuts
This table lists the default shortcuts for the source editor.
In the Editor Preferences section of the developer tools settings, you can choose to use Vim, Emacs, or Sublime Text key bindings instead.
To select these, visit
about:config, select the setting
devtools.editor.keymap, and assign "vim" or "emacs", or "sublime" to that setting. If you do this, the selected bindings will be used for all the developer tools that use the source editor. You need to reopen the editor for the change to take effect.
From Firefox 33 onwards, the key binding preference is exposed in the Editor Preferences section of the developer tools settings, and you can set it there instead of
|Go to line||Ctrl + J||Cmd + J||Ctrl + J|
|Find in file||Ctrl + F||Cmd + F||Ctrl + F|
|Find again||Ctrl + G||Cmd + G||Ctrl + G|
|Select all||Ctrl + A||Cmd + A||Ctrl + A|
|Cut||Ctrl + X||Cmd + X||Ctrl + X|
|Copy||Ctrl + C||Cmd + C||Ctrl + C|
|Paste||Ctrl + V||Cmd + V||Ctrl + V|
|Undo||Ctrl + Z||Cmd + Z||Ctrl + Z|
|Redo||Ctrl + Shift + Z / Ctrl + Y||Cmd + Shift + Z / Cmd + Y||Ctrl + Shift + Z / Ctrl + Y|
|Unindent||Shift + Tab||Shift + Tab||Shift + Tab|
|Move line(s) up||Alt + Up||Alt + Up||Alt + Up|
|Move line(s) down||Alt + Down||Alt + Down||Alt + Down|
|Comment/uncomment line(s)||Ctrl + /||Cmd + /||Ctrl + /|
[docs] link in the popup will take you to the MDN page for the symbol.
For changes to your files to take effect you need to save them. Files with unsaved changes get an asterisk next to their name in the tree view, and you can save files using the menu or Control+S (Command+S on Mac OS X).
To remove an app from the WebIDE, go to the app summary page and click "Remove Project".
When you're ready to run the app, you need to select a runtime from the "Select Runtime" dropdown menu. If you don't have any available runtimes here, find out how to add some in Setting up runtimes.
The "play" button in the center of the WebIDE toolbar is now enabled: click it to install and run the app in the selected runtime:
To debug the app, click the "Pause" button and the Developer Tools Toolbox appears, connected to your app:
With the Simulator, if you click on the app dropdown menu while the runtime is selected, you can see and debug not only your app but all apps running in that runtime, including certified apps:
However, to debug certified apps on a real device:
- the device must be running a development build of Firefox OS 1.2+
- you must enable certified app debugging
To enable certified app debugging, connect to the runtime, and then, in the menu, go to
Runtime > Runtime Info. From here, if you see
"DevTools restricted privileges: yes", that means certified apps can't be debugged. The path then differs depending on what you are debugging against:
- Real device
- If it can be rooted, clicking
"request higher privileges"will enable certified apps debugging (Firefox OS will restart).
- If it can be rooted, clicking
- The simulators come with certified debugging enabled by default.
- B2G desktop
- Manually edit the B2G desktop client preferences before connecting to enable certified app debugging.
Now (or after a restart of the B2G desktop client) in the WebIDE you should see all the certified apps on the device.
If you're interested in the performance of your apps, there are a few ways to measure their impact on the runtime in WebIDE:
- The Monitor panel offers a good overview of a device's performance. This can help you detect problems, e.g. a sudden, excessive increase in an app's memory usage (leak).
- The Profiler tool gives you a way to analyze a single app's footprint in great detail. This is especially useful when investigating a known performance problem.
If you have any problems working with the WebIDE, see the Troubleshooting page.