michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: /** michael@0: * Tests that the highlight/unhighlight and blackbox/unblackbox operations on michael@0: * program actors work as expected. michael@0: */ michael@0: michael@0: function ifWebGLSupported() { michael@0: let [target, debuggee, front] = yield initBackend(SIMPLE_CANVAS_URL); michael@0: front.setup({ reload: true }); michael@0: michael@0: let programActor = yield once(front, "program-linked"); michael@0: let vertexShader = yield programActor.getVertexShader(); michael@0: let fragmentShader = yield programActor.getFragmentShader(); michael@0: michael@0: yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 255, g: 0, b: 0, a: 255 }, true); michael@0: yield ensurePixelIs(debuggee, { x: 511, y: 511 }, { r: 0, g: 255, b: 0, a: 255 }, true); michael@0: yield checkShaderSource("The shader sources are correct before highlighting."); michael@0: ok(true, "The corner pixel colors are correct before highlighting."); michael@0: michael@0: yield programActor.highlight([0, 1, 0, 1]); michael@0: yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 0, g: 0, b: 0, a: 255 }, true); michael@0: yield ensurePixelIs(debuggee, { x: 511, y: 511 }, { r: 0, g: 255, b: 0, a: 255 }, true); michael@0: yield checkShaderSource("The shader sources are preserved after highlighting."); michael@0: ok(true, "The corner pixel colors are correct after highlighting."); michael@0: michael@0: yield programActor.unhighlight(); michael@0: yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 255, g: 0, b: 0, a: 255 }, true); michael@0: yield ensurePixelIs(debuggee, { x: 511, y: 511 }, { r: 0, g: 255, b: 0, a: 255 }, true); michael@0: yield checkShaderSource("The shader sources are correct after unhighlighting."); michael@0: ok(true, "The corner pixel colors are correct after unhighlighting."); michael@0: michael@0: yield programActor.blackbox(); michael@0: yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 0, g: 0, b: 0, a: 255 }, true); michael@0: yield ensurePixelIs(debuggee, { x: 511, y: 511 }, { r: 0, g: 0, b: 0, a: 255 }, true); michael@0: yield checkShaderSource("The shader sources are preserved after blackboxing."); michael@0: ok(true, "The corner pixel colors are correct after blackboxing."); michael@0: michael@0: yield programActor.unblackbox(); michael@0: yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 255, g: 0, b: 0, a: 255 }, true); michael@0: yield ensurePixelIs(debuggee, { x: 511, y: 511 }, { r: 0, g: 255, b: 0, a: 255 }, true); michael@0: yield checkShaderSource("The shader sources are correct after unblackboxing."); michael@0: ok(true, "The corner pixel colors are correct after unblackboxing."); michael@0: michael@0: function checkShaderSource(aMessage) { michael@0: return Task.spawn(function() { michael@0: let newVertexShader = yield programActor.getVertexShader(); michael@0: let newFragmentShader = yield programActor.getFragmentShader(); michael@0: is(vertexShader, newVertexShader, michael@0: "The same vertex shader actor was retrieved."); michael@0: is(fragmentShader, newFragmentShader, michael@0: "The same fragment shader actor was retrieved."); michael@0: michael@0: let vertSource = yield newVertexShader.getText(); michael@0: let fragSource = yield newFragmentShader.getText(); michael@0: ok(vertSource.contains("I'm special!") && michael@0: fragSource.contains("I'm also special!"), aMessage); michael@0: }); michael@0: } michael@0: michael@0: yield removeTab(target.tab); michael@0: finish(); michael@0: }