forked from jsantell/firefox-patches
-
Notifications
You must be signed in to change notification settings - Fork 0
/
1108928-ui-automation.patch
1848 lines (1710 loc) · 65.7 KB
/
1108928-ui-automation.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
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
From 199d6aa72d9a17933732ee4e00c3b7410625a614 Mon Sep 17 00:00:00 2001
From: Jordan Santell <[email protected]>
Date: Fri, 2 Jan 2015 15:52:33 -0800
Subject: Bug 1108928 - UI for rendering automation data for web audio
editor. r=vp
diff --git a/browser/devtools/jar.mn b/browser/devtools/jar.mn
index 43f64f8..7076238 100644
--- a/browser/devtools/jar.mn
+++ b/browser/devtools/jar.mn
@@ -80,16 +80,18 @@ browser.jar:
content/browser/devtools/webaudioeditor.xul (webaudioeditor/webaudioeditor.xul)
content/browser/devtools/dagre-d3.js (webaudioeditor/lib/dagre-d3.js)
content/browser/devtools/webaudioeditor/includes.js (webaudioeditor/includes.js)
content/browser/devtools/webaudioeditor/models.js (webaudioeditor/models.js)
content/browser/devtools/webaudioeditor/controller.js (webaudioeditor/controller.js)
content/browser/devtools/webaudioeditor/views/utils.js (webaudioeditor/views/utils.js)
content/browser/devtools/webaudioeditor/views/context.js (webaudioeditor/views/context.js)
content/browser/devtools/webaudioeditor/views/inspector.js (webaudioeditor/views/inspector.js)
+ content/browser/devtools/webaudioeditor/views/properties.js (webaudioeditor/views/properties.js)
+ content/browser/devtools/webaudioeditor/views/automation.js (webaudioeditor/views/automation.js)
content/browser/devtools/profiler.xul (profiler/profiler.xul)
content/browser/devtools/profiler.js (profiler/profiler.js)
content/browser/devtools/ui-recordings.js (profiler/ui-recordings.js)
content/browser/devtools/ui-profile.js (profiler/ui-profile.js)
#ifdef MOZ_DEVTOOLS_PERFTOOLS
content/browser/devtools/performance.xul (performance/performance.xul)
content/browser/devtools/performance/performance-controller.js (performance/performance-controller.js)
content/browser/devtools/performance/performance-view.js (performance/performance-view.js)
diff --git a/browser/devtools/webaudioeditor/controller.js b/browser/devtools/webaudioeditor/controller.js
index ee8dc45..79d2105 100644
--- a/browser/devtools/webaudioeditor/controller.js
+++ b/browser/devtools/webaudioeditor/controller.js
@@ -10,28 +10,32 @@ let gAudioNodes = new AudioNodesCollection();
/**
* Initializes the web audio editor views
*/
function startupWebAudioEditor() {
return all([
WebAudioEditorController.initialize(),
ContextView.initialize(),
- InspectorView.initialize()
+ InspectorView.initialize(),
+ PropertiesView.initialize(),
+ AutomationView.initialize()
]);
}
/**
* Destroys the web audio editor controller and views.
*/
function shutdownWebAudioEditor() {
return all([
WebAudioEditorController.destroy(),
ContextView.destroy(),
InspectorView.destroy(),
+ PropertiesView.destroy(),
+ AutomationView.destroy()
]);
}
/**
* Functions handling target-related lifetime events.
*/
let WebAudioEditorController = {
/**
@@ -78,16 +82,17 @@ let WebAudioEditorController = {
/**
* Called when page is reloaded to show the reload notice and waiting
* for an audio context notice.
*/
reset: function () {
$("#content").hidden = true;
ContextView.resetUI();
InspectorView.resetUI();
+ PropertiesView.resetUI();
},
// Since node create and connect are probably executed back to back,
// and the controller's `_onCreateNode` needs to look up type,
// the edge creation could be called before the graph node is actually
// created. This way, we can check and listen for the event before
// adding an edge.
_waitForNodeCreation: function (sourceActor, destActor) {
diff --git a/browser/devtools/webaudioeditor/includes.js b/browser/devtools/webaudioeditor/includes.js
index ddac056..db84a68 100644
--- a/browser/devtools/webaudioeditor/includes.js
+++ b/browser/devtools/webaudioeditor/includes.js
@@ -5,27 +5,30 @@
const { classes: Cc, interfaces: Ci, utils: Cu, results: Cr } = Components;
Cu.import("resource://gre/modules/Services.jsm");
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource:///modules/devtools/ViewHelpers.jsm");
Cu.import("resource:///modules/devtools/gDevTools.jsm");
-const require = Cu.import("resource://gre/modules/devtools/Loader.jsm", {}).devtools.require;
+const devtools = Cu.import("resource://gre/modules/devtools/Loader.jsm", {}).devtools;
+const { require } = devtools;
let { console } = Cu.import("resource://gre/modules/devtools/Console.jsm", {});
let { EventTarget } = require("sdk/event/target");
const { Task } = Cu.import("resource://gre/modules/Task.jsm", {});
const { Class } = require("sdk/core/heritage");
const EventEmitter = require("devtools/toolkit/event-emitter");
const STRINGS_URI = "chrome://browser/locale/devtools/webaudioeditor.properties"
const L10N = new ViewHelpers.L10N(STRINGS_URI);
const Telemetry = require("devtools/shared/telemetry");
const telemetry = new Telemetry();
+devtools.lazyImporter(this, "LineGraphWidget",
+ "resource:///modules/devtools/Graphs.jsm");
// Override DOM promises with Promise.jsm helpers
const { defer, all } = Cu.import("resource://gre/modules/Promise.jsm", {}).Promise;
/* Events fired on `window` to indicate state or actions*/
const EVENTS = {
// Fired when the first AudioNode has been created, signifying
// that the AudioContext is being used and should be tracked via the editor.
@@ -48,21 +51,27 @@ const EVENTS = {
UI_INSPECTOR_NODE_SET: "WebAudioEditor:UIInspectorNodeSet",
// When the inspector is finished rendering in or out of view.
UI_INSPECTOR_TOGGLED: "WebAudioEditor:UIInspectorToggled",
// When an audio node is finished loading in the Properties tab.
UI_PROPERTIES_TAB_RENDERED: "WebAudioEditor:UIPropertiesTabRendered",
+ // When an audio node is finished loading in the Automation tab.
+ UI_AUTOMATION_TAB_RENDERED: "WebAudioEditor:UIAutomationTabRendered",
+
// When the Audio Context graph finishes rendering.
// Is called with two arguments, first representing number of nodes
// rendered, second being the number of edge connections rendering (not counting
// param edges), followed by the count of the param edges rendered.
- UI_GRAPH_RENDERED: "WebAudioEditor:UIGraphRendered"
+ UI_GRAPH_RENDERED: "WebAudioEditor:UIGraphRendered",
+
+ // Called when the inspector splitter is moved and resized.
+ UI_INSPECTOR_RESIZE: "WebAudioEditor:UIInspectorResize"
};
/**
* The current target and the Web Audio Editor front, set by this tool's host.
*/
let gToolbox, gTarget, gFront;
/**
diff --git a/browser/devtools/webaudioeditor/models.js b/browser/devtools/webaudioeditor/models.js
index e9ce10c..142a338 100644
--- a/browser/devtools/webaudioeditor/models.js
+++ b/browser/devtools/webaudioeditor/models.js
@@ -81,16 +81,27 @@ const AudioNodeModel = Class({
*
* @return Promise->Object
*/
getParams: function () {
return this.actor.getParams();
},
/**
+ * Returns a promise that resolves to an object containing an
+ * array of event information and an array of automation data.
+ *
+ * @param String paramName
+ * @return Promise->Array
+ */
+ getAutomationData: function (paramName) {
+ return this.actor.getAutomationData(paramName);
+ },
+
+ /**
* Takes a `dagreD3.Digraph` object and adds this node to
* the graph to be rendered.
*
* @param dagreD3.Digraph
*/
addToGraph: function (graph) {
graph.addNode(this.id, {
type: this.type,
diff --git a/browser/devtools/webaudioeditor/test/browser.ini b/browser/devtools/webaudioeditor/test/browser.ini
index 1adf13e..3012b7e 100644
--- a/browser/devtools/webaudioeditor/test/browser.ini
+++ b/browser/devtools/webaudioeditor/test/browser.ini
@@ -56,8 +56,11 @@ support-files =
[browser_wa_properties-view.js]
[browser_wa_properties-view-edit-01.js]
skip-if = true # bug 1010423
[browser_wa_properties-view-edit-02.js]
skip-if = true # bug 1010423
[browser_wa_properties-view-media-nodes.js]
[browser_wa_properties-view-params.js]
[browser_wa_properties-view-params-objects.js]
+
+[browser_wa_automation-view-01.js]
+[browser_wa_automation-view-02.js]
diff --git a/browser/devtools/webaudioeditor/test/browser_audionode-actor-get-param-flags.js b/browser/devtools/webaudioeditor/test/browser_audionode-actor-get-param-flags.js
index d7f77f1..c7ba798 100644
--- a/browser/devtools/webaudioeditor/test/browser_audionode-actor-get-param-flags.js
+++ b/browser/devtools/webaudioeditor/test/browser_audionode-actor-get-param-flags.js
@@ -34,16 +34,14 @@ add_task(function*() {
if (param === "buffer") {
is(flags.Buffer, true, "`buffer` params have Buffer flag");
}
else if (param === "bufferSize" || param === "frequencyBinCount") {
is(flags.readonly, true, param + " is readonly");
}
else if (param === "curve") {
is(flags["Float32Array"], true, "`curve` param has Float32Array flag");
- } else {
- is(Object.keys(flags), 0, type + "-" + param + " has no flags set")
}
}
}
yield removeTab(target.tab);
});
diff --git a/browser/devtools/webaudioeditor/test/browser_audionode-actor-get-params-01.js b/browser/devtools/webaudioeditor/test/browser_audionode-actor-get-params-01.js
index 24e0232..b04ae24 100644
--- a/browser/devtools/webaudioeditor/test/browser_audionode-actor-get-params-01.js
+++ b/browser/devtools/webaudioeditor/test/browser_audionode-actor-get-params-01.js
@@ -31,16 +31,14 @@ add_task(function*() {
if (param === "buffer") {
is(flags.Buffer, true, "`buffer` params have Buffer flag");
}
else if (param === "bufferSize" || param === "frequencyBinCount") {
is(flags.readonly, true, param + " is readonly");
}
else if (param === "curve") {
is(flags["Float32Array"], true, "`curve` param has Float32Array flag");
- } else {
- is(Object.keys(flags), 0, type + "-" + param + " has no flags set")
}
});
});
yield removeTab(target.tab);
});
diff --git a/browser/devtools/webaudioeditor/test/browser_wa_automation-view-01.js b/browser/devtools/webaudioeditor/test/browser_wa_automation-view-01.js
new file mode 100644
index 0000000..d211e1b
--- /dev/null
+++ b/browser/devtools/webaudioeditor/test/browser_wa_automation-view-01.js
@@ -0,0 +1,55 @@
+/* Any copyright is dedicated to the Public Domain.
+ http://creativecommons.org/publicdomain/zero/1.0/ */
+
+/**
+ * Tests that automation view shows the correct view depending on if events
+ * or params exist.
+ */
+
+add_task(function*() {
+ let { target, panel } = yield initWebAudioEditor(AUTOMATION_URL);
+ let { panelWin } = panel;
+ let { gFront, $, $$, EVENTS } = panelWin;
+
+ let started = once(gFront, "start-context");
+
+ reload(target);
+
+ let [actors] = yield Promise.all([
+ get3(gFront, "create-node"),
+ waitForGraphRendered(panelWin, 3, 2)
+ ]);
+ let nodeIds = actors.map(actor => actor.actorID);
+
+ // Oscillator node
+ click(panelWin, findGraphNode(panelWin, nodeIds[1]));
+ yield waitForInspectorRender(panelWin, EVENTS);
+ click(panelWin, $("#automation-tab"));
+
+ ok(isVisible($("#automation-graph-container")), "graph container should be visible");
+ ok(isVisible($("#automation-content")), "automation content should be visible");
+ ok(!isVisible($("#automation-no-events")), "no-events panel should not be visible");
+ ok(!isVisible($("#automation-empty")), "empty panel should not be visible");
+
+ // Gain node
+ click(panelWin, findGraphNode(panelWin, nodeIds[2]));
+ yield waitForInspectorRender(panelWin, EVENTS);
+ click(panelWin, $("#automation-tab"));
+
+ ok(!isVisible($("#automation-graph-container")), "graph container should be visible");
+ ok(isVisible($("#automation-content")), "automation content should not be visible");
+ ok(isVisible($("#automation-no-events")), "no-events panel should be visible");
+ ok(!isVisible($("#automation-empty")), "empty panel should not be visible");
+
+ // destination node
+ click(panelWin, findGraphNode(panelWin, nodeIds[0]));
+ yield waitForInspectorRender(panelWin, EVENTS);
+ click(panelWin, $("#automation-tab"));
+
+ ok(!isVisible($("#automation-graph-container")), "graph container should not be visible");
+ ok(!isVisible($("#automation-content")), "automation content should not be visible");
+ ok(!isVisible($("#automation-no-events")), "no-events panel should not be visible");
+ ok(isVisible($("#automation-empty")), "empty panel should be visible");
+
+ yield teardown(target);
+});
diff --git a/browser/devtools/webaudioeditor/test/browser_wa_automation-view-02.js b/browser/devtools/webaudioeditor/test/browser_wa_automation-view-02.js
new file mode 100644
index 0000000..ecb9957
--- /dev/null
+++ b/browser/devtools/webaudioeditor/test/browser_wa_automation-view-02.js
@@ -0,0 +1,56 @@
+/* Any copyright is dedicated to the Public Domain.
+ http://creativecommons.org/publicdomain/zero/1.0/ */
+
+/**
+ * Tests that automation view selects the first parameter by default and
+ * switching between AudioParam rerenders the graph.
+ */
+
+add_task(function*() {
+ let { target, panel } = yield initWebAudioEditor(AUTOMATION_URL);
+ let { panelWin } = panel;
+ let { gFront, $, $$, EVENTS, AutomationView } = panelWin;
+
+ let started = once(gFront, "start-context");
+
+ reload(target);
+
+ let [actors] = yield Promise.all([
+ get3(gFront, "create-node"),
+ waitForGraphRendered(panelWin, 3, 2)
+ ]);
+ let nodeIds = actors.map(actor => actor.actorID);
+
+
+ // Oscillator node
+ click(panelWin, findGraphNode(panelWin, nodeIds[1]));
+ yield waitForInspectorRender(panelWin, EVENTS);
+ click(panelWin, $("#automation-tab"));
+
+ ok(AutomationView._selectedParamName, "frequency",
+ "AutomatioView is set on 'frequency'");
+ ok($(".automation-param-button[data-param='frequency']").getAttribute("selected"),
+ "frequency param should be selected on load");
+ ok(!$(".automation-param-button[data-param='detune']").getAttribute("selected"),
+ "detune param should not be selected on load");
+ ok(isVisible($("#automation-content")), "automation content should be visible");
+ ok(isVisible($("#automation-graph-container")), "graph container should be visible");
+ ok(!isVisible($("#automation-no-events")), "no-events panel should not be visible");
+
+ click(panelWin, $(".automation-param-button[data-param='detune']"));
+ yield once(panelWin, EVENTS.UI_AUTOMATION_TAB_RENDERED);
+
+ ok(true, "automation tab rerendered");
+
+ ok(AutomationView._selectedParamName, "detune",
+ "AutomatioView is set on 'detune'");
+ ok(!$(".automation-param-button[data-param='frequency']").getAttribute("selected"),
+ "frequency param should not be selected after clicking detune");
+ ok($(".automation-param-button[data-param='detune']").getAttribute("selected"),
+ "detune param should be selected after clicking detune");
+ ok(isVisible($("#automation-content")), "automation content should be visible");
+ ok(!isVisible($("#automation-graph-container")), "graph container should not be visible");
+ ok(isVisible($("#automation-no-events")), "no-events panel should be visible");
+
+ yield teardown(target);
+});
diff --git a/browser/devtools/webaudioeditor/test/browser_wa_inspector-toggle.js b/browser/devtools/webaudioeditor/test/browser_wa_inspector-toggle.js
index 606af9f..917d00f 100644
--- a/browser/devtools/webaudioeditor/test/browser_wa_inspector-toggle.js
+++ b/browser/devtools/webaudioeditor/test/browser_wa_inspector-toggle.js
@@ -46,18 +46,19 @@ add_task(function*() {
// Open again to test node loading while open
$("#inspector-pane-toggle").click();
yield once(panelWin, EVENTS.UI_INSPECTOR_TOGGLED);
ok(InspectorView.isVisible(), "InspectorView being shown.");
ok(!isVisible($("#web-audio-editor-tabs")),
"InspectorView tabs are still hidden.");
+ let nodeSet = once(panelWin, EVENTS.UI_INSPECTOR_NODE_SET);
click(panelWin, findGraphNode(panelWin, nodeIds[1]));
- yield once(panelWin, EVENTS.UI_INSPECTOR_NODE_SET);
+ yield nodeSet;
ok(!isVisible($("#web-audio-editor-details-pane-empty")),
"Empty message hides even when loading node while open.");
ok(isVisible($("#web-audio-editor-tabs")),
"Switches to tab view when loading node while open.");
is($("#web-audio-inspector-title").value, "Oscillator",
"Inspector title updates when loading node while open.");
diff --git a/browser/devtools/webaudioeditor/test/browser_wa_inspector.js b/browser/devtools/webaudioeditor/test/browser_wa_inspector.js
index 616be40..ed845bc 100644
--- a/browser/devtools/webaudioeditor/test/browser_wa_inspector.js
+++ b/browser/devtools/webaudioeditor/test/browser_wa_inspector.js
@@ -25,35 +25,37 @@ add_task(function*() {
ok(!InspectorView.isVisible(), "InspectorView hidden on start.");
ok(isVisible($("#web-audio-editor-details-pane-empty")),
"InspectorView empty message should show when no node's selected.");
ok(!isVisible($("#web-audio-editor-tabs")),
"InspectorView tabs view should be hidden when no node's selected.");
is($("#web-audio-inspector-title").value, "AudioNode Inspector",
"Inspector should have default title when empty.");
- click(panelWin, findGraphNode(panelWin, nodeIds[1]));
// Wait for the node to be set as well as the inspector to come fully into the view
- yield Promise.all([
+ let nodeSet = Promise.all([
once(panelWin, EVENTS.UI_INSPECTOR_NODE_SET),
once(panelWin, EVENTS.UI_INSPECTOR_TOGGLED)
]);
+ click(panelWin, findGraphNode(panelWin, nodeIds[1]));
+ yield nodeSet;
ok(InspectorView.isVisible(), "InspectorView shown once node selected.");
ok(!isVisible($("#web-audio-editor-details-pane-empty")),
"InspectorView empty message hidden when node selected.");
ok(isVisible($("#web-audio-editor-tabs")),
"InspectorView tabs view visible when node selected.");
is($("#web-audio-inspector-title").value, "Oscillator",
"Inspector should have the node title when a node is selected.");
is($("#web-audio-editor-tabs").selectedIndex, 0,
"default tab selected should be the parameters tab.");
+ nodeSet = once(panelWin, EVENTS.UI_INSPECTOR_NODE_SET);
click(panelWin, findGraphNode(panelWin, nodeIds[2]));
- yield once(panelWin, EVENTS.UI_INSPECTOR_NODE_SET);
+ yield nodeSet;
is($("#web-audio-inspector-title").value, "Gain",
"Inspector title updates when a new node is selected.");
yield teardown(target);
});
diff --git a/browser/devtools/webaudioeditor/test/browser_wa_properties-view-edit-01.js b/browser/devtools/webaudioeditor/test/browser_wa_properties-view-edit-01.js
index 673eb76..bebcbc3 100644
--- a/browser/devtools/webaudioeditor/test/browser_wa_properties-view-edit-01.js
+++ b/browser/devtools/webaudioeditor/test/browser_wa_properties-view-edit-01.js
@@ -3,56 +3,56 @@
/**
* Tests that properties are updated when modifying the VariablesView.
*/
add_task(function*() {
let { target, panel } = yield initWebAudioEditor(SIMPLE_CONTEXT_URL);
let { panelWin } = panel;
- let { gFront, $, $$, EVENTS, InspectorView } = panelWin;
- let gVars = InspectorView._propsView;
+ let { gFront, $, $$, EVENTS, PropertiesView } = panelWin;
+ let gVars = PropertiesView._propsView;
let started = once(gFront, "start-context");
reload(target);
let [actors] = yield Promise.all([
get3(gFront, "create-node"),
waitForGraphRendered(panelWin, 3, 2)
]);
let nodeIds = actors.map(actor => actor.actorID);
click(panelWin, findGraphNode(panelWin, nodeIds[1]));
// Wait for the node to be set as well as the inspector to come fully into the view
yield Promise.all([
- once(panelWin, EVENTS.UI_INSPECTOR_NODE_SET),
+ waitForInspectorRender(panelWin, EVENTS),
once(panelWin, EVENTS.UI_INSPECTOR_TOGGLED)
]);
let setAndCheck = setAndCheckVariable(panelWin, gVars);
checkVariableView(gVars, 0, {
"type": "sine",
"frequency": 440,
"detune": 0
}, "default loaded string");
click(panelWin, findGraphNode(panelWin, nodeIds[2]));
- yield once(panelWin, EVENTS.UI_INSPECTOR_NODE_SET);
+ yield waitForInspectorRender(panelWin, EVENTS),
checkVariableView(gVars, 0, {
"gain": 0
}, "default loaded number");
click(panelWin, findGraphNode(panelWin, nodeIds[1]));
- yield once(panelWin, EVENTS.UI_INSPECTOR_NODE_SET);
+ yield waitForInspectorRender(panelWin, EVENTS),
yield setAndCheck(0, "type", "square", "square", "sets string as string");
click(panelWin, findGraphNode(panelWin, nodeIds[2]));
- yield once(panelWin, EVENTS.UI_INSPECTOR_NODE_SET);
+ yield waitForInspectorRender(panelWin, EVENTS),
yield setAndCheck(0, "gain", "0.005", 0.005, "sets number as number");
yield setAndCheck(0, "gain", "0.1", 0.1, "sets float as float");
yield setAndCheck(0, "gain", ".2", 0.2, "sets float without leading zero as float");
yield teardown(target);
});
function setAndCheckVariable (panelWin, gVars) {
diff --git a/browser/devtools/webaudioeditor/test/browser_wa_properties-view-edit-02.js b/browser/devtools/webaudioeditor/test/browser_wa_properties-view-edit-02.js
index 58f31fa..f7f43983 100644
--- a/browser/devtools/webaudioeditor/test/browser_wa_properties-view-edit-02.js
+++ b/browser/devtools/webaudioeditor/test/browser_wa_properties-view-edit-02.js
@@ -3,33 +3,33 @@
/**
* Tests that properties are not updated when modifying the VariablesView.
*/
add_task(function*() {
let { target, panel } = yield initWebAudioEditor(COMPLEX_CONTEXT_URL);
let { panelWin } = panel;
- let { gFront, $, $$, EVENTS, InspectorView } = panelWin;
- let gVars = InspectorView._propsView;
+ let { gFront, $, $$, EVENTS, PropertiesView } = panelWin;
+ let gVars = PropertiesView._propsView;
let started = once(gFront, "start-context");
reload(target);
let [actors] = yield Promise.all([
getN(gFront, "create-node", 8),
waitForGraphRendered(panelWin, 8, 8)
]);
let nodeIds = actors.map(actor => actor.actorID);
click(panelWin, findGraphNode(panelWin, nodeIds[3]));
// Wait for the node to be set as well as the inspector to come fully into the view
yield Promise.all([
- once(panelWin, EVENTS.UI_INSPECTOR_NODE_SET),
+ waitForInspectorRender(panelWin, EVENTS),
once(panelWin, EVENTS.UI_INSPECTOR_TOGGLED),
]);
let errorEvent = once(panelWin, EVENTS.UI_SET_PARAM_ERROR);
try {
yield modifyVariableView(panelWin, gVars, 0, "bufferSize", 2048);
} catch(e) {
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
index afbba4d..917ecc3 100644
--- a/browser/devtools/webaudioeditor/test/browser_wa_properties-view-media-nodes.js
+++ b/browser/devtools/webaudioeditor/test/browser_wa_properties-view-media-nodes.js
@@ -32,18 +32,18 @@ function waitForDeviceClosed() {
});
return deferred.promise;
}
add_task(function*() {
let { target, panel } = yield initWebAudioEditor(MEDIA_NODES_URL);
let { panelWin } = panel;
- let { gFront, $, $$, EVENTS, InspectorView } = panelWin;
- let gVars = InspectorView._propsView;
+ let { gFront, $, $$, EVENTS, PropertiesView } = panelWin;
+ let gVars = PropertiesView._propsView;
// Auto enable getUserMedia
let mediaPermissionPref = Services.prefs.getBoolPref(MEDIA_PERMISSION);
Services.prefs.setBoolPref(MEDIA_PERMISSION, true);
reload(target);
let [actors] = yield Promise.all([
@@ -54,17 +54,17 @@ add_task(function*() {
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);
+ yield waitForInspectorRender(panelWin, EVENTS);
checkVariableView(gVars, 0, NODE_DEFAULT_VALUES[types[i]], types[i]);
}
// Reset permissions on getUserMedia
Services.prefs.setBoolPref(MEDIA_PERMISSION, mediaPermissionPref);
yield teardown(target);
diff --git a/browser/devtools/webaudioeditor/test/browser_wa_properties-view-params-objects.js b/browser/devtools/webaudioeditor/test/browser_wa_properties-view-params-objects.js
index e13efe5..61fe539 100644
--- a/browser/devtools/webaudioeditor/test/browser_wa_properties-view-params-objects.js
+++ b/browser/devtools/webaudioeditor/test/browser_wa_properties-view-params-objects.js
@@ -4,41 +4,41 @@
/**
* Tests that params view correctly displays non-primitive properties
* like AudioBuffer and Float32Array in properties of AudioNodes.
*/
add_task(function*() {
let { target, panel } = yield initWebAudioEditor(BUFFER_AND_ARRAY_URL);
let { panelWin } = panel;
- let { gFront, $, $$, EVENTS, InspectorView } = panelWin;
- let gVars = InspectorView._propsView;
+ let { gFront, $, $$, EVENTS, PropertiesView } = panelWin;
+ let gVars = PropertiesView._propsView;
let started = once(gFront, "start-context");
reload(target);
let [actors] = yield Promise.all([
getN(gFront, "create-node", 3),
waitForGraphRendered(panelWin, 3, 2)
]);
let nodeIds = actors.map(actor => actor.actorID);
click(panelWin, findGraphNode(panelWin, nodeIds[2]));
- yield once(panelWin, EVENTS.UI_INSPECTOR_NODE_SET);
+ yield waitForInspectorRender(panelWin, EVENTS);
checkVariableView(gVars, 0, {
"curve": "Float32Array"
}, "WaveShaper's `curve` is listed as an `Float32Array`.");
let aVar = gVars.getScopeAtIndex(0).get("curve")
let state = aVar.target.querySelector(".theme-twisty").hasAttribute("invisible");
ok(state, "Float32Array property should not have a dropdown.");
click(panelWin, findGraphNode(panelWin, nodeIds[1]));
- yield once(panelWin, EVENTS.UI_INSPECTOR_NODE_SET);
+ yield waitForInspectorRender(panelWin, EVENTS);
checkVariableView(gVars, 0, {
"buffer": "AudioBuffer"
}, "AudioBufferSourceNode's `buffer` is listed as an `AudioBuffer`.");
aVar = gVars.getScopeAtIndex(0).get("buffer")
state = aVar.target.querySelector(".theme-twisty").hasAttribute("invisible");
ok(state, "AudioBuffer property should not have a dropdown.");
diff --git a/browser/devtools/webaudioeditor/test/browser_wa_properties-view-params.js b/browser/devtools/webaudioeditor/test/browser_wa_properties-view-params.js
index 9ce5726..5af047f 100644
--- a/browser/devtools/webaudioeditor/test/browser_wa_properties-view-params.js
+++ b/browser/devtools/webaudioeditor/test/browser_wa_properties-view-params.js
@@ -4,18 +4,18 @@
/**
* Tests that params view correctly displays all properties for nodes
* correctly, with default values and correct types.
*/
add_task(function*() {
let { target, panel } = yield initWebAudioEditor(SIMPLE_NODES_URL);
let { panelWin } = panel;
- let { gFront, $, $$, EVENTS, InspectorView } = panelWin;
- let gVars = InspectorView._propsView;
+ let { gFront, $, $$, EVENTS, PropertiesView } = panelWin;
+ let gVars = PropertiesView._propsView;
let started = once(gFront, "start-context");
reload(target);
let [actors] = yield Promise.all([
getN(gFront, "create-node", 15),
waitForGraphRendered(panelWin, 15, 0)
@@ -25,14 +25,14 @@ add_task(function*() {
"AudioDestinationNode", "AudioBufferSourceNode", "ScriptProcessorNode",
"AnalyserNode", "GainNode", "DelayNode", "BiquadFilterNode", "WaveShaperNode",
"PannerNode", "ConvolverNode", "ChannelSplitterNode", "ChannelMergerNode",
"DynamicsCompressorNode", "OscillatorNode"
];
for (let i = 0; i < types.length; i++) {
click(panelWin, findGraphNode(panelWin, nodeIds[i]));
- yield once(panelWin, EVENTS.UI_INSPECTOR_NODE_SET);
+ yield waitForInspectorRender(panelWin, EVENTS);
checkVariableView(gVars, 0, NODE_DEFAULT_VALUES[types[i]], types[i]);
}
yield teardown(target);
});
diff --git a/browser/devtools/webaudioeditor/test/browser_wa_properties-view.js b/browser/devtools/webaudioeditor/test/browser_wa_properties-view.js
index b86bf54..702f116 100644
--- a/browser/devtools/webaudioeditor/test/browser_wa_properties-view.js
+++ b/browser/devtools/webaudioeditor/test/browser_wa_properties-view.js
@@ -3,40 +3,40 @@
/**
* Tests that params view shows params when they exist, and are hidden otherwise.
*/
add_task(function*() {
let { target, panel } = yield initWebAudioEditor(SIMPLE_CONTEXT_URL);
let { panelWin } = panel;
- let { gFront, $, $$, EVENTS, InspectorView } = panelWin;
- let gVars = InspectorView._propsView;
+ let { gFront, $, $$, EVENTS, PropertiesView } = panelWin;
+ let gVars = PropertiesView._propsView;
let started = once(gFront, "start-context");
reload(target);
let [actors] = yield Promise.all([
get3(gFront, "create-node"),
waitForGraphRendered(panelWin, 3, 2)
]);
let nodeIds = actors.map(actor => actor.actorID);
// Gain node
click(panelWin, findGraphNode(panelWin, nodeIds[2]));
- yield once(panelWin, EVENTS.UI_INSPECTOR_NODE_SET);
+ yield waitForInspectorRender(panelWin, EVENTS);
- ok(isVisible($("#properties-tabpanel-content")), "Parameters shown when they exist.");
- ok(!isVisible($("#properties-tabpanel-content-empty")),
+ ok(isVisible($("#properties-content")), "Parameters shown when they exist.");
+ ok(!isVisible($("#properties-empty")),
"Empty message hidden when AudioParams exist.");
// Destination node
click(panelWin, findGraphNode(panelWin, nodeIds[0]));
- yield once(panelWin, EVENTS.UI_INSPECTOR_NODE_SET);
+ yield waitForInspectorRender(panelWin, EVENTS);
- ok(!isVisible($("#properties-tabpanel-content")),
+ ok(!isVisible($("#properties-content")),
"Parameters hidden when they don't exist.");
- ok(isVisible($("#properties-tabpanel-content-empty")),
+ ok(isVisible($("#properties-empty")),
"Empty message shown when no AudioParams exist.");
yield teardown(target);
});
diff --git a/browser/devtools/webaudioeditor/test/browser_webaudio-actor-automation-event.js b/browser/devtools/webaudioeditor/test/browser_webaudio-actor-automation-event.js
index 407754e..ef98dfa 100644
--- a/browser/devtools/webaudioeditor/test/browser_webaudio-actor-automation-event.js
+++ b/browser/devtools/webaudioeditor/test/browser_webaudio-actor-automation-event.js
@@ -30,22 +30,23 @@ add_task(function*() {
function onAutomationEvent (e) {
let { eventName, paramName, args } = e;
let exp = expected[events.length];
is(eventName, exp[0], "correct eventName in event");
is(paramName, "frequency", "correct paramName in event");
is(args.length, exp.length - 1, "correct length in args");
+
args.forEach((a, i) => {
// In the case of an array
if (typeof a === "object") {
- a.forEach((f, j) => is(f, exp[i + 1][j], "correct argument in args"));
+ a.forEach((f, j) => is(f, exp[i + 1][j], `correct argument in Float32Array: ${f}`));
} else {
- is(a, exp[i + 1], "correct argument in args");
+ is(a, exp[i + 1], `correct ${i+1}th argument in args: ${a}`);
}
});
events.push([eventName].concat(args));
}
front.off("automation-event", onAutomationEvent);
yield removeTab(target.tab);
});
diff --git a/browser/devtools/webaudioeditor/test/head.js b/browser/devtools/webaudioeditor/test/head.js
index 1b10e28..fc9ea9f 100644
--- a/browser/devtools/webaudioeditor/test/head.js
+++ b/browser/devtools/webaudioeditor/test/head.js
@@ -226,17 +226,17 @@ function waitForGraphRendered (front, nodeCount, edgeCount, paramEdgeCount) {
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")),
+ ok(isVisible(scope.window.$("#properties-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,
@@ -408,28 +408,38 @@ function checkAutomationValue (values, time, expected) {
/**
* Entries are ordered in `values` according to time, so if we can't find an exact point
* on a time of interest, return the point in between the threshold. This should
* get us a very close value.
*/
function getValueAt (values, time) {
for (let i = 0; i < values.length; i++) {
- if (values[i].t === time) {
+ if (values[i].delta === time) {
return values[i].value;
}
- if (values[i].t > time) {
+ if (values[i].delta > time) {
return (values[i - 1].value + values[i].value) / 2;
}
}
return values[values.length - 1].value;
}
}
/**
+ * Wait for all inspector tabs to complete rendering.
+ */
+function waitForInspectorRender (panelWin, EVENTS) {
+ return Promise.all([
+ once(panelWin, EVENTS.UI_PROPERTIES_TAB_RENDERED),
+ once(panelWin, EVENTS.UI_AUTOMATION_TAB_RENDERED)
+ ]);
+}
+
+/**
* List of audio node properties to test against expectations of the AudioNode actor
*/
const NODE_DEFAULT_VALUES = {
"AudioDestinationNode": {},
"MediaElementAudioSourceNode": {},
"MediaStreamAudioSourceNode": {},
"MediaStreamAudioDestinationNode": {
diff --git a/browser/devtools/webaudioeditor/views/automation.js b/browser/devtools/webaudioeditor/views/automation.js
new file mode 100644
index 0000000..d6107d7
--- /dev/null
+++ b/browser/devtools/webaudioeditor/views/automation.js
@@ -0,0 +1,159 @@
+/* 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/. */
+"use strict";
+
+/**
+ * Functions handling the audio node inspector UI.
+ */
+
+let AutomationView = {
+
+ /**
+ * Initialization function called when the tool starts up.
+ */
+ initialize: function () {
+ this._buttons = $("#automation-param-toolbar-buttons");
+ this.graph = new LineGraphWidget($("#automation-graph"), { avg: false });
+ this.graph.selectionEnabled = false;
+
+ this._onButtonClick = this._onButtonClick.bind(this);
+ this._onNodeSet = this._onNodeSet.bind(this);
+ this._onResize = this._onResize.bind(this);
+
+ this._buttons.addEventListener("click", this._onButtonClick);
+ window.on(EVENTS.UI_INSPECTOR_RESIZE, this._onResize);
+ window.on(EVENTS.UI_INSPECTOR_NODE_SET, this._onNodeSet);
+ },
+
+ /**
+ * Destruction function called when the tool cleans up.
+ */
+ destroy: function () {
+ this._buttons.removeEventListener("click", this._onButtonClick);
+ window.off(EVENTS.UI_INSPECTOR_RESIZE, this._onResize);
+ window.off(EVENTS.UI_INSPECTOR_NODE_SET, this._onNodeSet);
+ },
+
+ /**
+ * Empties out the props view.
+ */
+ resetUI: function () {
+ this._currentNode = null;
+ },
+
+ /**
+ * On a new node selection, create the Automation panel for
+ * that specific node.
+ */
+ build: Task.async(function* () {
+ let node = this._currentNode;
+
+ let props = yield node.getParams();
+ let params = props.filter(({ flags }) => flags && flags.param);
+
+ this._createParamButtons(params);
+
+ this._selectedParamName = params[0] ? params[0].param : null;
+ this.render();
+ }),
+
+ /**
+ * Renders the graph for specified `paramName`. Called when
+ * the parameter view is changed, or when new param data events
+ * are fired for the currently specified param.
+ */
+ render: Task.async(function *() {
+ let node = this._currentNode;
+ let paramName = this._selectedParamName;
+ // Escape if either node or parameter name does not exist.
+ if (!node || !paramName) {
+ this._setState("no-params");
+ window.emit(EVENTS.UI_AUTOMATION_TAB_RENDERED, null);
+ return;
+ }
+
+ let { values, events } = yield node.getAutomationData(paramName);
+ this._setState(events.length ? "show" : "no-events");
+ yield this.graph.setDataWhenReady(values);
+ window.emit(EVENTS.UI_AUTOMATION_TAB_RENDERED, node.id);
+ }),
+
+ /**
+ * Create the buttons for each AudioParam, that when clicked,
+ * render the graph for that AudioParam.
+ */
+ _createParamButtons: function (params) {
+ this._buttons.innerHTML = "";
+ params.forEach((param, i) => {
+ let button = document.createElement("toolbarbutton");
+ button.setAttribute("class", "devtools-toolbarbutton automation-param-button");
+ button.setAttribute("data-param", param.param);
+ // Set label to the parameter name, should not be L10N'd
+ button.setAttribute("label", param.param);
+
+ // If first button, set to 'selected' for styling
+ if (i === 0) {
+ button.setAttribute("selected", true);
+ }
+
+ this._buttons.appendChild(button);
+ });
+ },
+
+ /**
+ * Internally sets the current audio node and rebuilds appropriate
+ * views.
+ */
+ _setAudioNode: function (node) {
+ this._currentNode = node;
+ if (this._currentNode) {
+ this.build();
+ }
+ },
+
+ /**
+ * Toggles the subviews to display messages whether or not
+ * the audio node has no AudioParams, no automation events, or
+ * shows the graph.
+ */
+ _setState: function (state) {
+ let contentView = $("#automation-content");
+ let emptyView = $("#automation-empty");
+
+ let graphView = $("#automation-graph-container");
+ let noEventsView = $("#automation-no-events");
+
+ contentView.hidden = state === "no-params";
+ emptyView.hidden = state !== "no-params";
+
+ graphView.hidden = state !== "show";
+ noEventsView.hidden = state !== "no-events";
+ },
+
+ /**
+ * Event handlers
+ */
+
+ _onButtonClick: function (e) {
+ Array.forEach($$(".automation-param-button"), $btn => $btn.removeAttribute("selected"));
+ let paramName = e.target.getAttribute("data-param");
+ e.target.setAttribute("selected", true);
+ this._selectedParamName = paramName;
+ this.render();
+ },
+
+ /**
+ * Called when the inspector is resized.
+ */
+ _onResize: function () {
+ this.graph.refresh();
+ },
+
+ /**
+ * Called when the inspector view determines a node is selected.
+ */
+ _onNodeSet: function (_, id) {
+ this._setAudioNode(id != null ? gAudioNodes.get(id) : null);
+ }
+};
diff --git a/browser/devtools/webaudioeditor/views/context.js b/browser/devtools/webaudioeditor/views/context.js
index 139047c..bd3cbf6 100644
--- a/browser/devtools/webaudioeditor/views/context.js
+++ b/browser/devtools/webaudioeditor/views/context.js
@@ -33,41 +33,38 @@ const GRAPH_REDRAW_EVENTS = ["add", "connect", "disconnect", "remove"];
*/
let ContextView = {
/**
* Initialization function, called when the tool is started.
*/
initialize: function() {
this._onGraphNodeClick = this._onGraphNodeClick.bind(this);