diff --git a/browser/devtools/netmonitor/netmonitor-view.js b/browser/devtools/netmonitor/netmonitor-view.js index 17fde350935..b2a2aeb7f5a 100644 --- a/browser/devtools/netmonitor/netmonitor-view.js +++ b/browser/devtools/netmonitor/netmonitor-view.js @@ -1048,9 +1048,16 @@ create({ constructor: NetworkDetailsView, proto: MenuContainer.prototype }, { // Handle json. if (mimeType.contains("/json")) { $("#response-content-json-box").hidden = false; - let jsonScope = this._json.addScope("JSON"); - let sanitizedText = aString.replace(/^[a-zA-Z0-9_$]+\(|\)$/g, ""); // JSONP - jsonScope.addVar().populate(JSON.parse(sanitizedText), { expanded: true }); + let jsonpRegex = /^[a-zA-Z0-9_$]+\(|\)$/g; // JSONP with callback. + let sanitizedJSON = aString.replace(jsonpRegex, ""); + let callbackPadding = aString.match(jsonpRegex); + + let jsonScopeName = callbackPadding + ? L10N.getFormatStr("jsonpScopeName", callbackPadding[0].slice(0, -1)) + : L10N.getStr("jsonScopeName"); + + let jsonScope = this._json.addScope(jsonScopeName); + jsonScope.addVar().populate(JSON.parse(sanitizedJSON), { expanded: true }); jsonScope.expanded = true; } // Handle images. diff --git a/browser/devtools/netmonitor/test/browser_net_content-type.js b/browser/devtools/netmonitor/test/browser_net_content-type.js index 9230541a2fd..82eb286ce95 100644 --- a/browser/devtools/netmonitor/test/browser_net_content-type.js +++ b/browser/devtools/netmonitor/test/browser_net_content-type.js @@ -166,7 +166,8 @@ function test() { let jsonScope = tabpanel.querySelectorAll(".variables-view-scope")[0]; is(jsonScope.querySelector(".name").getAttribute("value"), - "JSON", "The json scope doesn't have the correct title."); + L10N.getStr("jsonScopeName"), + "The json scope doesn't have the correct title."); is(jsonScope.querySelectorAll(".variables-view-property .name")[0].getAttribute("value"), "greeting", "The first json property name was incorrect."); diff --git a/browser/devtools/netmonitor/test/browser_net_json-long.js b/browser/devtools/netmonitor/test/browser_net_json-long.js index 0a38a014fa4..613a3a1a978 100644 --- a/browser/devtools/netmonitor/test/browser_net_json-long.js +++ b/browser/devtools/netmonitor/test/browser_net_json-long.js @@ -2,7 +2,7 @@ http://creativecommons.org/publicdomain/zero/1.0/ */ /** - * Tests if JSONP responses are handled correctly. + * Tests if very long JSON responses are handled correctly. */ function test() { @@ -70,7 +70,8 @@ function test() { let values = ".variables-view-property .value"; is(jsonScope.querySelector(".name").getAttribute("value"), - "JSON", "The json scope doesn't have the correct title."); + L10N.getStr("jsonScopeName"), + "The json scope doesn't have the correct title."); is(jsonScope.querySelectorAll(names)[0].getAttribute("value"), "0", "The first json property name was incorrect."); diff --git a/browser/devtools/netmonitor/test/browser_net_jsonp.js b/browser/devtools/netmonitor/test/browser_net_jsonp.js index 727bcf4e946..b3f8cd8d547 100644 --- a/browser/devtools/netmonitor/test/browser_net_jsonp.js +++ b/browser/devtools/netmonitor/test/browser_net_jsonp.js @@ -62,7 +62,8 @@ function test() { let jsonScope = tabpanel.querySelectorAll(".variables-view-scope")[0]; is(jsonScope.querySelector(".name").getAttribute("value"), - "JSON", "The json scope doesn't have the correct title."); + L10N.getFormatStr("jsonpScopeName", "$_0123Fun"), + "The json scope doesn't have the correct title."); is(jsonScope.querySelectorAll(".variables-view-property .name")[0].getAttribute("value"), "greeting", "The first json property name was incorrect."); diff --git a/browser/locales/en-US/chrome/browser/devtools/netmonitor.properties b/browser/locales/en-US/chrome/browser/devtools/netmonitor.properties index bd51a26a0d8..b3bddaf8a00 100644 --- a/browser/locales/en-US/chrome/browser/devtools/netmonitor.properties +++ b/browser/locales/en-US/chrome/browser/devtools/netmonitor.properties @@ -89,6 +89,14 @@ responseCookies=Response cookies # in the response tab of the network details pane for the JSON filtering input. jsonFilterText=Filter properties +# LOCALIZATION NOTE (jsonScopeName): This is the text displayed +# in the response tab of the network details pane for a JSON scope. +jsonScopeName=JSON + +# LOCALIZATION NOTE (jsonpScopeName): This is the text displayed +# in the response tab of the network details pane for a JSONP scope. +jsonpScopeName=JSONP → callback %S() + # LOCALIZATION NOTE (networkMenu.size): This is the label displayed # in the network menu specifying the size of a request (in kilobytes). networkMenu.sizeKB=%S KB