michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: /** michael@0: * Tests if editing a vertex and a fragment shader would permanently store michael@0: * their new source on the backend and reshow it in the frontend when required. michael@0: */ michael@0: michael@0: function ifWebGLSupported() { michael@0: let [target, debuggee, panel] = yield initShaderEditor(MULTIPLE_CONTEXTS_URL); michael@0: let { gFront, EVENTS, ShadersListView, ShadersEditorsView } = panel.panelWin; michael@0: michael@0: reload(target); michael@0: michael@0: yield promise.all([ michael@0: once(gFront, "program-linked"), michael@0: once(gFront, "program-linked") michael@0: ]); michael@0: michael@0: yield once(panel.panelWin, EVENTS.SOURCES_SHOWN) michael@0: michael@0: let vsEditor = yield ShadersEditorsView._getEditor("vs"); michael@0: let fsEditor = yield ShadersEditorsView._getEditor("fs"); michael@0: michael@0: is(ShadersListView.selectedIndex, 0, michael@0: "The first program is currently selected."); michael@0: is(vsEditor.getText().indexOf("1);"), 136, michael@0: "The vertex shader editor contains the correct initial text (1)."); michael@0: is(fsEditor.getText().indexOf("1);"), 117, michael@0: "The fragment shader editor contains the correct initial text (1)."); michael@0: is(vsEditor.getText().indexOf("2.);"), -1, michael@0: "The vertex shader editor contains the correct initial text (2)."); michael@0: is(fsEditor.getText().indexOf(".0);"), -1, michael@0: "The fragment shader editor contains the correct initial text (2)."); michael@0: michael@0: vsEditor.replaceText("2.", { line: 5, ch: 44 }, { line: 5, ch: 45 }); michael@0: yield once(panel.panelWin, EVENTS.SHADER_COMPILED); michael@0: michael@0: fsEditor.replaceText(".0", { line: 5, ch: 35 }, { line: 5, ch: 37 }); michael@0: yield once(panel.panelWin, EVENTS.SHADER_COMPILED); michael@0: michael@0: ok(true, "Vertex and fragment shaders were changed."); michael@0: michael@0: yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 0, g: 0, b: 0, a: 255 }, true, "#canvas1"); michael@0: yield ensurePixelIs(debuggee, { x: 32, y: 32 }, { r: 255, g: 255, b: 0, a: 0 }, true, "#canvas1"); michael@0: yield ensurePixelIs(debuggee, { x: 64, y: 64 }, { r: 255, g: 255, b: 0, a: 0 }, true, "#canvas1"); michael@0: yield ensurePixelIs(debuggee, { x: 127, y: 127 }, { r: 0, g: 0, b: 0, a: 255 }, true, "#canvas1"); michael@0: yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 0, g: 255, b: 255, a: 255 }, true, "#canvas2"); michael@0: yield ensurePixelIs(debuggee, { x: 32, y: 32 }, { r: 0, g: 255, b: 255, a: 255 }, true, "#canvas2"); michael@0: yield ensurePixelIs(debuggee, { x: 64, y: 64 }, { r: 0, g: 255, b: 255, a: 255 }, true, "#canvas2"); michael@0: yield ensurePixelIs(debuggee, { x: 127, y: 127 }, { r: 0, g: 255, b: 255, a: 255 }, true, "#canvas2"); michael@0: michael@0: ok(true, "The vertex and fragment shaders were recompiled successfully."); michael@0: michael@0: EventUtils.sendMouseEvent({ type: "mousedown" }, ShadersListView.items[1].target); michael@0: yield once(panel.panelWin, EVENTS.SOURCES_SHOWN); michael@0: michael@0: is(ShadersListView.selectedIndex, 1, michael@0: "The second program is currently selected."); michael@0: is(vsEditor.getText().indexOf("1);"), 136, michael@0: "The vertex shader editor contains the correct text (1)."); michael@0: is(fsEditor.getText().indexOf("1);"), 117, michael@0: "The fragment shader editor contains the correct text (1)."); michael@0: is(vsEditor.getText().indexOf("2.);"), -1, michael@0: "The vertex shader editor contains the correct text (2)."); michael@0: is(fsEditor.getText().indexOf(".0);"), -1, michael@0: "The fragment shader editor contains the correct text (2)."); michael@0: michael@0: EventUtils.sendMouseEvent({ type: "mousedown" }, ShadersListView.items[0].target); michael@0: yield once(panel.panelWin, EVENTS.SOURCES_SHOWN); michael@0: michael@0: is(ShadersListView.selectedIndex, 0, michael@0: "The first program is currently selected again."); michael@0: is(vsEditor.getText().indexOf("1);"), -1, michael@0: "The vertex shader editor contains the correct text (3)."); michael@0: is(fsEditor.getText().indexOf("1);"), -1, michael@0: "The fragment shader editor contains the correct text (3)."); michael@0: is(vsEditor.getText().indexOf("2.);"), 136, michael@0: "The vertex shader editor contains the correct text (4)."); michael@0: is(fsEditor.getText().indexOf(".0);"), 116, michael@0: "The fragment shader editor contains the correct text (4)."); michael@0: michael@0: yield teardown(panel); michael@0: finish(); michael@0: }