browser/devtools/shadereditor/test/browser_se_programs-list.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.

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

mercurial