browser/devtools/shadereditor/test/browser_se_shaders-edit-01.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 if editing a vertex and a fragment shader works properly.
michael@0 6 */
michael@0 7
michael@0 8 function ifWebGLSupported() {
michael@0 9 let [target, debuggee, panel] = yield initShaderEditor(SIMPLE_CANVAS_URL);
michael@0 10 let { gFront, $, EVENTS, ShadersEditorsView } = panel.panelWin;
michael@0 11
michael@0 12 reload(target);
michael@0 13 yield promise.all([
michael@0 14 once(gFront, "program-linked"),
michael@0 15 once(panel.panelWin, EVENTS.SOURCES_SHOWN)
michael@0 16 ]);
michael@0 17
michael@0 18 let vsEditor = yield ShadersEditorsView._getEditor("vs");
michael@0 19 let fsEditor = yield ShadersEditorsView._getEditor("fs");
michael@0 20
michael@0 21 is(vsEditor.getText().indexOf("gl_Position"), 170,
michael@0 22 "The vertex shader editor contains the correct text.");
michael@0 23 is(fsEditor.getText().indexOf("gl_FragColor"), 97,
michael@0 24 "The fragment shader editor contains the correct text.");
michael@0 25
michael@0 26 is($("#vs-editor-label").hasAttribute("selected"), false,
michael@0 27 "The vertex shader editor shouldn't be initially selected.");
michael@0 28 is($("#fs-editor-label").hasAttribute("selected"), false,
michael@0 29 "The vertex shader editor shouldn't be initially selected.");
michael@0 30
michael@0 31 yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 255, g: 0, b: 0, a: 255 }, true);
michael@0 32 yield ensurePixelIs(debuggee, { x: 128, y: 128 }, { r: 191, g: 64, b: 0, a: 255 }, true);
michael@0 33 yield ensurePixelIs(debuggee, { x: 511, y: 511 }, { r: 0, g: 255, b: 0, a: 255 }, true);
michael@0 34
michael@0 35 vsEditor.focus();
michael@0 36
michael@0 37 is($("#vs-editor-label").hasAttribute("selected"), true,
michael@0 38 "The vertex shader editor should now be selected.");
michael@0 39 is($("#fs-editor-label").hasAttribute("selected"), false,
michael@0 40 "The vertex shader editor shouldn't still not be selected.");
michael@0 41
michael@0 42 vsEditor.replaceText("2.0", { line: 7, ch: 44 }, { line: 7, ch: 47 });
michael@0 43 yield once(panel.panelWin, EVENTS.SHADER_COMPILED);
michael@0 44
michael@0 45 ok(true, "Vertex shader was changed.");
michael@0 46
michael@0 47 yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 0, g: 0, b: 0, a: 255 }, true);
michael@0 48 yield ensurePixelIs(debuggee, { x: 128, y: 128 }, { r: 255, g: 0, b: 0, a: 255 }, true);
michael@0 49 yield ensurePixelIs(debuggee, { x: 511, y: 511 }, { r: 0, g: 0, b: 0, a: 255 }, true);
michael@0 50
michael@0 51 ok(true, "The vertex shader was recompiled successfully.");
michael@0 52
michael@0 53 fsEditor.focus();
michael@0 54
michael@0 55 is($("#vs-editor-label").hasAttribute("selected"), false,
michael@0 56 "The vertex shader editor should now be deselected.");
michael@0 57 is($("#fs-editor-label").hasAttribute("selected"), true,
michael@0 58 "The vertex shader editor should now be selected.");
michael@0 59
michael@0 60 fsEditor.replaceText("0.5", { line: 5, ch: 44 }, { line: 5, ch: 47 });
michael@0 61 yield once(panel.panelWin, EVENTS.SHADER_COMPILED);
michael@0 62
michael@0 63 ok(true, "Fragment shader was changed.");
michael@0 64
michael@0 65 yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 0, g: 0, b: 0, a: 255 }, true);
michael@0 66 yield ensurePixelIs(debuggee, { x: 128, y: 128 }, { r: 255, g: 0, b: 0, a: 127 }, true);
michael@0 67 yield ensurePixelIs(debuggee, { x: 511, y: 511 }, { r: 0, g: 0, b: 0, a: 255 }, true);
michael@0 68
michael@0 69 ok(true, "The fragment shader was recompiled successfully.");
michael@0 70
michael@0 71 yield teardown(panel);
michael@0 72 finish();
michael@0 73 }

mercurial