From b1914a6e0ec592f2137953681c2995a9ae235966 Mon Sep 17 00:00:00 2001 From: Jordan Santell Date: Wed, 29 Oct 2014 13:03:00 +0100 Subject: [PATCH] Bug 1058879 - enable browser_canvas-actor-test-10.js for e10s. r=vp --- .../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 60c8c6c4b9f..2430397707b 100644 --- a/browser/devtools/canvasdebugger/test/browser.ini +++ b/browser/devtools/canvasdebugger/test/browser.ini @@ -19,7 +19,6 @@ support-files = [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] 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 99f021476c6..d46318e1ccf 100644 --- a/browser/devtools/canvasdebugger/test/browser_canvas-actor-test-10.js +++ b/browser/devtools/canvasdebugger/test/browser_canvas-actor-test-10.js @@ -8,8 +8,7 @@ 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"); @@ -37,20 +36,26 @@ function ifTestingSupported() { 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]); @@ -75,20 +80,26 @@ function ifTestingSupported() { 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); diff --git a/browser/devtools/canvasdebugger/test/head.js b/browser/devtools/canvasdebugger/test/head.js index 1812e40e1e2..9d94cf6f86a 100644 --- a/browser/devtools/canvasdebugger/test/head.js +++ b/browser/devtools/canvasdebugger/test/head.js @@ -11,19 +11,21 @@ let { Services } = Cu.import("resource://gre/modules/Services.jsm", {}); 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"; @@ -48,6 +50,15 @@ registerCleanupFunction(() => { 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); @@ -232,3 +243,30 @@ function teardown(aPanel) { 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 c4e68f5cbff..5188526ffe1 100644 --- a/browser/devtools/shared/frame-script-utils.js +++ b/browser/devtools/shared/frame-script-utils.js @@ -22,6 +22,15 @@ addMessageListener("devtools:test:console", function ({ data }) { 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);