Bug 1284843 - Reps: don't add quotes around strings. r=linclark
MozReview-Commit-ID: 7zP8hAUqalR
--- 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>