Bug 1419416 - Remove UTF-16 support in JSON Viewer. r=tromey
authorOriol Brufau <oriol-bugzilla@hotmail.com>
Tue, 21 Nov 2017 15:09:14 +0100
changeset 393094 96de9eeb020a9ca1109b2844e03e08f48801ef0b
parent 393093 77a5d063a83f58ca55fd88a466e848c1449d5c91
child 393095 7cc1270bf794f1e2354a93fd8d508f121f959bcf
push id55849
push userryanvm@gmail.com
push dateWed, 22 Nov 2017 17:51:06 +0000
treeherderautoland@96de9eeb020a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstromey
bugs1419416
milestone59.0a1
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
Bug 1419416 - Remove UTF-16 support in JSON Viewer. r=tromey MozReview-Commit-ID: GIE3Q5j3wZm
devtools/client/jsonview/converter-child.js
devtools/client/jsonview/test/browser.ini
--- a/devtools/client/jsonview/converter-child.js
+++ b/devtools/client/jsonview/converter-child.js
@@ -19,17 +19,17 @@ loader.lazyGetter(this, "debug", functio
 
 const childProcessMessageManager =
   Cc["@mozilla.org/childprocessmessagemanager;1"]
     .getService(Ci.nsISyncMessageSender);
 const BinaryInput = CC("@mozilla.org/binaryinputstream;1",
                        "nsIBinaryInputStream", "setInputStream");
 const BufferStream = CC("@mozilla.org/io/arraybuffer-input-stream;1",
                        "nsIArrayBufferInputStream", "setData");
-const encodingLength = 2;
+const encodingLength = 0;
 
 // Localization
 loader.lazyGetter(this, "jsonViewStrings", () => {
   return Services.strings.createBundle(
     "chrome://devtools/locale/jsonview.properties");
 });
 
 /**
@@ -140,32 +140,19 @@ Converter.prototype = {
     this.listener.onStopRequest(request, context, statusCode);
     this.listener = null;
     this.decoder = null;
     this.data = null;
   },
 
   // Determines the encoding of the response.
   determineEncoding: function (request, context, flush = false) {
-    // Determine the encoding using the bytes in encodingArray, defaulting to UTF-8.
-    // An initial byte order mark character (U+FEFF) does the trick.
-    // If there is no BOM, since the first character of valid JSON will be ASCII,
-    // the pattern of nulls in the first two bytes can be used instead.
-    //  - UTF-16BE:  00 xx  or  FE FF
-    //  - UTF-16LE:  xx 00  or  FF FE
-    //  - UTF-8:  anything else.
+    // Always use UTF-8
     let encoding = "UTF-8";
     let bytes = this.encodingArray;
-    if (bytes.length >= 2) {
-      if (!bytes[0] && bytes[1] || bytes[0] == 0xFE && bytes[1] == 0xFF) {
-        encoding = "UTF-16BE";
-      } else if (bytes[0] && !bytes[1] || bytes[0] == 0xFF && bytes[1] == 0xFE) {
-        encoding = "UTF-16LE";
-      }
-    }
 
     // Create a decoder for that encoding.
     this.decoder = new TextDecoder(encoding);
     this.data.encoding = encoding;
 
     // Decode and insert the bytes in encodingArray, and remove it.
     let buffer = new Uint8Array(bytes).buffer;
     this.decodeAndInsertBuffer(request, context, buffer, flush);
--- a/devtools/client/jsonview/test/browser.ini
+++ b/devtools/client/jsonview/test/browser.ini
@@ -32,16 +32,17 @@ skip-if = (os == 'linux' && bits == 32 &
 subsuite = clipboard
 skip-if = (os == 'linux' && bits == 32 && debug) # bug 1328915, disable linux32 debug devtools for timeouts
 [browser_jsonview_copy_rawdata.js]
 subsuite = clipboard
 skip-if = (os == 'linux' && bits == 32 && debug) # bug 1328915, disable linux32 debug devtools for timeouts
 [browser_jsonview_csp_json.js]
 [browser_jsonview_empty_object.js]
 [browser_jsonview_encoding.js]
+skip-if = true # bug 1419416, remove UTF-16 support
 [browser_jsonview_filter.js]
 [browser_jsonview_invalid_json.js]
 [browser_jsonview_manifest.js]
 [browser_jsonview_nojs.js]
 [browser_jsonview_nul.js]
 [browser_jsonview_object-type.js]
 [browser_jsonview_row_selection.js]
 [browser_jsonview_save_json.js]