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 multiple WebGL contexts are correctly handled. michael@0: */ michael@0: michael@0: function ifWebGLSupported() { michael@0: let [target, debuggee, front] = yield initBackend(MULTIPLE_CONTEXTS_URL); michael@0: front.setup({ reload: true }); michael@0: michael@0: let [firstProgramActor, secondProgramActor] = yield getPrograms(front, 2); michael@0: michael@0: isnot(firstProgramActor, secondProgramActor, michael@0: "Two distinct program actors were recevide from two separate contexts."); michael@0: michael@0: let firstVertexShader = yield firstProgramActor.getVertexShader(); michael@0: let firstFragmentShader = yield firstProgramActor.getFragmentShader(); michael@0: let secondVertexShader = yield secondProgramActor.getVertexShader(); michael@0: let secondFragmentShader = yield secondProgramActor.getFragmentShader(); michael@0: michael@0: isnot(firstVertexShader, secondVertexShader, michael@0: "The two programs should have distinct vertex shaders."); michael@0: isnot(firstFragmentShader, secondFragmentShader, michael@0: "The two programs should have distinct fragment shaders."); michael@0: michael@0: let firstVertSource = yield firstVertexShader.getText(); michael@0: let firstFragSource = yield firstFragmentShader.getText(); michael@0: let secondVertSource = yield secondVertexShader.getText(); michael@0: let secondFragSource = yield secondFragmentShader.getText(); michael@0: michael@0: is(firstVertSource, secondVertSource, michael@0: "The vertex shaders should have identical sources."); michael@0: is(firstFragSource, secondFragSource, michael@0: "The vertex shaders should have identical sources."); michael@0: michael@0: yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 255, g: 255, b: 0, a: 255 }, true, "#canvas1"); michael@0: yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 0, g: 255, b: 255, a: 255 }, true, "#canvas2"); michael@0: yield ensurePixelIs(debuggee, { x: 127, y: 127 }, { r: 255, g: 255, b: 0, a: 255 }, true, "#canvas1"); michael@0: yield ensurePixelIs(debuggee, { x: 127, y: 127 }, { r: 0, g: 255, b: 255, a: 255 }, true, "#canvas2"); michael@0: ok(true, "The two canvases are correctly drawn."); michael@0: michael@0: yield firstProgramActor.highlight([1, 0, 0, 1]); michael@0: yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 255, g: 0, b: 0, a: 255 }, true, "#canvas1"); michael@0: yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 0, g: 255, b: 255, a: 255 }, true, "#canvas2"); michael@0: yield ensurePixelIs(debuggee, { x: 127, y: 127 }, { r: 255, g: 0, b: 0, a: 255 }, true, "#canvas1"); michael@0: yield ensurePixelIs(debuggee, { x: 127, y: 127 }, { r: 0, g: 255, b: 255, a: 255 }, true, "#canvas2"); michael@0: ok(true, "The first canvas was correctly filled after highlighting."); michael@0: michael@0: yield secondProgramActor.highlight([0, 1, 0, 1]); michael@0: yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 255, g: 0, b: 0, a: 255 }, true, "#canvas1"); michael@0: yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 0, g: 255, b: 0, a: 255 }, true, "#canvas2"); michael@0: yield ensurePixelIs(debuggee, { x: 127, y: 127 }, { r: 255, g: 0, b: 0, a: 255 }, true, "#canvas1"); michael@0: yield ensurePixelIs(debuggee, { x: 127, y: 127 }, { r: 0, g: 255, b: 0, a: 255 }, true, "#canvas2"); michael@0: ok(true, "The second canvas was correctly filled after highlighting."); michael@0: michael@0: yield firstProgramActor.unhighlight(); michael@0: yield secondProgramActor.unhighlight(); michael@0: yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 255, g: 255, b: 0, a: 255 }, true, "#canvas1"); michael@0: yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 0, g: 255, b: 255, a: 255 }, true, "#canvas2"); michael@0: yield ensurePixelIs(debuggee, { x: 127, y: 127 }, { r: 255, g: 255, b: 0, a: 255 }, true, "#canvas1"); michael@0: yield ensurePixelIs(debuggee, { x: 127, y: 127 }, { r: 0, g: 255, b: 255, a: 255 }, true, "#canvas2"); michael@0: ok(true, "The two canvases were correctly filled after unhighlighting."); michael@0: michael@0: yield removeTab(target.tab); michael@0: finish(); michael@0: }