browser/devtools/shadereditor/test/browser_webgl-actor-test-14.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /* Any copyright is dedicated to the Public Domain.
michael@0 2 http://creativecommons.org/publicdomain/zero/1.0/ */
michael@0 3
michael@0 4 /**
michael@0 5 * Tests that the rendering is updated when a uniform variable is
michael@0 6 * changed in one shader of a page with multiple WebGL contexts.
michael@0 7 */
michael@0 8
michael@0 9 function ifWebGLSupported() {
michael@0 10 let [target, debuggee, front] = yield initBackend(MULTIPLE_CONTEXTS_URL);
michael@0 11 front.setup({ reload: true });
michael@0 12
michael@0 13 let [firstProgramActor, secondProgramActor] = yield getPrograms(front, 2);
michael@0 14
michael@0 15 let firstFragmentShader = yield firstProgramActor.getFragmentShader();
michael@0 16 let secondFragmentShader = yield secondProgramActor.getFragmentShader();
michael@0 17
michael@0 18 let oldFragSource = yield firstFragmentShader.getText();
michael@0 19 let newFragSource = oldFragSource.replace("vec4(uColor", "vec4(0.25, 0.25, 0.25");
michael@0 20 let status = yield firstFragmentShader.compile(newFragSource);
michael@0 21 ok(!status,
michael@0 22 "The first new fragment shader source was compiled without errors.");
michael@0 23
michael@0 24 yield waitForFrame(debuggee);
michael@0 25 yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 64, g: 64, b: 64, a: 255 }, true, "#canvas1");
michael@0 26 yield ensurePixelIs(debuggee, { x: 127, y: 127 }, { r: 64, g: 64, b: 64, a: 255 }, true, "#canvas1");
michael@0 27 yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 0, g: 255, b: 255, a: 255 }, true, "#canvas2");
michael@0 28 yield ensurePixelIs(debuggee, { x: 127, y: 127 }, { r: 0, g: 255, b: 255, a: 255 }, true, "#canvas2");
michael@0 29 ok(true, "The first fragment shader was changed.");
michael@0 30
michael@0 31 let oldFragSource = yield secondFragmentShader.getText();
michael@0 32 let newFragSource = oldFragSource.replace("vec4(uColor", "vec4(0.75, 0.75, 0.75");
michael@0 33 let status = yield secondFragmentShader.compile(newFragSource);
michael@0 34 ok(!status,
michael@0 35 "The second new fragment shader source was compiled without errors.");
michael@0 36
michael@0 37 yield waitForFrame(debuggee);
michael@0 38 yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 64, g: 64, b: 64, a: 255 }, true, "#canvas1");
michael@0 39 yield ensurePixelIs(debuggee, { x: 127, y: 127 }, { r: 64, g: 64, b: 64, a: 255 }, true, "#canvas1");
michael@0 40 yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 191, g: 191, b: 191, a: 255 }, true, "#canvas2");
michael@0 41 yield ensurePixelIs(debuggee, { x: 127, y: 127 }, { r: 191, g: 191, b: 191, a: 255 }, true, "#canvas2");
michael@0 42 ok(true, "The second fragment shader was changed.");
michael@0 43
michael@0 44 yield removeTab(target.tab);
michael@0 45 finish();
michael@0 46 }

mercurial