browser_dbg_post-page.js 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
  2. /* Any copyright is dedicated to the Public Domain.
  3. * http://creativecommons.org/publicdomain/zero/1.0/ */
  4. /**
  5. * Tests that source contents are invalidated when the target navigates.
  6. */
  7. const TAB_URL = EXAMPLE_URL + "sjs_post-page.sjs";
  8. const FORM = "<form method=\"POST\"><input type=\"submit\"></form>";
  9. const GET_CONTENT = "<script>\"GET\";</script>" + FORM;
  10. const POST_CONTENT = "<script>\"POST\";</script>" + FORM;
  11. add_task(function* () {
  12. let options = {
  13. source: TAB_URL,
  14. line: 1
  15. };
  16. let [tab,, panel] = yield initDebugger(TAB_URL, options);
  17. let win = panel.panelWin;
  18. let editor = win.DebuggerView.editor;
  19. let queries = win.require("./content/queries");
  20. let getState = win.DebuggerController.getState;
  21. let source = queries.getSelectedSource(getState());
  22. is(queries.getSourceCount(getState()), 1,
  23. "There should be one source displayed in the view.");
  24. is(source.url, TAB_URL,
  25. "The correct source is currently selected in the view.");
  26. is(editor.getText(), GET_CONTENT,
  27. "The currently shown source contains bacon. Mmm, delicious!");
  28. // Submit the form and wait for debugger update
  29. let onSourceUpdated = waitForSourceShown(panel, TAB_URL);
  30. yield ContentTask.spawn(tab.linkedBrowser, null, function () {
  31. content.document.querySelector("input[type=\"submit\"]").click();
  32. });
  33. yield onSourceUpdated;
  34. // Verify that the source updates to the POST page content
  35. source = queries.getSelectedSource(getState());
  36. is(queries.getSourceCount(getState()), 1,
  37. "There should be one source displayed in the view.");
  38. is(source.url, TAB_URL,
  39. "The correct source is currently selected in the view.");
  40. is(editor.getText(), POST_CONTENT,
  41. "The currently shown source contains bacon. Mmm, delicious!");
  42. yield closeDebuggerAndFinish(panel);
  43. });