1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/devtools/shadereditor/test/browser_se_editors-lazy-init.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,48 @@ 1.4 +/* Any copyright is dedicated to the Public Domain. 1.5 + http://creativecommons.org/publicdomain/zero/1.0/ */ 1.6 + 1.7 +/** 1.8 + * Tests if source editors are lazily initialized. 1.9 + */ 1.10 + 1.11 +function ifWebGLSupported() { 1.12 + let [target, debuggee, panel] = yield initShaderEditor(SIMPLE_CANVAS_URL); 1.13 + let { gFront, ShadersEditorsView } = panel.panelWin; 1.14 + 1.15 + try { 1.16 + yield ShadersEditorsView._getEditor("vs"); 1.17 + ok(false, "The promise for a vertex shader editor should be rejected."); 1.18 + } catch (e) { 1.19 + ok(true, "The vertex shader editors wasn't initialized."); 1.20 + } 1.21 + 1.22 + try { 1.23 + yield ShadersEditorsView._getEditor("fs"); 1.24 + ok(false, "The promise for a fragment shader editor should be rejected."); 1.25 + } catch (e) { 1.26 + ok(true, "The fragment shader editors wasn't initialized."); 1.27 + } 1.28 + 1.29 + reload(target); 1.30 + yield once(gFront, "program-linked"); 1.31 + 1.32 + let vsEditor = yield ShadersEditorsView._getEditor("vs"); 1.33 + let fsEditor = yield ShadersEditorsView._getEditor("fs"); 1.34 + 1.35 + ok(vsEditor, "A vertex shader editor was initialized."); 1.36 + ok(fsEditor, "A fragment shader editor was initialized."); 1.37 + 1.38 + isnot(vsEditor, fsEditor, 1.39 + "The vertex shader editor is distinct from the fragment shader editor."); 1.40 + 1.41 + let vsEditor2 = yield ShadersEditorsView._getEditor("vs"); 1.42 + let fsEditor2 = yield ShadersEditorsView._getEditor("fs"); 1.43 + 1.44 + is(vsEditor, vsEditor2, 1.45 + "The vertex shader editor instances are cached."); 1.46 + is(fsEditor, fsEditor2, 1.47 + "The fragment shader editor instances are cached."); 1.48 + 1.49 + yield teardown(panel); 1.50 + finish(); 1.51 +}