forked from jsantell/firefox-patches
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path1026766-media-nodes-wae.patch
239 lines (223 loc) · 8.34 KB
/
1026766-media-nodes-wae.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
From fe7f1f72bdb00e0ad2d687d40548138de506a4d6 Mon Sep 17 00:00:00 2001
From: Jordan Santell <[email protected]>
Date: Tue, 17 Jun 2014 15:54:53 -0700
Subject: Bug 1026766 - Support Media AudioNodes in the web audio editor. r=vp
---
browser/devtools/webaudioeditor/test/browser.ini | 2 +
.../test/browser_wa_properties-view-media-nodes.js | 45 ++++++++++++++++++++++
.../test/doc_media-node-creation.html | 29 ++++++++++++++
browser/devtools/webaudioeditor/test/head.js | 16 ++++++++
toolkit/devtools/server/actors/webaudio.js | 7 +++-
5 files changed, 98 insertions(+), 1 deletion(-)
create mode 100644 browser/devtools/webaudioeditor/test/browser_wa_properties-view-media-nodes.js
create mode 100644 browser/devtools/webaudioeditor/test/doc_media-node-creation.html
diff --git a/browser/devtools/webaudioeditor/test/browser.ini b/browser/devtools/webaudioeditor/test/browser.ini
index 3616124..9b5f814 100644
--- a/browser/devtools/webaudioeditor/test/browser.ini
+++ b/browser/devtools/webaudioeditor/test/browser.ini
@@ -1,16 +1,17 @@
[DEFAULT]
skip-if = e10s # Bug ?????? - devtools tests disabled with e10s
subsuite = devtools
support-files =
doc_simple-context.html
doc_complex-context.html
doc_simple-node-creation.html
doc_buffer-and-array.html
+ doc_media-node-creation.html
440hz_sine.ogg
head.js
[browser_audionode-actor-get-set-param.js]
[browser_audionode-actor-get-type.js]
[browser_audionode-actor-get-params-01.js]
[browser_audionode-actor-get-params-02.js]
[browser_audionode-actor-get-param-flags.js]
@@ -27,12 +28,13 @@ support-files =
[browser_wa_graph-render-02.js]
[browser_wa_graph-markers.js]
[browser_wa_graph-selected.js]
[browser_wa_inspector.js]
[browser_wa_inspector-toggle.js]
[browser_wa_properties-view.js]
+[browser_wa_properties-view-media-nodes.js]
# [browser_wa_properties-view-edit.js]
# Disabled for too many intermittents bug 1010423
[browser_wa_properties-view-params.js]
[browser_wa_properties-view-params-objects.js]
diff --git a/browser/devtools/webaudioeditor/test/browser_wa_properties-view-media-nodes.js b/browser/devtools/webaudioeditor/test/browser_wa_properties-view-media-nodes.js
new file mode 100644
index 0000000..a0ee37f
--- /dev/null
+++ b/browser/devtools/webaudioeditor/test/browser_wa_properties-view-media-nodes.js
@@ -0,0 +1,45 @@
+/* Any copyright is dedicated to the Public Domain.
+ http://creativecommons.org/publicdomain/zero/1.0/ */
+
+/**
+ * Tests that params view correctly displays all properties for nodes
+ * correctly, with default values and correct types.
+ */
+
+let MEDIA_PERMISSION = "media.navigator.permission.disabled";
+
+function spawnTest() {
+ let [target, debuggee, panel] = yield initWebAudioEditor(MEDIA_NODES_URL);
+ let { panelWin } = panel;
+ let { gFront, $, $$, EVENTS, WebAudioInspectorView } = panelWin;
+ let gVars = WebAudioInspectorView._propsView;
+
+ // Auto enable getUserMedia
+ let mediaPermissionPref = Services.prefs.getBoolPref(MEDIA_PERMISSION);
+ Services.prefs.setBoolPref(MEDIA_PERMISSION, true);
+
+ reload(target);
+
+ let [actors] = yield Promise.all([
+ getN(gFront, "create-node", 4),
+ waitForGraphRendered(panelWin, 4, 0)
+ ]);
+
+ let nodeIds = actors.map(actor => actor.actorID);
+ let types = [
+ "AudioDestinationNode", "MediaElementAudioSourceNode",
+ "MediaStreamAudioSourceNode", "MediaStreamAudioDestinationNode"
+ ];
+
+ for (let i = 0; i < types.length; i++) {
+ click(panelWin, findGraphNode(panelWin, nodeIds[i]));
+ yield once(panelWin, EVENTS.UI_INSPECTOR_NODE_SET);
+ checkVariableView(gVars, 0, NODE_DEFAULT_VALUES[types[i]], types[i]);
+ }
+
+ // Reset permissions on getUserMedia
+ Services.prefs.setBoolPref(MEDIA_PERMISSION, mediaPermissionPref);
+
+ yield teardown(panel);
+ finish();
+}
diff --git a/browser/devtools/webaudioeditor/test/doc_media-node-creation.html b/browser/devtools/webaudioeditor/test/doc_media-node-creation.html
new file mode 100644
index 0000000..685062e
--- /dev/null
+++ b/browser/devtools/webaudioeditor/test/doc_media-node-creation.html
@@ -0,0 +1,29 @@
+<!-- Any copyright is dedicated to the Public Domain.
+ http://creativecommons.org/publicdomain/zero/1.0/ -->
+<!doctype html>
+
+<html>
+ <head>
+ <meta charset="utf-8"/>
+ <title>Web Audio Editor test page</title>
+ </head>
+
+ <body>
+
+ <script type="text/javascript;version=1.8">
+ "use strict";
+
+ let ctx = new AudioContext();
+ let audio = new Audio();
+ let meNode, msNode, mdNode;
+ navigator.getUserMedia = navigator.getUserMedia || navigator.mozGetUserMedia;
+
+ navigator.getUserMedia({ audio: true }, stream => {
+ meNode = ctx.createMediaElementSource(audio);
+ msNode = ctx.createMediaStreamSource(stream);
+ mdNode = ctx.createMediaStreamDestination();
+ }, () => {});
+ </script>
+ </body>
+
+</html>
diff --git a/browser/devtools/webaudioeditor/test/head.js b/browser/devtools/webaudioeditor/test/head.js
index 386ab2b..0dbd8b0 100644
--- a/browser/devtools/webaudioeditor/test/head.js
+++ b/browser/devtools/webaudioeditor/test/head.js
@@ -19,16 +19,17 @@ let { DebuggerServer } = Cu.import("resource://gre/modules/devtools/dbg-server.j
let { WebAudioFront } = devtools.require("devtools/server/actors/webaudio");
let TargetFactory = devtools.TargetFactory;
const EXAMPLE_URL = "http://example.com/browser/browser/devtools/webaudioeditor/test/";
const SIMPLE_CONTEXT_URL = EXAMPLE_URL + "doc_simple-context.html";
const COMPLEX_CONTEXT_URL = EXAMPLE_URL + "doc_complex-context.html";
const SIMPLE_NODES_URL = EXAMPLE_URL + "doc_simple-node-creation.html";
+const MEDIA_NODES_URL = EXAMPLE_URL + "doc_media-node-creation.html";
const BUFFER_AND_ARRAY_URL = EXAMPLE_URL + "doc_buffer-and-array.html";
// All tests are asynchronous.
waitForExplicitFinish();
let gToolEnabled = Services.prefs.getBoolPref("devtools.webaudioeditor.enabled");
registerCleanupFunction(() => {
@@ -211,16 +212,26 @@ function waitForGraphRendered (front, nodeCount, edgeCount) {
});
return deferred.promise;
}
function checkVariableView (view, index, hash, description = "") {
info("Checking Variable View");
let scope = view.getScopeAtIndex(index);
let variables = Object.keys(hash);
+
+ // If node shouldn't display any properties, ensure that the 'empty' message is
+ // visible
+ if (!variables.length) {
+ ok(isVisible(scope.window.$("#properties-tabpanel-content-empty")),
+ description + " should show the empty properties tab.");
+ return;
+ }
+
+ // Otherwise, iterate over expected properties
variables.forEach(variable => {
let aVar = scope.get(variable);
is(aVar.target.querySelector(".name").getAttribute("value"), variable,
"Correct property name for " + variable);
let value = aVar.target.querySelector(".value").getAttribute("value");
// Cast value with JSON.parse if possible;
// will fail when displaying Object types like "ArrayBuffer"
@@ -362,16 +373,21 @@ function countGraphObjects (win) {
}
/**
* List of audio node properties to test against expectations of the AudioNode actor
*/
const NODE_DEFAULT_VALUES = {
"AudioDestinationNode": {},
+ "MediaElementAudioSourceNode": {},
+ "MediaStreamAudioSourceNode": {},
+ "MediaStreamAudioDestinationNode": {
+ "stream": "MediaStream"
+ },
"AudioBufferSourceNode": {
"playbackRate": 1,
"loop": false,
"loopStart": 0,
"loopEnd": 0,
"buffer": null
},
"ScriptProcessorNode": {
diff --git a/toolkit/devtools/server/actors/webaudio.js b/toolkit/devtools/server/actors/webaudio.js
index b3fc7e5..6e3e9cf 100644
--- a/toolkit/devtools/server/actors/webaudio.js
+++ b/toolkit/devtools/server/actors/webaudio.js
@@ -99,17 +99,22 @@ const NODE_PROPERTIES = {
"fftSize": {},
"minDecibels": {},
"maxDecibels": {},
"smoothingTimeConstant": {},
"frequencyBinCount": { "readonly": true },
},
"AudioDestinationNode": {},
"ChannelSplitterNode": {},
- "ChannelMergerNode": {}
+ "ChannelMergerNode": {},
+ "MediaElementAudioSourceNode": {},
+ "MediaStreamAudioSourceNode": {},
+ "MediaStreamAudioDestinationNode": {
+ "stream": { "MediaStream": true }
+ }
};
/**
* An Audio Node actor allowing communication to a specific audio node in the
* Audio Context graph.
*/
let AudioNodeActor = exports.AudioNodeActor = protocol.ActorClass({
typeName: "audionode",
--
1.8.4.2