summaryrefslogtreecommitdiffstats
path: root/devtools/client/shadereditor/test/browser_se_programs-cache.js
blob: 5e5708e446a414db8309736ad8ae30e372563d67 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/* Any copyright is dedicated to the Public Domain.
   http://creativecommons.org/publicdomain/zero/1.0/ */

/**
 * Tests that program and shader actors are cached in the frontend.
 */

function* ifWebGLSupported() {
  let { target, debuggee, panel } = yield initShaderEditor(MULTIPLE_CONTEXTS_URL);
  let { EVENTS, gFront, ShadersListView, ShadersEditorsView } = panel.panelWin;

  reload(target);
  let [[programActor]] = yield promise.all([
    getPrograms(gFront, 1),
    once(panel.panelWin, EVENTS.SOURCES_SHOWN)
  ]);

  let programItem = ShadersListView.selectedItem;

  is(programItem.attachment.programActor, programActor,
    "The correct program actor is cached for the selected item.");

  is((yield programActor.getVertexShader()),
     (yield programItem.attachment.vs),
    "The cached vertex shader promise returns the correct actor.");

  is((yield programActor.getFragmentShader()),
     (yield programItem.attachment.fs),
    "The cached fragment shader promise returns the correct actor.");

  is((yield (yield programActor.getVertexShader()).getText()),
     (yield (yield ShadersEditorsView._getEditor("vs")).getText()),
    "The cached vertex shader promise returns the correct text.");

  is((yield (yield programActor.getFragmentShader()).getText()),
     (yield (yield ShadersEditorsView._getEditor("fs")).getText()),
    "The cached fragment shader promise returns the correct text.");

  yield teardown(panel);
  finish();
}