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 rendering is updated when a uniform variable is michael@0: * changed in one shader of a page with multiple WebGL contexts. 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: let firstFragmentShader = yield firstProgramActor.getFragmentShader(); michael@0: let secondFragmentShader = yield secondProgramActor.getFragmentShader(); michael@0: michael@0: let oldFragSource = yield firstFragmentShader.getText(); michael@0: let newFragSource = oldFragSource.replace("vec4(uColor", "vec4(0.25, 0.25, 0.25"); michael@0: let status = yield firstFragmentShader.compile(newFragSource); michael@0: ok(!status, michael@0: "The first new fragment shader source was compiled without errors."); michael@0: michael@0: yield waitForFrame(debuggee); michael@0: yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 64, g: 64, b: 64, a: 255 }, true, "#canvas1"); michael@0: yield ensurePixelIs(debuggee, { x: 127, y: 127 }, { r: 64, g: 64, b: 64, 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: 0, g: 255, b: 255, a: 255 }, true, "#canvas2"); michael@0: ok(true, "The first fragment shader was changed."); michael@0: michael@0: let oldFragSource = yield secondFragmentShader.getText(); michael@0: let newFragSource = oldFragSource.replace("vec4(uColor", "vec4(0.75, 0.75, 0.75"); michael@0: let status = yield secondFragmentShader.compile(newFragSource); michael@0: ok(!status, michael@0: "The second new fragment shader source was compiled without errors."); michael@0: michael@0: yield waitForFrame(debuggee); michael@0: yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 64, g: 64, b: 64, a: 255 }, true, "#canvas1"); michael@0: yield ensurePixelIs(debuggee, { x: 127, y: 127 }, { r: 64, g: 64, b: 64, a: 255 }, true, "#canvas1"); michael@0: yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 191, g: 191, b: 191, a: 255 }, true, "#canvas2"); michael@0: yield ensurePixelIs(debuggee, { x: 127, y: 127 }, { r: 191, g: 191, b: 191, a: 255 }, true, "#canvas2"); michael@0: ok(true, "The second fragment shader was changed."); michael@0: michael@0: yield removeTab(target.tab); michael@0: finish(); michael@0: }