Bug 1416916 - Syntax highlight .es# files r=jlast
authorDavid Walsh <dwalsh@mozilla.com>
Mon, 10 Jun 2019 15:57:22 +0000
changeset 478096 bac01d6670ed1e40384e919c3e24f169ce8dd2bb
parent 478095 e2f99cd199eb53b367fed2c1151c297b59491760
child 478097 bd7b19350b5a63d77f42c433e54da0e1e12f39bf
push id113405
push usernerli@mozilla.com
push dateTue, 11 Jun 2019 03:22:35 +0000
treeherdermozilla-inbound@e3bbbcf873c2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjlast
bugs1416916
milestone69.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 1416916 - Syntax highlight .es# files r=jlast Differential Revision: https://phabricator.services.mozilla.com/D34191
devtools/client/debugger/src/utils/source.js
devtools/client/debugger/src/utils/tests/source.spec.js
--- a/devtools/client/debugger/src/utils/source.js
+++ b/devtools/client/debugger/src/utils/source.js
@@ -362,19 +362,19 @@ export function getMode(
   if (url) {
     const result = languageMimeMap.find(({ ext }) => url.endsWith(ext));
 
     if (result !== undefined) {
       return { name: result.mode };
     }
   }
 
-  // if the url ends with .marko we set the name to Javascript so
-  // syntax highlighting works for marko too
-  if (url && url.match(/\.marko$/i)) {
+  // if the url ends with .marko or .es6 we set the name to Javascript so
+  // syntax highlighting works for these file extensions too
+  if (url && url.match(/\.marko|\.es6$/i)) {
     return { name: "javascript" };
   }
 
   // Use HTML mode for files in which the first non whitespace
   // character is `<` regardless of extension.
   const isHTMLLike = text.match(/^\s*</);
   if (!contentType) {
     if (isHTMLLike) {
--- a/devtools/client/debugger/src/utils/tests/source.spec.js
+++ b/devtools/client/debugger/src/utils/tests/source.spec.js
@@ -456,16 +456,26 @@ describe("sources", () => {
       const { source, content } = makeMockSourceAndContent(
         "http://localhost.com:7999/increment/sometestfile.marko",
         undefined,
         "does not matter",
         "function foo(){}"
       );
       expect(getMode(source, content)).toEqual({ name: "javascript" });
     });
+
+    it("es6", () => {
+      const { source, content } = makeMockSourceAndContent(
+        "http://localhost.com:7999/increment/sometestfile.es6",
+        undefined,
+        "does not matter",
+        "function foo(){}"
+      );
+      expect(getMode(source, content)).toEqual({ name: "javascript" });
+    });
   });
 
   describe("getSourceLineCount", () => {
     it("should give us the amount bytes for wasm source", () => {
       const { content } = makeMockWasmSourceWithContent({
         binary: "\x00asm\x01\x00\x00\x00",
       });
       expect(getSourceLineCount(content.value)).toEqual(8);