/* 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/. */ var Cu = Components.utils; var Ci = Components.interfaces; const { require } = Cu.import("resource://devtools/shared/Loader.jsm", {}); const { getDevices, getDeviceString } = require("devtools/client/shared/devices"); const { Simulators, Simulator } = require("devtools/client/webide/modules/simulators"); const Services = require("Services"); const EventEmitter = require("devtools/shared/event-emitter"); const promise = require("promise"); const utils = require("devtools/client/webide/modules/utils"); const Strings = Services.strings.createBundle("chrome://devtools/locale/webide.properties"); var 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 = Array.map(deviceFields, field => field.name); } // Append a new