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 if the WebGL context is correctly instrumented every time the michael@0: * target navigates. michael@0: */ michael@0: michael@0: function ifWebGLSupported() { michael@0: let [target, debuggee, front] = yield initBackend(SIMPLE_CANVAS_URL); michael@0: michael@0: front.setup({ reload: true }); michael@0: yield testHighlighting((yield once(front, "program-linked"))); michael@0: ok(true, "Canvas was correctly instrumented on the first navigation."); michael@0: michael@0: reload(target); michael@0: yield testHighlighting((yield once(front, "program-linked"))); michael@0: ok(true, "Canvas was correctly instrumented on the second navigation."); michael@0: michael@0: reload(target); michael@0: yield testHighlighting((yield once(front, "program-linked"))); michael@0: ok(true, "Canvas was correctly instrumented on the third navigation."); michael@0: michael@0: yield removeTab(target.tab); michael@0: finish(); michael@0: michael@0: function testHighlighting(programActor) { michael@0: return Task.spawn(function() { 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: 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: 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: ok(true, "The corner pixel colors are correct after unhighlighting."); michael@0: }); michael@0: } michael@0: }