Commit 8e8ac4d1 authored by Tom Tromey's avatar Tom Tromey
Browse files

Bug 1345533 - report source map errors to the web console; r=bgrins

MozReview-Commit-ID: 7gynPYFxyIv

--HG--
extra : rebase_source : 8cfe3e3ec53beeeed8f1707d6d1e80e34f53e30f
parent dd8e682c
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -551,7 +551,12 @@ Toolbox.prototype = {
      get: (target, name) => {
        if (name === "getOriginalURLs") {
          return (urlInfo) => {
            return target.getOriginalURLs(urlInfo).catch(console.error);
            return target.getOriginalURLs(urlInfo)
              .catch(text => {
                let message = L10N.getFormatStr("toolbox.sourceMapFailure",
                                                text, urlInfo.url, urlInfo.sourceMapURL);
                this.target.logErrorInPage(message, "source map");
              });
          };
        }
        return target[name];
+7 −0
Original line number Diff line number Diff line
@@ -177,3 +177,10 @@ toolbox.closebutton.tooltip=Close Developer Tools
# LOCALIZATION NOTE (toolbox.allToolsButton.tooltip): This is the tooltip for the
# "all tools" button displayed when some tools are hidden by overflow of the toolbar.
toolbox.allToolsButton.tooltip=Select another tool

# LOCALIZATION NOTE (toolbox.sourceMapFailure): This is shown in the web console
# when there is a failure to fetch or parse a source map.
# The text of the error: %1$S
# The URL that caused DevTools to try to fetch a source map: %2$S
# The URL of the source map itself: %3$S
toolbox.sourceMapFailure=Source map error: %1$S\nResource URL: %2$S\nSource Map URL: %3$S
+5 −0
Original line number Diff line number Diff line
@@ -15,6 +15,10 @@ support-files =
  test-location-styleeditor-link-2.css
  test-location-styleeditor-link.html
  test-network-request.html
  test-sourcemap-error-01.html
  test-sourcemap-error-02.html
  test-sourcemap-error-01.js
  test-sourcemap-error-02.js
  test-stacktrace-location-debugger-link.html
  !/devtools/client/framework/test/shared-head.js

@@ -48,6 +52,7 @@ skip-if = (os == 'linux' && bits == 32 && debug) # bug 1328915, disable linux32
[browser_webconsole_object_inspector.js]
[browser_webconsole_observer_notifications.js]
[browser_webconsole_shows_reqs_in_netmonitor.js]
[browser_webconsole_sourcemap_error.js]
[browser_webconsole_stacktrace_location_debugger_link.js]
[browser_webconsole_stacktrace_location_scratchpad_link.js]
[browser_webconsole_string.js]
+22 −0
Original line number Diff line number Diff line
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* vim: set ft=javascript ts=2 et sw=2 tw=80: */
/* Any copyright is dedicated to the Public Domain.
 * http://creativecommons.org/publicdomain/zero/1.0/ */

"use strict";

// Test that a missing source map is reported.

const BASE = "http://example.com/browser/devtools/client/webconsole/new-console-output/test/mochitest/";

add_task(async function () {
  for (let test of ["test-sourcemap-error-01.html", "test-sourcemap-error-02.html"]) {
    const hud = await openNewTabAndConsole(BASE + test);

    const node = await waitFor(() => findMessage(hud, "here"));
    ok(node, "logged text is displayed in web console");

    const node2 = await waitFor(() => findMessage(hud, "Source map error"));
    ok(node2, "source map error is displayed in web console");
  }
});
+13 −0
Original line number Diff line number Diff line
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <title>Test that a missing source map is reported to the console</title>
<!-- Any copyright is dedicated to the Public Domain.
     http://creativecommons.org/publicdomain/zero/1.0/ -->
    <script type="text/javascript" src="test-sourcemap-error-01.js"></script>
  </head>
  <body>
    <p>Web Console test for source map failure.</p>
  </body>
</html>
Loading