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