browser/devtools/webaudioeditor/panel.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /* -*- Mode: javascript; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 2 /* vim: set ft=javascript ts=2 et sw=2 tw=80: */
michael@0 3 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 4 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 6 "use strict";
michael@0 7
michael@0 8 const { Cc, Ci, Cu, Cr } = require("chrome");
michael@0 9 const EventEmitter = require("devtools/toolkit/event-emitter");
michael@0 10 const { WebAudioFront } = require("devtools/server/actors/webaudio");
michael@0 11 let Promise = Cu.import("resource://gre/modules/Promise.jsm", {}).Promise;
michael@0 12
michael@0 13 function WebAudioEditorPanel (iframeWindow, toolbox) {
michael@0 14 this.panelWin = iframeWindow;
michael@0 15 this._toolbox = toolbox;
michael@0 16 this._destroyer = null;
michael@0 17
michael@0 18 EventEmitter.decorate(this);
michael@0 19 }
michael@0 20
michael@0 21 exports.WebAudioEditorPanel = WebAudioEditorPanel;
michael@0 22
michael@0 23 WebAudioEditorPanel.prototype = {
michael@0 24 open: function() {
michael@0 25 let targetPromise;
michael@0 26
michael@0 27 // Local debugging needs to make the target remote.
michael@0 28 if (!this.target.isRemote) {
michael@0 29 targetPromise = this.target.makeRemote();
michael@0 30 } else {
michael@0 31 targetPromise = Promise.resolve(this.target);
michael@0 32 }
michael@0 33
michael@0 34 return targetPromise
michael@0 35 .then(() => {
michael@0 36 this.panelWin.gToolbox = this._toolbox;
michael@0 37 this.panelWin.gTarget = this.target;
michael@0 38 this.panelWin.gFront = new WebAudioFront(this.target.client, this.target.form);
michael@0 39 return this.panelWin.startupWebAudioEditor();
michael@0 40 })
michael@0 41 .then(() => {
michael@0 42 this.isReady = true;
michael@0 43 this.emit("ready");
michael@0 44 return this;
michael@0 45 })
michael@0 46 .then(null, function onError(aReason) {
michael@0 47 Cu.reportError("WebAudioEditorPanel open failed. " +
michael@0 48 aReason.error + ": " + aReason.message);
michael@0 49 });
michael@0 50 },
michael@0 51
michael@0 52 // DevToolPanel API
michael@0 53
michael@0 54 get target() this._toolbox.target,
michael@0 55
michael@0 56 destroy: function() {
michael@0 57 // Make sure this panel is not already destroyed.
michael@0 58 if (this._destroyer) {
michael@0 59 return this._destroyer;
michael@0 60 }
michael@0 61
michael@0 62 return this._destroyer = this.panelWin.shutdownWebAudioEditor().then(() => {
michael@0 63 this.emit("destroyed");
michael@0 64 });
michael@0 65 }
michael@0 66 };

mercurial