browser_webconsole_view_source.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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. // Tests that source URLs in the Web Console can be clicked to display the
  5. // standard View Source window. As JS exceptions and console.log() messages always
  6. // have their locations opened in Debugger, we need to test a security message in
  7. // order to have it opened in the standard View Source window.
  8. "use strict";
  9. const TEST_URI = "https://example.com/browser/devtools/client/webconsole/" +
  10. "test/test-mixedcontent-securityerrors.html";
  11. add_task(function* () {
  12. yield actuallyTest();
  13. });
  14. add_task(function* () {
  15. Services.prefs.setBoolPref("devtools.debugger.new-debugger-frontend", false);
  16. yield actuallyTest();
  17. Services.prefs.clearUserPref("devtools.debugger.new-debugger-frontend");
  18. });
  19. var actuallyTest = Task.async(function*() {
  20. yield loadTab(TEST_URI);
  21. let hud = yield openConsole(null);
  22. info("console opened");
  23. let [result] = yield waitForMessages({
  24. webconsole: hud,
  25. messages: [{
  26. text: "Blocked loading mixed active content",
  27. category: CATEGORY_SECURITY,
  28. severity: SEVERITY_ERROR,
  29. }],
  30. });
  31. let msg = [...result.matched][0];
  32. ok(msg, "error message");
  33. let locationNode = msg.querySelector(".message-location .frame-link-filename");
  34. ok(locationNode, "location node");
  35. let onTabOpen = waitForTab();
  36. EventUtils.sendMouseEvent({ type: "click" }, locationNode);
  37. let tab = yield onTabOpen;
  38. ok(true, "the view source tab was opened in response to clicking the location node");
  39. gBrowser.removeTab(tab);
  40. });