1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/devtools/shadereditor/test/browser_se_shaders-edit-03.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,85 @@ 1.4 +/* Any copyright is dedicated to the Public Domain. 1.5 + http://creativecommons.org/publicdomain/zero/1.0/ */ 1.6 + 1.7 +/** 1.8 + * Tests if editing a vertex and a fragment shader would permanently store 1.9 + * their new source on the backend and reshow it in the frontend when required. 1.10 + */ 1.11 + 1.12 +function ifWebGLSupported() { 1.13 + let [target, debuggee, panel] = yield initShaderEditor(MULTIPLE_CONTEXTS_URL); 1.14 + let { gFront, EVENTS, ShadersListView, ShadersEditorsView } = panel.panelWin; 1.15 + 1.16 + reload(target); 1.17 + 1.18 + yield promise.all([ 1.19 + once(gFront, "program-linked"), 1.20 + once(gFront, "program-linked") 1.21 + ]); 1.22 + 1.23 + yield once(panel.panelWin, EVENTS.SOURCES_SHOWN) 1.24 + 1.25 + let vsEditor = yield ShadersEditorsView._getEditor("vs"); 1.26 + let fsEditor = yield ShadersEditorsView._getEditor("fs"); 1.27 + 1.28 + is(ShadersListView.selectedIndex, 0, 1.29 + "The first program is currently selected."); 1.30 + is(vsEditor.getText().indexOf("1);"), 136, 1.31 + "The vertex shader editor contains the correct initial text (1)."); 1.32 + is(fsEditor.getText().indexOf("1);"), 117, 1.33 + "The fragment shader editor contains the correct initial text (1)."); 1.34 + is(vsEditor.getText().indexOf("2.);"), -1, 1.35 + "The vertex shader editor contains the correct initial text (2)."); 1.36 + is(fsEditor.getText().indexOf(".0);"), -1, 1.37 + "The fragment shader editor contains the correct initial text (2)."); 1.38 + 1.39 + vsEditor.replaceText("2.", { line: 5, ch: 44 }, { line: 5, ch: 45 }); 1.40 + yield once(panel.panelWin, EVENTS.SHADER_COMPILED); 1.41 + 1.42 + fsEditor.replaceText(".0", { line: 5, ch: 35 }, { line: 5, ch: 37 }); 1.43 + yield once(panel.panelWin, EVENTS.SHADER_COMPILED); 1.44 + 1.45 + ok(true, "Vertex and fragment shaders were changed."); 1.46 + 1.47 + yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 0, g: 0, b: 0, a: 255 }, true, "#canvas1"); 1.48 + yield ensurePixelIs(debuggee, { x: 32, y: 32 }, { r: 255, g: 255, b: 0, a: 0 }, true, "#canvas1"); 1.49 + yield ensurePixelIs(debuggee, { x: 64, y: 64 }, { r: 255, g: 255, b: 0, a: 0 }, true, "#canvas1"); 1.50 + yield ensurePixelIs(debuggee, { x: 127, y: 127 }, { r: 0, g: 0, b: 0, a: 255 }, true, "#canvas1"); 1.51 + yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 0, g: 255, b: 255, a: 255 }, true, "#canvas2"); 1.52 + yield ensurePixelIs(debuggee, { x: 32, y: 32 }, { r: 0, g: 255, b: 255, a: 255 }, true, "#canvas2"); 1.53 + yield ensurePixelIs(debuggee, { x: 64, y: 64 }, { r: 0, g: 255, b: 255, a: 255 }, true, "#canvas2"); 1.54 + yield ensurePixelIs(debuggee, { x: 127, y: 127 }, { r: 0, g: 255, b: 255, a: 255 }, true, "#canvas2"); 1.55 + 1.56 + ok(true, "The vertex and fragment shaders were recompiled successfully."); 1.57 + 1.58 + EventUtils.sendMouseEvent({ type: "mousedown" }, ShadersListView.items[1].target); 1.59 + yield once(panel.panelWin, EVENTS.SOURCES_SHOWN); 1.60 + 1.61 + is(ShadersListView.selectedIndex, 1, 1.62 + "The second program is currently selected."); 1.63 + is(vsEditor.getText().indexOf("1);"), 136, 1.64 + "The vertex shader editor contains the correct text (1)."); 1.65 + is(fsEditor.getText().indexOf("1);"), 117, 1.66 + "The fragment shader editor contains the correct text (1)."); 1.67 + is(vsEditor.getText().indexOf("2.);"), -1, 1.68 + "The vertex shader editor contains the correct text (2)."); 1.69 + is(fsEditor.getText().indexOf(".0);"), -1, 1.70 + "The fragment shader editor contains the correct text (2)."); 1.71 + 1.72 + EventUtils.sendMouseEvent({ type: "mousedown" }, ShadersListView.items[0].target); 1.73 + yield once(panel.panelWin, EVENTS.SOURCES_SHOWN); 1.74 + 1.75 + is(ShadersListView.selectedIndex, 0, 1.76 + "The first program is currently selected again."); 1.77 + is(vsEditor.getText().indexOf("1);"), -1, 1.78 + "The vertex shader editor contains the correct text (3)."); 1.79 + is(fsEditor.getText().indexOf("1);"), -1, 1.80 + "The fragment shader editor contains the correct text (3)."); 1.81 + is(vsEditor.getText().indexOf("2.);"), 136, 1.82 + "The vertex shader editor contains the correct text (4)."); 1.83 + is(fsEditor.getText().indexOf(".0);"), 116, 1.84 + "The fragment shader editor contains the correct text (4)."); 1.85 + 1.86 + yield teardown(panel); 1.87 + finish(); 1.88 +}