Backed out changeset 0c0dfeb3692a (bug 1395313) for maybe causing browser_bug451286.js failures a=backout CLOSED TREE
authorWes Kocher <wkocher@mozilla.com>
Tue, 12 Sep 2017 15:24:14 -0700
changeset 429844 f30873510385aeaaa810fda203edb77e74a007d2
parent 429843 77a07c56db0dab0d8dc7ece3c6466746f80e7076
child 429845 9a676cb6f09a4d0b29cc8b0072acc035c2082224
push id7761
push userjlund@mozilla.com
push dateFri, 15 Sep 2017 00:19:52 +0000
treeherdermozilla-beta@c38455951db4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbackout
bugs1395313, 451286
milestone57.0a1
backs out0c0dfeb3692a60f3e8f62ee2ee0235fcb5607512
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Backed out changeset 0c0dfeb3692a (bug 1395313) for maybe causing browser_bug451286.js failures a=backout CLOSED TREE MozReview-Commit-ID: 5WybzB8cgmJ
devtools/client/jsonview/json-viewer.js
devtools/client/jsonview/test/browser_jsonview_utf8.js
--- a/devtools/client/jsonview/json-viewer.js
+++ b/devtools/client/jsonview/json-viewer.js
@@ -8,38 +8,35 @@
 
 define(function (require, exports, module) {
   const { render } = require("devtools/client/shared/vendor/react-dom");
   const { createFactories } = require("devtools/client/shared/react-utils");
   const { MainTabbedArea } = createFactories(require("./components/main-tabbed-area"));
 
   const json = document.getElementById("json");
 
+  let jsonData;
   let prettyURL;
 
+  try {
+    jsonData = JSON.parse(json.textContent);
+  } catch (err) {
+    jsonData = err;
+  }
+
   // Application state object.
   let input = {
     jsonText: json.textContent,
     jsonPretty: null,
+    json: jsonData,
     headers: JSONView.headers,
     tabActive: 0,
     prettified: false
   };
 
-  // Remove BOM.
-  if (input.jsonText.startsWith("\ufeff")) {
-    input.jsonText = input.jsonText.slice(1);
-  }
-
-  try {
-    input.json = JSON.parse(input.jsonText);
-  } catch (err) {
-    input.json = err;
-  }
-
   json.remove();
 
   /**
    * Application actions/commands. This list implements all commands
    * available for the JSON viewer.
    */
   input.actions = {
     onCopyJson: function () {
@@ -57,25 +54,25 @@ define(function (require, exports, modul
       dispatchEvent("copy-headers", input.headers);
     },
 
     onSearch: function (value) {
       theApp.setState({searchFilter: value});
     },
 
     onPrettify: function (data) {
-      if (input.json instanceof Error) {
+      if (jsonData instanceof Error) {
         // Cannot prettify invalid JSON
         return;
       }
       if (input.prettified) {
         theApp.setState({jsonText: input.jsonText});
       } else {
         if (!input.jsonPretty) {
-          input.jsonPretty = JSON.stringify(input.json, null, "  ");
+          input.jsonPretty = JSON.stringify(jsonData, null, "  ");
         }
         theApp.setState({jsonText: input.jsonPretty});
       }
 
       input.prettified = !input.prettified;
     },
   };
 
--- a/devtools/client/jsonview/test/browser_jsonview_utf8.js
+++ b/devtools/client/jsonview/test/browser_jsonview_utf8.js
@@ -1,39 +1,27 @@
 /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
 /* vim: set ts=2 et sw=2 tw=80: */
 /* Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/publicdomain/zero/1.0/ */
 
 "use strict";
 
-// In UTF-8 this is a heavy black heart.
-const encodedChar = "%E2%9D%A4";
-
 add_task(function* () {
   info("Test UTF-8 JSON started");
 
-  info("Test 1: UTF-8 is used by default");
-  yield testUrl("data:application/json,[\"" + encodedChar + "\"]");
-
-  info("Test 2: The charset parameter is ignored");
-  yield testUrl("data:application/json;charset=ANSI,[\"" + encodedChar + "\"]");
+  const encodedChar = "%E2%9D%A4"; // In UTF-8 this is a heavy black heart
+  const TEST_JSON_URL = "data:application/json;charset=ANSI,[\"" + encodedChar + "\"]";
 
-  info("Test 3: The UTF-8 BOM is tolerated.");
-  const bom = "%EF%BB%BF";
-  yield testUrl("data:application/json," + bom + "[\"" + encodedChar + "\"]");
-});
-
-function* testUrl(TEST_JSON_URL) {
   yield addJsonViewTab(TEST_JSON_URL);
 
   let countBefore = yield getElementCount(".jsonPanelBox .treeTable .treeRow");
   is(countBefore, 1, "There must be one row.");
 
   let objectCellCount = yield getElementCount(
     ".jsonPanelBox .treeTable .stringCell");
   is(objectCellCount, 1, "There must be one string cell.");
 
   let objectCellText = yield getElementText(
     ".jsonPanelBox .treeTable .stringCell");
   is(objectCellText, JSON.stringify(decodeURIComponent(encodedChar)),
      "The source has been parsed as UTF-8, ignoring the charset parameter.");
-}
+});