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 highlighting a program works properly. 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: once(panel.panelWin, EVENTS.SHADER_COMPILED).then(() => { michael@0: ok(false, "No shaders should be publicly compiled during this test."); michael@0: }); michael@0: michael@0: reload(target); michael@0: let [[firstProgramActor, secondProgramActor]] = yield promise.all([ michael@0: getPrograms(gFront, 2), 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.once("change", () => { michael@0: ok(false, "The vertex shader source was unexpectedly changed."); michael@0: }); michael@0: fsEditor.once("change", () => { michael@0: ok(false, "The fragment shader source was unexpectedly changed."); michael@0: }); michael@0: once(panel.panelWin, EVENTS.SOURCES_SHOWN).then(() => { michael@0: ok(false, "No sources should be changed form this point onward."); michael@0: }); michael@0: michael@0: yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 255, g: 255, 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: 127, y: 127 }, { r: 255, g: 255, b: 0, a: 255 }, true, "#canvas1"); michael@0: yield ensurePixelIs(debuggee, { x: 127, y: 127 }, { r: 0, g: 255, b: 255, a: 255 }, true, "#canvas2"); michael@0: michael@0: ShadersListView._onProgramMouseEnter({ target: getItemLabel(panel, 0) }); michael@0: michael@0: yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 255, 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: 127, y: 127 }, { r: 255, g: 0, b: 0, a: 255 }, true, "#canvas1"); michael@0: yield ensurePixelIs(debuggee, { x: 127, y: 127 }, { r: 0, g: 255, b: 255, a: 255 }, true, "#canvas2"); michael@0: ok(true, "The first program was correctly highlighted."); michael@0: michael@0: ShadersListView._onProgramMouseLeave({ target: getItemLabel(panel, 0) }); michael@0: ShadersListView._onProgramMouseEnter({ target: getItemLabel(panel, 1) }); michael@0: michael@0: yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 255, g: 255, b: 0, a: 255 }, true, "#canvas1"); michael@0: yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 0, g: 0, b: 64, a: 255 }, true, "#canvas2"); michael@0: yield ensurePixelIs(debuggee, { x: 127, y: 127 }, { r: 255, g: 255, b: 0, a: 255 }, true, "#canvas1"); michael@0: yield ensurePixelIs(debuggee, { x: 127, y: 127 }, { r: 0, g: 0, b: 64, a: 255 }, true, "#canvas2"); michael@0: ok(true, "The second program was correctly highlighted."); michael@0: michael@0: ShadersListView._onProgramMouseLeave({ target: getItemLabel(panel, 1) }); michael@0: michael@0: yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 255, g: 255, 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: 127, y: 127 }, { r: 255, g: 255, b: 0, a: 255 }, true, "#canvas1"); michael@0: yield ensurePixelIs(debuggee, { x: 127, y: 127 }, { r: 0, g: 255, b: 255, a: 255 }, true, "#canvas2"); michael@0: ok(true, "The two programs were correctly unhighlighted."); michael@0: michael@0: ShadersListView._onProgramMouseEnter({ target: getBlackBoxCheckbox(panel, 0) }); michael@0: michael@0: yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 255, g: 255, 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: 127, y: 127 }, { r: 255, g: 255, b: 0, a: 255 }, true, "#canvas1"); michael@0: yield ensurePixelIs(debuggee, { x: 127, y: 127 }, { r: 0, g: 255, b: 255, a: 255 }, true, "#canvas2"); michael@0: ok(true, "The two programs were left unchanged after hovering a blackbox checkbox."); michael@0: michael@0: ShadersListView._onProgramMouseLeave({ target: getBlackBoxCheckbox(panel, 0) }); michael@0: michael@0: yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 255, g: 255, 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: 127, y: 127 }, { r: 255, g: 255, b: 0, a: 255 }, true, "#canvas1"); michael@0: yield ensurePixelIs(debuggee, { x: 127, y: 127 }, { r: 0, g: 255, b: 255, a: 255 }, true, "#canvas2"); michael@0: ok(true, "The two programs were left unchanged after unhovering a blackbox checkbox."); michael@0: michael@0: yield teardown(panel); michael@0: finish(); michael@0: } michael@0: michael@0: function getItemLabel(aPanel, aIndex) { michael@0: return aPanel.panelWin.document.querySelectorAll( michael@0: ".side-menu-widget-item-contents")[aIndex]; michael@0: } michael@0: michael@0: function getBlackBoxCheckbox(aPanel, aIndex) { michael@0: return aPanel.panelWin.document.querySelectorAll( michael@0: ".side-menu-widget-item-checkbox")[aIndex]; michael@0: }