Wed, 31 Dec 2014 06:09:35 +0100
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 the programs list contains an entry after vertex and fragment |
michael@0 | 6 | * shaders are linked. |
michael@0 | 7 | */ |
michael@0 | 8 | |
michael@0 | 9 | function ifWebGLSupported() { |
michael@0 | 10 | let [target, debuggee, panel] = yield initShaderEditor(MULTIPLE_CONTEXTS_URL); |
michael@0 | 11 | let { gFront, EVENTS, L10N, ShadersListView, ShadersEditorsView } = panel.panelWin; |
michael@0 | 12 | |
michael@0 | 13 | is(ShadersListView.itemCount, 0, |
michael@0 | 14 | "The shaders list should initially be empty."); |
michael@0 | 15 | is(ShadersListView.selectedItem, null, |
michael@0 | 16 | "The shaders list has no selected item."); |
michael@0 | 17 | is(ShadersListView.selectedIndex, -1, |
michael@0 | 18 | "The shaders list has a negative index."); |
michael@0 | 19 | |
michael@0 | 20 | reload(target); |
michael@0 | 21 | |
michael@0 | 22 | let [firstProgramActor, secondProgramActor] = yield promise.all([ |
michael@0 | 23 | getPrograms(gFront, 2, (actors) => { |
michael@0 | 24 | // Fired upon each actor addition, we want to check only |
michael@0 | 25 | // after the first actor has been added so we can test state |
michael@0 | 26 | if (actors.length === 1) |
michael@0 | 27 | checkFirstProgram(); |
michael@0 | 28 | if (actors.length === 2) |
michael@0 | 29 | checkSecondProgram(); |
michael@0 | 30 | }), |
michael@0 | 31 | once(panel.panelWin, EVENTS.SOURCES_SHOWN) |
michael@0 | 32 | ]).then(([programs, ]) => programs); |
michael@0 | 33 | |
michael@0 | 34 | is(ShadersListView.attachments[0].label, L10N.getFormatStr("shadersList.programLabel", 0), |
michael@0 | 35 | "The correct first label is shown in the shaders list."); |
michael@0 | 36 | is(ShadersListView.attachments[1].label, L10N.getFormatStr("shadersList.programLabel", 1), |
michael@0 | 37 | "The correct second label is shown in the shaders list."); |
michael@0 | 38 | |
michael@0 | 39 | let vertexShader = yield firstProgramActor.getVertexShader(); |
michael@0 | 40 | let fragmentShader = yield firstProgramActor.getFragmentShader(); |
michael@0 | 41 | let vertSource = yield vertexShader.getText(); |
michael@0 | 42 | let fragSource = yield fragmentShader.getText(); |
michael@0 | 43 | |
michael@0 | 44 | let vsEditor = yield ShadersEditorsView._getEditor("vs"); |
michael@0 | 45 | let fsEditor = yield ShadersEditorsView._getEditor("fs"); |
michael@0 | 46 | |
michael@0 | 47 | is(vertSource, vsEditor.getText(), |
michael@0 | 48 | "The vertex shader editor contains the correct text."); |
michael@0 | 49 | is(fragSource, fsEditor.getText(), |
michael@0 | 50 | "The vertex shader editor contains the correct text."); |
michael@0 | 51 | |
michael@0 | 52 | let compiled = once(panel.panelWin, EVENTS.SHADER_COMPILED).then(() => { |
michael@0 | 53 | ok(false, "Selecting a different program shouldn't recompile its shaders."); |
michael@0 | 54 | }); |
michael@0 | 55 | |
michael@0 | 56 | let shown = once(panel.panelWin, EVENTS.SOURCES_SHOWN).then(() => { |
michael@0 | 57 | ok(true, "The vertex and fragment sources have changed in the editors."); |
michael@0 | 58 | }); |
michael@0 | 59 | |
michael@0 | 60 | EventUtils.sendMouseEvent({ type: "mousedown" }, ShadersListView.items[1].target); |
michael@0 | 61 | yield shown; |
michael@0 | 62 | |
michael@0 | 63 | is(ShadersListView.selectedItem, ShadersListView.items[1], |
michael@0 | 64 | "The shaders list has a correct item selected."); |
michael@0 | 65 | is(ShadersListView.selectedIndex, 1, |
michael@0 | 66 | "The shaders list has a correct index selected."); |
michael@0 | 67 | |
michael@0 | 68 | yield teardown(panel); |
michael@0 | 69 | finish(); |
michael@0 | 70 | |
michael@0 | 71 | function checkFirstProgram () { |
michael@0 | 72 | is(ShadersListView.itemCount, 1, |
michael@0 | 73 | "The shaders list contains one entry."); |
michael@0 | 74 | is(ShadersListView.selectedItem, ShadersListView.items[0], |
michael@0 | 75 | "The shaders list has a correct item selected."); |
michael@0 | 76 | is(ShadersListView.selectedIndex, 0, |
michael@0 | 77 | "The shaders list has a correct index selected."); |
michael@0 | 78 | } |
michael@0 | 79 | function checkSecondProgram () { |
michael@0 | 80 | is(ShadersListView.itemCount, 2, |
michael@0 | 81 | "The shaders list contains two entries."); |
michael@0 | 82 | is(ShadersListView.selectedItem, ShadersListView.items[0], |
michael@0 | 83 | "The shaders list has a correct item selected."); |
michael@0 | 84 | is(ShadersListView.selectedIndex, 0, |
michael@0 | 85 | "The shaders list has a correct index selected."); |
michael@0 | 86 | } |
michael@0 | 87 | } |