browser_se_navigation.js 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /* Any copyright is dedicated to the Public Domain.
  2. http://creativecommons.org/publicdomain/zero/1.0/ */
  3. /**
  4. * Tests target navigations are handled correctly in the UI.
  5. */
  6. function* ifWebGLSupported() {
  7. let { target, panel } = yield initShaderEditor(SIMPLE_CANVAS_URL);
  8. let { gFront, $, EVENTS, ShadersListView, ShadersEditorsView } = panel.panelWin;
  9. reload(target);
  10. yield promise.all([
  11. once(gFront, "program-linked"),
  12. once(panel.panelWin, EVENTS.SOURCES_SHOWN)
  13. ]);
  14. is($("#reload-notice").hidden, true,
  15. "The 'reload this page' notice should be hidden after linking.");
  16. is($("#waiting-notice").hidden, true,
  17. "The 'waiting for a WebGL context' notice should be visible after linking.");
  18. is($("#content").hidden, false,
  19. "The tool's content should not be hidden anymore.");
  20. is(ShadersListView.itemCount, 1,
  21. "The shaders list contains one entry.");
  22. is(ShadersListView.selectedItem, ShadersListView.items[0],
  23. "The shaders list has a correct item selected.");
  24. is(ShadersListView.selectedIndex, 0,
  25. "The shaders list has a correct index selected.");
  26. let vsEditor = yield ShadersEditorsView._getEditor("vs");
  27. let fsEditor = yield ShadersEditorsView._getEditor("fs");
  28. is(vsEditor.getText().indexOf("gl_Position"), 170,
  29. "The vertex shader editor contains the correct text.");
  30. is(fsEditor.getText().indexOf("gl_FragColor"), 97,
  31. "The fragment shader editor contains the correct text.");
  32. let navigating = once(target, "will-navigate");
  33. let navigated = once(target, "will-navigate");
  34. navigate(target, "about:blank");
  35. yield promise.all([navigating, once(panel.panelWin, EVENTS.UI_RESET) ]);
  36. is($("#reload-notice").hidden, true,
  37. "The 'reload this page' notice should be hidden while navigating.");
  38. is($("#waiting-notice").hidden, false,
  39. "The 'waiting for a WebGL context' notice should be visible while navigating.");
  40. is($("#content").hidden, true,
  41. "The tool's content should be hidden now that there's no WebGL content.");
  42. is(ShadersListView.itemCount, 0,
  43. "The shaders list should be empty.");
  44. is(ShadersListView.selectedItem, null,
  45. "The shaders list has no correct item.");
  46. is(ShadersListView.selectedIndex, -1,
  47. "The shaders list has a negative index.");
  48. yield navigated;
  49. is($("#reload-notice").hidden, true,
  50. "The 'reload this page' notice should still be hidden after navigating.");
  51. is($("#waiting-notice").hidden, false,
  52. "The 'waiting for a WebGL context' notice should still be visible after navigating.");
  53. is($("#content").hidden, true,
  54. "The tool's content should be still hidden since there's no WebGL content.");
  55. yield teardown(panel);
  56. finish();
  57. }