Bug 1284843 - Reps: Don't add quotes around strings. r=linclark
authorHemanth Kumar Veeranki <hems.india1997@gmail.com>
Wed, 03 Aug 2016 10:49:00 -0400
changeset 400780 62dd82f4b4c09709fbe7a6ce3345fe35c1755ba2
parent 400737 3e4803eb9a5ca755a8881bf599f05f8430ffb343
child 400781 28ded847d319a75a1ea5e651447dffa2103914b2
push id26284
push usermwein@mozilla.com
push dateMon, 15 Aug 2016 20:48:20 +0000
reviewerslinclark
bugs1284843
milestone51.0a1
Bug 1284843 - Reps: Don't add quotes around strings. r=linclark
devtools/client/shared/components/reps/string.js
devtools/client/shared/components/test/mochitest/test_reps_string.html
--- a/devtools/client/shared/components/reps/string.js
+++ b/devtools/client/shared/components/reps/string.js
@@ -30,18 +30,21 @@ define(function (require, exports, modul
             "\"" + text + "\""
           )
         );
       }
 
       let croppedString = this.props.cropLimit ?
         cropMultipleLines(text, this.props.cropLimit) : cropMultipleLines(text);
 
+      let formattedString = this.props.omitQuotes ?
+        croppedString : "\"" + croppedString + "\"";
+
       return (
-        span({className: "objectBox objectBox-string"}, "\"" + croppedString + "\""
+        span({className: "objectBox objectBox-string"}, formattedString
         )
       );
     },
   });
 
   function supportsObject(object, type) {
     return (type == "string");
   }
--- a/devtools/client/shared/components/test/mochitest/test_reps_string.html
+++ b/devtools/client/shared/components/test/mochitest/test_reps_string.html
@@ -22,16 +22,17 @@ window.onload = Task.async(function* () 
     // Test that correct rep is chosen
     const renderedRep = shallowRenderComponent(Rep, { object: getGripStub("testMultiline") });
     is(renderedRep.type, StringRep.rep, `Rep correctly selects ${StringRep.rep.displayName}`);
 
     // Test rendering
     yield testMultiline();
     yield testMultilineOpen();
     yield testMultilineLimit();
+    yield testOmitQuotes();
   } catch(e) {
     ok(false, "Got an error: " + DevToolsUtils.safeErrorString(e));
   } finally {
     SimpleTest.finish();
   }
 
   function testMultiline() {
     const renderedComponent = renderComponent(StringRep.rep, { object: getGripStub("testMultiline") });
@@ -43,19 +44,27 @@ window.onload = Task.async(function* () 
     is(renderedComponent.textContent, "\"aaaaaaaaaa…cccccccc\\n\"", "String rep has expected text content for multiline string with specified number of characters");
   }
 
   function testMultilineOpen() {
     const renderedComponent = renderComponent(StringRep.rep, { object: getGripStub("testMultiline"), member: {open: true} });
     is(renderedComponent.textContent, "\"aaaaaaaaaaaaaaaaaaaaa\nbbbbbbbbbbbbbbbbbbb\ncccccccccccccccc\n\"", "String rep has expected text content for multiline string when open");
   }
 
+  function testOmitQuotes(){
+     const renderedComponent = renderComponent(StringRep.rep, { object: getGripStub("testOmitQuotes"), omitQuotes: true });
+     is(renderedComponent.textContent, "abc","String rep has expected to omit quotes");
+  }
+
   function getGripStub(name) {
     switch (name) {
       case "testMultiline":
-        return "aaaaaaaaaaaaaaaaaaaaa\nbbbbbbbbbbbbbbbbbbb\ncccccccccccccccc\n";
+      	 return "aaaaaaaaaaaaaaaaaaaaa\nbbbbbbbbbbbbbbbbbbb\ncccccccccccccccc\n";
+	 break;
+      case "testOmitQuotes":
+	 return "abc";
     }
   }
 });
 </script>
 </pre>
 </body>
 </html>