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 compile or linkage errors are emitted when a shader source michael@0: * gets malformed after being edited. michael@0: */ michael@0: michael@0: function ifWebGLSupported() { michael@0: let [target, debuggee, panel] = yield initShaderEditor(SIMPLE_CANVAS_URL); michael@0: let { gFront, EVENTS, ShadersEditorsView } = panel.panelWin; michael@0: michael@0: reload(target); michael@0: yield promise.all([ michael@0: once(gFront, "program-linked"), michael@0: once(panel.panelWin, EVENTS.SOURCES_SHOWN) michael@0: ]); michael@0: michael@0: let vsEditor = yield ShadersEditorsView._getEditor("vs"); michael@0: let fsEditor = yield ShadersEditorsView._getEditor("fs"); michael@0: michael@0: vsEditor.replaceText("vec3", { line: 7, ch: 22 }, { line: 7, ch: 26 }); michael@0: let [, error] = yield onceSpread(panel.panelWin, EVENTS.SHADER_COMPILED); michael@0: michael@0: ok(error, michael@0: "The new vertex shader source was compiled with errors."); michael@0: is(error.compile, "", michael@0: "The compilation status should be empty."); michael@0: isnot(error.link, "", michael@0: "The linkage status should not be empty."); michael@0: is(error.link.split("ERROR").length - 1, 2, michael@0: "The linkage status contains two errors."); michael@0: ok(error.link.contains("ERROR: 0:8: 'constructor'"), michael@0: "A constructor error is contained in the linkage status."); michael@0: ok(error.link.contains("ERROR: 0:8: 'assign'"), michael@0: "An assignment error is contained in the linkage status."); michael@0: michael@0: fsEditor.replaceText("vec4", { line: 2, ch: 14 }, { line: 2, ch: 18 }); michael@0: let [, error] = yield onceSpread(panel.panelWin, EVENTS.SHADER_COMPILED); michael@0: michael@0: ok(error, michael@0: "The new fragment shader source was compiled with errors."); michael@0: is(error.compile, "", michael@0: "The compilation status should be empty."); michael@0: isnot(error.link, "", michael@0: "The linkage status should not be empty."); michael@0: is(error.link.split("ERROR").length - 1, 1, michael@0: "The linkage status contains one error."); michael@0: ok(error.link.contains("ERROR: 0:6: 'constructor'"), michael@0: "A constructor error is contained in the linkage status."); michael@0: michael@0: yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 255, g: 0, b: 0, a: 255 }, true); michael@0: yield ensurePixelIs(debuggee, { x: 511, y: 511 }, { r: 0, g: 255, b: 0, a: 255 }, true); michael@0: michael@0: vsEditor.replaceText("vec4", { line: 7, ch: 22 }, { line: 7, ch: 26 }); michael@0: let [, error] = yield onceSpread(panel.panelWin, EVENTS.SHADER_COMPILED); michael@0: ok(!error, "The new vertex shader source was compiled successfully."); michael@0: michael@0: fsEditor.replaceText("vec3", { line: 2, ch: 14 }, { line: 2, ch: 18 }); michael@0: let [, error] = yield onceSpread(panel.panelWin, EVENTS.SHADER_COMPILED); michael@0: ok(!error, "The new fragment shader source was compiled successfully."); michael@0: michael@0: yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 255, g: 0, b: 0, a: 255 }, true); michael@0: yield ensurePixelIs(debuggee, { x: 511, y: 511 }, { r: 0, g: 255, b: 0, a: 255 }, true); michael@0: michael@0: yield teardown(panel); michael@0: finish(); michael@0: }