/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ const Cu = Components.utils; const { require } = Cu.import("resource://gre/modules/devtools/Loader.jsm", {}).devtools; const { GetDevices, GetDeviceString } = require("devtools/shared/devices"); const { Services } = Cu.import("resource://gre/modules/Services.jsm"); const { Simulators, Simulator } = require("devtools/webide/simulators"); const EventEmitter = require('devtools/toolkit/event-emitter'); const promise = require("promise"); const utils = require("devtools/webide/utils"); const Strings = Services.strings.createBundle("chrome://browser/locale/devtools/webide.properties"); let SimulatorEditor = { // Available Firefox OS Simulator addons (key: `addon.id`). _addons: {}, // Available device simulation profiles (key: `device.name`). _devices: {}, // The names of supported simulation options. _deviceOptions: [], // The
element used to edit Simulator options. _form: null, // The Simulator object being edited. _simulator: null, // Generate the dynamic form elements. init() { let promises = []; // Grab the element. let form = this._form; if (!form) { // This is the first time we run `init()`, bootstrap some things. form = this._form = document.querySelector("#simulator-editor"); form.addEventListener("change", this.update.bind(this)); Simulators.on("configure", (e, simulator) => { this.edit(simulator) }); // Extract the list of device simulation options we'll support. let deviceFields = form.querySelectorAll("*[data-device]"); this._deviceOptions = [].map.call(deviceFields, field => field.name); } // Append a new