michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: /** michael@0: * Tests target navigations are handled correctly in the UI. michael@0: */ michael@0: michael@0: function ifWebGLSupported() { michael@0: let [target, debuggee, panel] = yield initShaderEditor(SIMPLE_CANVAS_URL); michael@0: let { gFront, $, EVENTS, ShadersListView, ShadersEditorsView } = panel.panelWin; michael@0: michael@0: reload(target); michael@0: yield promise.all([ michael@0: once(gFront, "program-linked"), michael@0: once(panel.panelWin, EVENTS.SOURCES_SHOWN) michael@0: ]); michael@0: michael@0: is($("#reload-notice").hidden, true, michael@0: "The 'reload this page' notice should be hidden after linking."); michael@0: is($("#waiting-notice").hidden, true, michael@0: "The 'waiting for a WebGL context' notice should be visible after linking."); michael@0: is($("#content").hidden, false, michael@0: "The tool's content should not be hidden anymore."); michael@0: michael@0: is(ShadersListView.itemCount, 1, michael@0: "The shaders list contains one entry."); michael@0: is(ShadersListView.selectedItem, ShadersListView.items[0], michael@0: "The shaders list has a correct item selected."); michael@0: is(ShadersListView.selectedIndex, 0, michael@0: "The shaders list has a correct index selected."); michael@0: michael@0: let vsEditor = yield ShadersEditorsView._getEditor("vs"); michael@0: let fsEditor = yield ShadersEditorsView._getEditor("fs"); michael@0: michael@0: is(vsEditor.getText().indexOf("gl_Position"), 170, michael@0: "The vertex shader editor contains the correct text."); michael@0: is(fsEditor.getText().indexOf("gl_FragColor"), 97, michael@0: "The fragment shader editor contains the correct text."); michael@0: michael@0: let navigating = once(target, "will-navigate"); michael@0: let navigated = once(target, "will-navigate"); michael@0: navigate(target, "about:blank"); michael@0: michael@0: yield navigating; michael@0: yield once(panel.panelWin, EVENTS.UI_RESET); michael@0: michael@0: is($("#reload-notice").hidden, true, michael@0: "The 'reload this page' notice should be hidden while navigating."); michael@0: is($("#waiting-notice").hidden, false, michael@0: "The 'waiting for a WebGL context' notice should be visible while navigating."); michael@0: is($("#content").hidden, true, michael@0: "The tool's content should be hidden now that there's no WebGL content."); michael@0: michael@0: is(ShadersListView.itemCount, 0, michael@0: "The shaders list should be empty."); michael@0: is(ShadersListView.selectedItem, null, michael@0: "The shaders list has no correct item."); michael@0: is(ShadersListView.selectedIndex, -1, michael@0: "The shaders list has a negative index."); michael@0: michael@0: yield ShadersEditorsView._getEditor("vs").then(() => { michael@0: ok(false, "The promise for a vertex shader editor should be rejected."); michael@0: }, () => { michael@0: ok(true, "The vertex shader editors wasn't initialized."); michael@0: }); michael@0: michael@0: yield ShadersEditorsView._getEditor("fs").then(() => { michael@0: ok(false, "The promise for a fragment shader editor should be rejected."); michael@0: }, () => { michael@0: ok(true, "The fragment shader editors wasn't initialized."); michael@0: }); michael@0: michael@0: yield navigated; michael@0: michael@0: is($("#reload-notice").hidden, true, michael@0: "The 'reload this page' notice should still be hidden after navigating."); michael@0: is($("#waiting-notice").hidden, false, michael@0: "The 'waiting for a WebGL context' notice should still be visible after navigating."); michael@0: is($("#content").hidden, true, michael@0: "The tool's content should be still hidden since there's no WebGL content."); michael@0: michael@0: yield teardown(panel); michael@0: finish(); michael@0: }