-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path1058879-enable-canvas-test-e10s.patch
272 lines (248 loc) · 11.6 KB
/
1058879-enable-canvas-test-e10s.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
From 7a02d934fcbf393e37ed1013a70f27ba6eb0e416 Mon Sep 17 00:00:00 2001
From: Jordan Santell <[email protected]>
Date: Tue, 14 Oct 2014 16:30:56 -0700
Subject: Bug 1058879 - enable browser_canvas-actor-test-10.js for e10s, r=vp
---
browser/devtools/canvasdebugger/test/browser.ini | 1 -
.../test/browser_canvas-actor-test-10.js | 47 +++++++++++++---------
browser/devtools/canvasdebugger/test/head.js | 40 +++++++++++++++++-
browser/devtools/shared/frame-script-utils.js | 9 +++++
4 files changed, 77 insertions(+), 20 deletions(-)
diff --git a/browser/devtools/canvasdebugger/test/browser.ini b/browser/devtools/canvasdebugger/test/browser.ini
index 60c8c6c..2430397 100644
--- a/browser/devtools/canvasdebugger/test/browser.ini
+++ b/browser/devtools/canvasdebugger/test/browser.ini
@@ -14,17 +14,16 @@ support-files =
[browser_canvas-actor-test-03.js]
[browser_canvas-actor-test-04.js]
[browser_canvas-actor-test-05.js]
[browser_canvas-actor-test-06.js]
[browser_canvas-actor-test-07.js]
[browser_canvas-actor-test-08.js]
[browser_canvas-actor-test-09.js]
[browser_canvas-actor-test-10.js]
-skip-if = e10s # Bug 1058879 - canvas debugger tests disabled with e10s
[browser_canvas-frontend-call-highlight.js]
[browser_canvas-frontend-call-list.js]
[browser_canvas-frontend-call-search.js]
[browser_canvas-frontend-call-stack-01.js]
[browser_canvas-frontend-call-stack-02.js]
[browser_canvas-frontend-call-stack-03.js]
[browser_canvas-frontend-clear.js]
[browser_canvas-frontend-img-screenshots.js]
diff --git a/browser/devtools/canvasdebugger/test/browser_canvas-actor-test-10.js b/browser/devtools/canvasdebugger/test/browser_canvas-actor-test-10.js
index 99f0214..d46318e 100644
--- a/browser/devtools/canvasdebugger/test/browser_canvas-actor-test-10.js
+++ b/browser/devtools/canvasdebugger/test/browser_canvas-actor-test-10.js
@@ -3,18 +3,17 @@
/**
* Tests that the correct framebuffer, renderbuffer and textures are re-bound
* after generating screenshots using the actor.
*/
function ifTestingSupported() {
let { target, front } = yield initCanvasDebuggerBackend(WEBGL_BINDINGS_URL);
- // XXX - use of |debuggee| here is incompatible with e10s - bug 1058879.
- let debuggee = target.window.wrappedJSObject
+ loadFrameScripts();
let navigated = once(target, "navigate");
yield front.setup({ reload: true });
ok(true, "The front was setup up successfully.");
yield navigated;
ok(true, "Target automatically navigated when the front was set up.");
@@ -32,30 +31,36 @@ function ifTestingSupported() {
"The first screenshot has the correct width.");
is(firstScreenshot.height, CanvasFront.WEBGL_SCREENSHOT_MAX_HEIGHT,
"The first screenshot has the correct height.");
is(firstScreenshot.flipped, true,
"The first screenshot has the correct 'flipped' flag.");
is(firstScreenshot.pixels.length, 0,
"The first screenshot should be empty.");
- let gl = debuggee.gl;
- is(gl.getParameter(gl.FRAMEBUFFER_BINDING), debuggee.customFramebuffer,
+ is((yield evalInDebuggee("gl.getParameter(gl.FRAMEBUFFER_BINDING) === customFramebuffer")),
+ true,
"The debuggee's gl context framebuffer wasn't changed.");
- is(gl.getParameter(gl.RENDERBUFFER_BINDING), debuggee.customRenderbuffer,
+ is((yield evalInDebuggee("gl.getParameter(gl.RENDERBUFFER_BINDING) === customRenderbuffer")),
+ true,
"The debuggee's gl context renderbuffer wasn't changed.");
- is(gl.getParameter(gl.TEXTURE_BINDING_2D), debuggee.customTexture,
+ is((yield evalInDebuggee("gl.getParameter(gl.TEXTURE_BINDING_2D) === customTexture")),
+ true,
"The debuggee's gl context texture binding wasn't changed.");
- is(gl.getParameter(gl.VIEWPORT)[0], 128,
+ is((yield evalInDebuggee("gl.getParameter(gl.VIEWPORT)[0]")),
+ 128,
"The debuggee's gl context viewport's left coord. wasn't changed.");
- is(gl.getParameter(gl.VIEWPORT)[1], 256,
+ is((yield evalInDebuggee("gl.getParameter(gl.VIEWPORT)[1]")),
+ 256,
"The debuggee's gl context viewport's left coord. wasn't changed.");
- is(gl.getParameter(gl.VIEWPORT)[2], 384,
+ is((yield evalInDebuggee("gl.getParameter(gl.VIEWPORT)[2]")),
+ 384,
"The debuggee's gl context viewport's left coord. wasn't changed.");
- is(gl.getParameter(gl.VIEWPORT)[3], 512,
+ is((yield evalInDebuggee("gl.getParameter(gl.VIEWPORT)[3]")),
+ 512,
"The debuggee's gl context viewport's left coord. wasn't changed.");
let secondScreenshot = yield snapshotActor.generateScreenshotFor(functionCalls[1]);
is(secondScreenshot.index, 1,
"The second screenshot has the correct index.");
is(secondScreenshot.width, CanvasFront.WEBGL_SCREENSHOT_MAX_HEIGHT,
"The second screenshot has the correct width.");
is(secondScreenshot.height, CanvasFront.WEBGL_SCREENSHOT_MAX_HEIGHT,
@@ -70,27 +75,33 @@ function ifTestingSupported() {
"The second screenshot has the correct red component.");
is(new Uint8Array(secondScreenshot.pixels.buffer)[1], 0,
"The second screenshot has the correct green component.");
is(new Uint8Array(secondScreenshot.pixels.buffer)[2], 255,
"The second screenshot has the correct blue component.");
is(new Uint8Array(secondScreenshot.pixels.buffer)[3], 255,
"The second screenshot has the correct alpha component.");
- gl = debuggee.gl;
- is(gl.getParameter(gl.FRAMEBUFFER_BINDING), debuggee.customFramebuffer,
+ is((yield evalInDebuggee("gl.getParameter(gl.FRAMEBUFFER_BINDING) === customFramebuffer")),
+ true,
"The debuggee's gl context framebuffer still wasn't changed.");
- is(gl.getParameter(gl.RENDERBUFFER_BINDING), debuggee.customRenderbuffer,
+ is((yield evalInDebuggee("gl.getParameter(gl.RENDERBUFFER_BINDING) === customRenderbuffer")),
+ true,
"The debuggee's gl context renderbuffer still wasn't changed.");
- is(gl.getParameter(gl.TEXTURE_BINDING_2D), debuggee.customTexture,
+ is((yield evalInDebuggee("gl.getParameter(gl.TEXTURE_BINDING_2D) === customTexture")),
+ true,
"The debuggee's gl context texture binding still wasn't changed.");
- is(gl.getParameter(gl.VIEWPORT)[0], 128,
+ is((yield evalInDebuggee("gl.getParameter(gl.VIEWPORT)[0]")),
+ 128,
"The debuggee's gl context viewport's left coord. still wasn't changed.");
- is(gl.getParameter(gl.VIEWPORT)[1], 256,
+ is((yield evalInDebuggee("gl.getParameter(gl.VIEWPORT)[1]")),
+ 256,
"The debuggee's gl context viewport's left coord. still wasn't changed.");
- is(gl.getParameter(gl.VIEWPORT)[2], 384,
+ is((yield evalInDebuggee("gl.getParameter(gl.VIEWPORT)[2]")),
+ 384,
"The debuggee's gl context viewport's left coord. still wasn't changed.");
- is(gl.getParameter(gl.VIEWPORT)[3], 512,
+ is((yield evalInDebuggee("gl.getParameter(gl.VIEWPORT)[3]")),
+ 512,
"The debuggee's gl context viewport's left coord. still wasn't changed.");
yield removeTab(target.tab);
finish();
}
diff --git a/browser/devtools/canvasdebugger/test/head.js b/browser/devtools/canvasdebugger/test/head.js
index 1812e40..9d94cf6 100644
--- a/browser/devtools/canvasdebugger/test/head.js
+++ b/browser/devtools/canvasdebugger/test/head.js
@@ -6,29 +6,31 @@ const { classes: Cc, interfaces: Ci, utils: Cu, results: Cr } = Components;
let { Services } = Cu.import("resource://gre/modules/Services.jsm", {});
// Disable logging for all the tests. Both the debugger server and frontend will
// be affected by this pref.
let gEnableLogging = Services.prefs.getBoolPref("devtools.debugger.log");
Services.prefs.setBoolPref("devtools.debugger.log", false);
+let { generateUUID } = Cc['@mozilla.org/uuid-generator;1'].getService(Ci.nsIUUIDGenerator);
let { Task } = Cu.import("resource://gre/modules/Task.jsm", {});
let { Promise: promise } = Cu.import("resource://gre/modules/Promise.jsm", {});
let { gDevTools } = Cu.import("resource:///modules/devtools/gDevTools.jsm", {});
let { devtools } = Cu.import("resource://gre/modules/devtools/Loader.jsm", {});
let { DebuggerServer } = Cu.import("resource://gre/modules/devtools/dbg-server.jsm", {});
let { DebuggerClient } = Cu.import("resource://gre/modules/devtools/dbg-client.jsm", {});
-
let { CallWatcherFront } = devtools.require("devtools/server/actors/call-watcher");
let { CanvasFront } = devtools.require("devtools/server/actors/canvas");
let TiltGL = devtools.require("devtools/tilt/tilt-gl");
let TargetFactory = devtools.TargetFactory;
let Toolbox = devtools.Toolbox;
+let mm = null
+const FRAME_SCRIPT_UTILS_URL = "chrome://browser/content/devtools/frame-script-utils.js";
const EXAMPLE_URL = "http://example.com/browser/browser/devtools/canvasdebugger/test/";
const SIMPLE_CANVAS_URL = EXAMPLE_URL + "doc_simple-canvas.html";
const SIMPLE_BITMASKS_URL = EXAMPLE_URL + "doc_simple-canvas-bitmasks.html";
const SIMPLE_CANVAS_TRANSPARENT_URL = EXAMPLE_URL + "doc_simple-canvas-transparent.html";
const SIMPLE_CANVAS_DEEP_STACK_URL = EXAMPLE_URL + "doc_simple-canvas-deep-stack.html";
const WEBGL_ENUM_URL = EXAMPLE_URL + "doc_webgl-enum.html";
const WEBGL_BINDINGS_URL = EXAMPLE_URL + "doc_webgl-bindings.html";
@@ -43,16 +45,25 @@ registerCleanupFunction(() => {
Services.prefs.setBoolPref("devtools.canvasdebugger.enabled", gToolEnabled);
// Some of yhese tests use a lot of memory due to GL contexts, so force a GC
// to help fragmentation.
info("Forcing GC after canvas debugger test.");
Cu.forceGC();
});
+/**
+ * Call manually in tests that use frame script utils after initializing
+ * the shader editor. Call after init but before navigating to different pages.
+ */
+function loadFrameScripts () {
+ mm = gBrowser.selectedBrowser.messageManager;
+ mm.loadFrameScript(FRAME_SCRIPT_UTILS_URL, false);
+}
+
function addTab(aUrl, aWindow) {
info("Adding tab: " + aUrl);
let deferred = promise.defer();
let targetWindow = aWindow || window;
let targetBrowser = targetWindow.gBrowser;
targetWindow.focus();
@@ -227,8 +238,35 @@ function initCanvasDebuggerFrontend(aUrl) {
function teardown(aPanel) {
info("Destroying the specified canvas debugger.");
return promise.all([
once(aPanel, "destroyed"),
removeTab(aPanel.target.tab)
]);
}
+
+/**
+ * Takes a string `script` and evaluates it directly in the content
+ * in potentially a different process.
+ */
+function evalInDebuggee (script) {
+ let deferred = promise.defer();
+
+ if (!mm) {
+ throw new Error("`loadFrameScripts()` must be called when using MessageManager.");
+ }
+
+ let id = generateUUID().toString();
+ mm.sendAsyncMessage("devtools:test:eval", { script: script, id: id });
+ mm.addMessageListener("devtools:test:eval:response", handler);
+
+ function handler ({ data }) {
+ if (id !== data.id) {
+ return;
+ }
+
+ mm.removeMessageListener("devtools:test:eval:response", handler);
+ deferred.resolve(data.value);
+ }
+
+ return deferred.promise;
+}
diff --git a/browser/devtools/shared/frame-script-utils.js b/browser/devtools/shared/frame-script-utils.js
index c4e68f5..5188526 100644
--- a/browser/devtools/shared/frame-script-utils.js
+++ b/browser/devtools/shared/frame-script-utils.js
@@ -17,11 +17,20 @@ addMessageListener("devtools:test:reload", function ({ data }) {
content.location.reload(data.forceget);
});
addMessageListener("devtools:test:console", function ({ data }) {
let method = data.shift();
content.console[method].apply(content.console, data);
});
+// To eval in content, look at `evalInDebuggee` in the head.js of canvasdebugger
+// for an example.
+addMessageListener("devtools:test:eval", function ({ data }) {
+ sendAsyncMessage("devtools:test:eval:response", {
+ value: content.eval(data.script),
+ id: data.id
+ });
+});
+
addEventListener("load", function() {
sendAsyncMessage("devtools:test:load");
}, true);
--
1.8.4.2