forked from jsantell/firefox-patches
-
Notifications
You must be signed in to change notification settings - Fork 0
/
1066450-fix-navigation-wae-regression.patch
200 lines (183 loc) · 6.84 KB
/
1066450-fix-navigation-wae-regression.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
From f3da7d0634aa7081683025e1a89f13ca318ea0d2 Mon Sep 17 00:00:00 2001
From: Jordan Santell <[email protected]>
Date: Mon, 22 Sep 2014 10:21:56 -0700
Subject: Bug 1066450 - Fix regression of web audio tools not reinitializing after navigation. r=vp
---
browser/devtools/webaudioeditor/test/browser.ini | 1 +
.../webaudioeditor/test/browser_wa_navigate.js | 45 ++++++++++++++++++++++
browser/devtools/webaudioeditor/test/head.js | 5 +++
toolkit/devtools/server/actors/webaudio.js | 13 +++++++
4 files changed, 64 insertions(+)
create mode 100644 browser/devtools/webaudioeditor/test/browser_wa_navigate.js
diff --git a/browser/devtools/webaudioeditor/test/browser.ini b/browser/devtools/webaudioeditor/test/browser.ini
index 943d647..9545b68 100644
--- a/browser/devtools/webaudioeditor/test/browser.ini
+++ b/browser/devtools/webaudioeditor/test/browser.ini
@@ -26,16 +26,17 @@ support-files =
[browser_wa_destroy-node-01.js]
[browser_wa_first-run.js]
[browser_wa_reset-01.js]
[browser_wa_reset-02.js]
[browser_wa_reset-03.js]
[browser_wa_reset-04.js]
+[browser_wa_navigate.js]
[browser_wa_graph-click.js]
[browser_wa_graph-markers.js]
[browser_wa_graph-render-01.js]
[browser_wa_graph-render-02.js]
[browser_wa_graph-render-03.js]
[browser_wa_graph-render-04.js]
[browser_wa_graph-selected.js]
diff --git a/browser/devtools/webaudioeditor/test/browser_wa_navigate.js b/browser/devtools/webaudioeditor/test/browser_wa_navigate.js
new file mode 100644
index 0000000..8bacd64
--- /dev/null
+++ b/browser/devtools/webaudioeditor/test/browser_wa_navigate.js
@@ -0,0 +1,45 @@
+/* Any copyright is dedicated to the Public Domain.
+ http://creativecommons.org/publicdomain/zero/1.0/ */
+
+/**
+ * Tests naviating from a page to another will repopulate
+ * the audio graph if both pages have an AudioContext.
+ */
+
+function spawnTest() {
+ let [target, debuggee, panel] = yield initWebAudioEditor(SIMPLE_CONTEXT_URL);
+ let { panelWin } = panel;
+ let { gFront, $ } = panelWin;
+
+ reload(target);
+
+ var [actors] = yield Promise.all([
+ get3(gFront, "create-node"),
+ waitForGraphRendered(panelWin, 3, 2)
+ ]);
+
+ var { nodes, edges } = countGraphObjects(panelWin);
+ ise(nodes, 3, "should only be 3 nodes.");
+ ise(edges, 2, "should only be 2 edges.");
+
+ navigate(target, SIMPLE_NODES_URL);
+
+ var [actors] = yield Promise.all([
+ getN(gFront, "create-node", 14),
+ waitForGraphRendered(panelWin, 14, 0)
+ ]);
+
+ is($("#reload-notice").hidden, true,
+ "The 'reload this page' notice should be hidden after context found after navigation.");
+ is($("#waiting-notice").hidden, true,
+ "The 'waiting for an audio context' notice should be hidden after context found after navigation.");
+ is($("#content").hidden, false,
+ "The tool's content should reappear without closing and reopening the toolbox.");
+
+ var { nodes, edges } = countGraphObjects(panelWin);
+ ise(nodes, 14, "after navigation, should have 14 nodes");
+ ise(edges, 0, "after navigation, should have 0 edges.");
+
+ yield teardown(panel);
+ finish();
+}
diff --git a/browser/devtools/webaudioeditor/test/head.js b/browser/devtools/webaudioeditor/test/head.js
index 0f5d0cb..d088c36 100644
--- a/browser/devtools/webaudioeditor/test/head.js
+++ b/browser/devtools/webaudioeditor/test/head.js
@@ -109,16 +109,21 @@ function once(aTarget, aEventName, aUseCapture = false) {
return deferred.promise;
}
function reload(aTarget, aWaitForTargetEvent = "navigate") {
aTarget.activeTab.reload();
return once(aTarget, aWaitForTargetEvent);
}
+function navigate(aTarget, aUrl, aWaitForTargetEvent = "navigate") {
+ executeSoon(() => aTarget.activeTab.navigateTo(aUrl));
+ return once(aTarget, aWaitForTargetEvent);
+}
+
function test () {
Task.spawn(spawnTest).then(finish, handleError);
}
function initBackend(aUrl) {
info("Initializing a web audio editor front.");
if (!DebuggerServer.initialized) {
diff --git a/toolkit/devtools/server/actors/webaudio.js b/toolkit/devtools/server/actors/webaudio.js
index 41529ae..1358696 100644
--- a/toolkit/devtools/server/actors/webaudio.js
+++ b/toolkit/devtools/server/actors/webaudio.js
@@ -279,16 +279,17 @@ let WebAudioActor = exports.WebAudioActor = protocol.ActorClass({
// Store ChromeOnly ID (`nativeID` property on AudioNodeActor) mapped
// to the associated actorID, so we don't have to expose `nativeID`
// to the client in any way.
this._nativeToActorID = new Map();
this._onDestroyNode = this._onDestroyNode.bind(this);
this._onGlobalDestroyed = this._onGlobalDestroyed.bind(this);
+ this._onGlobalCreated = this._onGlobalCreated.bind(this);
},
destroy: function(conn) {
protocol.Actor.prototype.destroy.call(this, conn);
this.finalize();
},
/**
@@ -317,16 +318,19 @@ let WebAudioActor = exports.WebAudioActor = protocol.ActorClass({
this._callWatcher.onCall = this._onContentFunctionCall;
this._callWatcher.setup({
tracedGlobals: AUDIO_GLOBALS,
startRecording: true,
performReload: reload,
holdWeak: true,
storeCalls: false
});
+ // Bind to `window-ready` so we can reenable recording on the
+ // call watcher
+ on(this.tabActor, "window-ready", this._onGlobalCreated);
// Bind to the `window-destroyed` event so we can unbind events between
// the global destruction and the `finalize` cleanup method on the actor.
on(this.tabActor, "window-destroyed", this._onGlobalDestroyed);
}, {
request: { reload: Option(0, "boolean") },
oneway: true
}),
@@ -390,16 +394,17 @@ let WebAudioActor = exports.WebAudioActor = protocol.ActorClass({
*/
finalize: method(function() {
if (!this._initialized) {
return;
}
this.tabActor = null;
this._initialized = false;
off(this.tabActor, "window-destroyed", this._onGlobalDestroyed);
+ off(this.tabActor, "window-ready", this._onGlobalCreated);
this._nativeToActorID = null;
this._callWatcher.eraseRecording();
this._callWatcher.finalize();
this._callWatcher = null;
}, {
oneway: true
}),
@@ -565,16 +570,24 @@ let WebAudioActor = exports.WebAudioActor = protocol.ActorClass({
// the mapping should not be found, so we do not emit an event.
if (actor) {
this._nativeToActorID.delete(nativeID);
emit(this, "destroy-node", actor);
}
},
/**
+ * Ensures that the new global has recording on
+ * so we can proxy the function calls.
+ */
+ _onGlobalCreated: function () {
+ this._callWatcher.resumeRecording();
+ },
+
+ /**
* Called when the underlying ContentObserver fires `global-destroyed`
* so we can cleanup some things between the global being destroyed and
* when the actor's `finalize` method gets called.
*/
_onGlobalDestroyed: function ({id}) {
if (this._callWatcher._tracedWindowId !== id) {
return;
}
--
1.8.4.2