browser/devtools/shadereditor/test/browser_se_shaders-edit-03.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 would permanently store
michael@0 6 * their new source on the backend and reshow it in the frontend when required.
michael@0 7 */
michael@0 8
michael@0 9 function ifWebGLSupported() {
michael@0 10 let [target, debuggee, panel] = yield initShaderEditor(MULTIPLE_CONTEXTS_URL);
michael@0 11 let { gFront, EVENTS, ShadersListView, ShadersEditorsView } = panel.panelWin;
michael@0 12
michael@0 13 reload(target);
michael@0 14
michael@0 15 yield promise.all([
michael@0 16 once(gFront, "program-linked"),
michael@0 17 once(gFront, "program-linked")
michael@0 18 ]);
michael@0 19
michael@0 20 yield once(panel.panelWin, EVENTS.SOURCES_SHOWN)
michael@0 21
michael@0 22 let vsEditor = yield ShadersEditorsView._getEditor("vs");
michael@0 23 let fsEditor = yield ShadersEditorsView._getEditor("fs");
michael@0 24
michael@0 25 is(ShadersListView.selectedIndex, 0,
michael@0 26 "The first program is currently selected.");
michael@0 27 is(vsEditor.getText().indexOf("1);"), 136,
michael@0 28 "The vertex shader editor contains the correct initial text (1).");
michael@0 29 is(fsEditor.getText().indexOf("1);"), 117,
michael@0 30 "The fragment shader editor contains the correct initial text (1).");
michael@0 31 is(vsEditor.getText().indexOf("2.);"), -1,
michael@0 32 "The vertex shader editor contains the correct initial text (2).");
michael@0 33 is(fsEditor.getText().indexOf(".0);"), -1,
michael@0 34 "The fragment shader editor contains the correct initial text (2).");
michael@0 35
michael@0 36 vsEditor.replaceText("2.", { line: 5, ch: 44 }, { line: 5, ch: 45 });
michael@0 37 yield once(panel.panelWin, EVENTS.SHADER_COMPILED);
michael@0 38
michael@0 39 fsEditor.replaceText(".0", { line: 5, ch: 35 }, { line: 5, ch: 37 });
michael@0 40 yield once(panel.panelWin, EVENTS.SHADER_COMPILED);
michael@0 41
michael@0 42 ok(true, "Vertex and fragment shaders were changed.");
michael@0 43
michael@0 44 yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 0, g: 0, b: 0, a: 255 }, true, "#canvas1");
michael@0 45 yield ensurePixelIs(debuggee, { x: 32, y: 32 }, { r: 255, g: 255, b: 0, a: 0 }, true, "#canvas1");
michael@0 46 yield ensurePixelIs(debuggee, { x: 64, y: 64 }, { r: 255, g: 255, b: 0, a: 0 }, true, "#canvas1");
michael@0 47 yield ensurePixelIs(debuggee, { x: 127, y: 127 }, { r: 0, g: 0, b: 0, a: 255 }, true, "#canvas1");
michael@0 48 yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 0, g: 255, b: 255, a: 255 }, true, "#canvas2");
michael@0 49 yield ensurePixelIs(debuggee, { x: 32, y: 32 }, { r: 0, g: 255, b: 255, a: 255 }, true, "#canvas2");
michael@0 50 yield ensurePixelIs(debuggee, { x: 64, y: 64 }, { r: 0, g: 255, b: 255, a: 255 }, true, "#canvas2");
michael@0 51 yield ensurePixelIs(debuggee, { x: 127, y: 127 }, { r: 0, g: 255, b: 255, a: 255 }, true, "#canvas2");
michael@0 52
michael@0 53 ok(true, "The vertex and fragment shaders were recompiled successfully.");
michael@0 54
michael@0 55 EventUtils.sendMouseEvent({ type: "mousedown" }, ShadersListView.items[1].target);
michael@0 56 yield once(panel.panelWin, EVENTS.SOURCES_SHOWN);
michael@0 57
michael@0 58 is(ShadersListView.selectedIndex, 1,
michael@0 59 "The second program is currently selected.");
michael@0 60 is(vsEditor.getText().indexOf("1);"), 136,
michael@0 61 "The vertex shader editor contains the correct text (1).");
michael@0 62 is(fsEditor.getText().indexOf("1);"), 117,
michael@0 63 "The fragment shader editor contains the correct text (1).");
michael@0 64 is(vsEditor.getText().indexOf("2.);"), -1,
michael@0 65 "The vertex shader editor contains the correct text (2).");
michael@0 66 is(fsEditor.getText().indexOf(".0);"), -1,
michael@0 67 "The fragment shader editor contains the correct text (2).");
michael@0 68
michael@0 69 EventUtils.sendMouseEvent({ type: "mousedown" }, ShadersListView.items[0].target);
michael@0 70 yield once(panel.panelWin, EVENTS.SOURCES_SHOWN);
michael@0 71
michael@0 72 is(ShadersListView.selectedIndex, 0,
michael@0 73 "The first program is currently selected again.");
michael@0 74 is(vsEditor.getText().indexOf("1);"), -1,
michael@0 75 "The vertex shader editor contains the correct text (3).");
michael@0 76 is(fsEditor.getText().indexOf("1);"), -1,
michael@0 77 "The fragment shader editor contains the correct text (3).");
michael@0 78 is(vsEditor.getText().indexOf("2.);"), 136,
michael@0 79 "The vertex shader editor contains the correct text (4).");
michael@0 80 is(fsEditor.getText().indexOf(".0);"), 116,
michael@0 81 "The fragment shader editor contains the correct text (4).");
michael@0 82
michael@0 83 yield teardown(panel);
michael@0 84 finish();
michael@0 85 }

mercurial