browser/devtools/shadereditor/test/browser_webgl-actor-test-08.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 varying variable is
michael@0 6 * changed in one shader.
michael@0 7 */
michael@0 8
michael@0 9 function ifWebGLSupported() {
michael@0 10 let [target, debuggee, front] = yield initBackend(SIMPLE_CANVAS_URL);
michael@0 11 front.setup({ reload: true });
michael@0 12
michael@0 13 let programActor = yield once(front, "program-linked");
michael@0 14 let vertexShader = yield programActor.getVertexShader();
michael@0 15 let fragmentShader = yield programActor.getFragmentShader();
michael@0 16
michael@0 17 let oldVertSource = yield vertexShader.getText();
michael@0 18 let newVertSource = oldVertSource.replace("= aVertexColor", "= vec3(0, 0, 1)");
michael@0 19 let status = yield vertexShader.compile(newVertSource);
michael@0 20 ok(!status,
michael@0 21 "The new vertex shader source was compiled without errors.");
michael@0 22
michael@0 23 yield waitForFrame(debuggee);
michael@0 24 yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 0, g: 0, b: 255, a: 255 }, true);
michael@0 25 yield ensurePixelIs(debuggee, { x: 128, y: 128 }, { r: 0, g: 0, b: 255, a: 255 }, true);
michael@0 26 yield ensurePixelIs(debuggee, { x: 511, y: 511 }, { r: 0, g: 0, b: 255, a: 255 }, true);
michael@0 27
michael@0 28 let vertSource = yield vertexShader.getText();
michael@0 29 let fragSource = yield fragmentShader.getText();
michael@0 30 ok(vertSource.contains("vFragmentColor = vec3(0, 0, 1);"),
michael@0 31 "The vertex shader source is correct after changing it.");
michael@0 32 ok(fragSource.contains("gl_FragColor = vec4(vFragmentColor, 1.0);"),
michael@0 33 "The fragment shader source is correct after changing the vertex shader.");
michael@0 34
michael@0 35 yield removeTab(target.tab);
michael@0 36 finish();
michael@0 37 }

mercurial