text/plain or text/html responses having quoted text get parsed by JSON.parse() which disappears on hover
Categories
(DevTools :: Netmonitor, defect, P3)
Tracking
(Not tracked)
People
(Reporter: hemakshis, Unassigned)
References
(Blocks 1 open bug)
Details
User Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36
Steps to reproduce:
- Open Netmonitor
- Visit page https://bugzilla-tests.glitch.me/bugs/quotedtext
- Click on both the buttons
- Go to Response Panel
- Notice both the responses have the "JSON" view with the response text, which disappears on hover
Any text with quotes get parsed by JSON (https://searchfox.org/mozilla-central/source/devtools/client/netmonitor/src/components/ResponsePanel.js#121)
Actual results:
The response text gets displayed beside the JSON view header which disappears on hover.
Expected results:
I don't know if it is expected to be displayed in JSON tree (because it is a valid JSON) but it should definitely not be displayed beside the heading and hover thing is definitely a bug.
Comment 1•6 years ago
|
||
I can reproduce this, thanks for the report!
Honza
Reporter | ||
Comment 2•6 years ago
|
||
Hi @honza,
Can you please tell if it is expected to show such responses in the JSON tree? Because JSON.parse("\"anytext\"");
actually evaluates to a correct JSON value.
But what if the user actually intended to pass a text/plain or text/html response?
Comment 3•6 years ago
|
||
(In reply to Hemakshi Sachdev [:hemakshis] from comment #2)
Can you please tell if it is expected to show such responses in the JSON tree? Because
JSON.parse("\"anytext\"");
actually evaluates to a correct JSON value.
I think that we should display the text inside the section - not next to (and within) the section title
But what if the user actually intended to pass a text/plain or text/html response?
Good point. I think that if the response is plain text we could display the JSON section only if the contentType is JSON.
Here is a link to the code base that does such JSON contentType check
https://searchfox.org/mozilla-central/rev/201450283cddc9e409cec707acb65ba6cf6037b1/devtools/client/netmonitor/src/components/ResponsePanel.js#134
Honza
Reporter | ||
Comment 4•6 years ago
|
||
Hi @Honza,
An update on the issue. JSON correctly parses for the following two types of responses and for them we see the hover defect for them:-
JSON.parse('"Hi"');
OR JSON.parse("\"Hi\"");
, returns a string Hi
JSON.parse('true');
OR JSON.parse("true");
returns a boolean true
Now, here we can check that if the json
is of type string or boolean and then we will also check if the contentType is plain/text or html/text and if so mark json
as null.
What do you think?
Comment 5•6 years ago
|
||
Thanks for the update!
My comments:
- I think that we should always display the
JSON
section if the response is using JSON content type. - JSON data should always be rendered in the content of the JSON section
- In other cases, we shouldn't display the JSON section for primitive values (just like you wrote), but we can if the response is actually parsable JSON (it might be useful in cases where the server isn't using the right content type for JSON responses)
- We should also check the Params tab - it should behave the same, but it should be probably a follow up.
Does that make sense?
Honza
Updated•5 years ago
|
Updated•2 years ago
|
Description
•