browser/devtools/shadereditor/test/browser_se_programs-highlight-01.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 highlighting a program works properly.
michael@0 6 */
michael@0 7
michael@0 8 function ifWebGLSupported() {
michael@0 9 let [target, debuggee, panel] = yield initShaderEditor(MULTIPLE_CONTEXTS_URL);
michael@0 10 let { gFront, EVENTS, ShadersListView, ShadersEditorsView } = panel.panelWin;
michael@0 11
michael@0 12 once(panel.panelWin, EVENTS.SHADER_COMPILED).then(() => {
michael@0 13 ok(false, "No shaders should be publicly compiled during this test.");
michael@0 14 });
michael@0 15
michael@0 16 reload(target);
michael@0 17 let [[firstProgramActor, secondProgramActor]] = yield promise.all([
michael@0 18 getPrograms(gFront, 2),
michael@0 19 once(panel.panelWin, EVENTS.SOURCES_SHOWN)
michael@0 20 ]);
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 vsEditor.once("change", () => {
michael@0 26 ok(false, "The vertex shader source was unexpectedly changed.");
michael@0 27 });
michael@0 28 fsEditor.once("change", () => {
michael@0 29 ok(false, "The fragment shader source was unexpectedly changed.");
michael@0 30 });
michael@0 31 once(panel.panelWin, EVENTS.SOURCES_SHOWN).then(() => {
michael@0 32 ok(false, "No sources should be changed form this point onward.");
michael@0 33 });
michael@0 34
michael@0 35 yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 255, g: 255, b: 0, a: 255 }, true, "#canvas1");
michael@0 36 yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 0, g: 255, b: 255, a: 255 }, true, "#canvas2");
michael@0 37 yield ensurePixelIs(debuggee, { x: 127, y: 127 }, { r: 255, g: 255, b: 0, a: 255 }, true, "#canvas1");
michael@0 38 yield ensurePixelIs(debuggee, { x: 127, y: 127 }, { r: 0, g: 255, b: 255, a: 255 }, true, "#canvas2");
michael@0 39
michael@0 40 ShadersListView._onProgramMouseEnter({ target: getItemLabel(panel, 0) });
michael@0 41
michael@0 42 yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 255, g: 0, b: 0, a: 255 }, true, "#canvas1");
michael@0 43 yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 0, g: 255, b: 255, a: 255 }, true, "#canvas2");
michael@0 44 yield ensurePixelIs(debuggee, { x: 127, y: 127 }, { r: 255, g: 0, b: 0, a: 255 }, true, "#canvas1");
michael@0 45 yield ensurePixelIs(debuggee, { x: 127, y: 127 }, { r: 0, g: 255, b: 255, a: 255 }, true, "#canvas2");
michael@0 46 ok(true, "The first program was correctly highlighted.");
michael@0 47
michael@0 48 ShadersListView._onProgramMouseLeave({ target: getItemLabel(panel, 0) });
michael@0 49 ShadersListView._onProgramMouseEnter({ target: getItemLabel(panel, 1) });
michael@0 50
michael@0 51 yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 255, g: 255, b: 0, a: 255 }, true, "#canvas1");
michael@0 52 yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 0, g: 0, b: 64, a: 255 }, true, "#canvas2");
michael@0 53 yield ensurePixelIs(debuggee, { x: 127, y: 127 }, { r: 255, g: 255, b: 0, a: 255 }, true, "#canvas1");
michael@0 54 yield ensurePixelIs(debuggee, { x: 127, y: 127 }, { r: 0, g: 0, b: 64, a: 255 }, true, "#canvas2");
michael@0 55 ok(true, "The second program was correctly highlighted.");
michael@0 56
michael@0 57 ShadersListView._onProgramMouseLeave({ target: getItemLabel(panel, 1) });
michael@0 58
michael@0 59 yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 255, g: 255, b: 0, a: 255 }, true, "#canvas1");
michael@0 60 yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 0, g: 255, b: 255, a: 255 }, true, "#canvas2");
michael@0 61 yield ensurePixelIs(debuggee, { x: 127, y: 127 }, { r: 255, g: 255, b: 0, a: 255 }, true, "#canvas1");
michael@0 62 yield ensurePixelIs(debuggee, { x: 127, y: 127 }, { r: 0, g: 255, b: 255, a: 255 }, true, "#canvas2");
michael@0 63 ok(true, "The two programs were correctly unhighlighted.");
michael@0 64
michael@0 65 ShadersListView._onProgramMouseEnter({ target: getBlackBoxCheckbox(panel, 0) });
michael@0 66
michael@0 67 yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 255, g: 255, b: 0, a: 255 }, true, "#canvas1");
michael@0 68 yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 0, g: 255, b: 255, a: 255 }, true, "#canvas2");
michael@0 69 yield ensurePixelIs(debuggee, { x: 127, y: 127 }, { r: 255, g: 255, b: 0, a: 255 }, true, "#canvas1");
michael@0 70 yield ensurePixelIs(debuggee, { x: 127, y: 127 }, { r: 0, g: 255, b: 255, a: 255 }, true, "#canvas2");
michael@0 71 ok(true, "The two programs were left unchanged after hovering a blackbox checkbox.");
michael@0 72
michael@0 73 ShadersListView._onProgramMouseLeave({ target: getBlackBoxCheckbox(panel, 0) });
michael@0 74
michael@0 75 yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 255, g: 255, b: 0, a: 255 }, true, "#canvas1");
michael@0 76 yield ensurePixelIs(debuggee, { x: 0, y: 0 }, { r: 0, g: 255, b: 255, a: 255 }, true, "#canvas2");
michael@0 77 yield ensurePixelIs(debuggee, { x: 127, y: 127 }, { r: 255, g: 255, b: 0, a: 255 }, true, "#canvas1");
michael@0 78 yield ensurePixelIs(debuggee, { x: 127, y: 127 }, { r: 0, g: 255, b: 255, a: 255 }, true, "#canvas2");
michael@0 79 ok(true, "The two programs were left unchanged after unhovering a blackbox checkbox.");
michael@0 80
michael@0 81 yield teardown(panel);
michael@0 82 finish();
michael@0 83 }
michael@0 84
michael@0 85 function getItemLabel(aPanel, aIndex) {
michael@0 86 return aPanel.panelWin.document.querySelectorAll(
michael@0 87 ".side-menu-widget-item-contents")[aIndex];
michael@0 88 }
michael@0 89
michael@0 90 function getBlackBoxCheckbox(aPanel, aIndex) {
michael@0 91 return aPanel.panelWin.document.querySelectorAll(
michael@0 92 ".side-menu-widget-item-checkbox")[aIndex];
michael@0 93 }

mercurial