Changeset 202933 in webkit
- Timestamp:
- Jul 7, 2016, 2:28:08 PM (10 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 5 edited
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/inspector/formatting/formatting-javascript-expected.txt (modified) (1 diff)
-
LayoutTests/inspector/formatting/formatting-javascript.html (modified) (1 diff)
-
LayoutTests/inspector/formatting/formatting-json-expected.txt (added)
-
LayoutTests/inspector/formatting/formatting-json.html (added)
-
Source/WebInspectorUI/ChangeLog (modified) (1 diff)
-
Source/WebInspectorUI/UserInterface/Workers/Formatter/FormatterWorker.js (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r202931 r202933 1 2016-07-07 Joseph Pecoraro <pecoraro@apple.com> 2 3 Web Inspector, regression: JS/JSON pretty-printing sporadically broken in STP8 4 https://bugs.webkit.org/show_bug.cgi?id=159511 5 <rdar://problem/27218435> 6 7 Reviewed by Timothy Hatcher. 8 9 * inspector/formatting/formatting-json-expected.txt: Added. 10 * inspector/formatting/formatting-json.html: Added. 11 1 12 2016-07-07 Antti Koivisto <antti@apple.com> 2 13 -
trunk/LayoutTests/inspector/formatting/formatting-javascript-expected.txt
r199838 r202933 1 Test JavaScript formatting tests.1 Test JavaScript formatting. 2 2 3 3 -
trunk/LayoutTests/inspector/formatting/formatting-javascript.html
r199838 r202933 43 43 </head> 44 44 <body onload="runTest()"> 45 <p>Test JavaScript formatting tests.</p>45 <p>Test JavaScript formatting.</p> 46 46 </body> 47 47 </html> -
trunk/Source/WebInspectorUI/ChangeLog
r202932 r202933 1 2016-07-07 Joseph Pecoraro <pecoraro@apple.com> 2 3 Web Inspector, regression: JS/JSON pretty-printing sporadically broken in STP8 4 https://bugs.webkit.org/show_bug.cgi?id=159511 5 <rdar://problem/27218435> 6 7 Reviewed by Timothy Hatcher. 8 9 * UserInterface/Workers/Formatter/FormatterWorker.js: 10 (FormatterWorker.prototype.formatJavaScript): 11 Attempt to format invalid JSON that can be evaluated to an object. 12 1 13 2016-07-07 Timothy Hatcher <timothy@apple.com> 2 14 -
trunk/Source/WebInspectorUI/UserInterface/Workers/Formatter/FormatterWorker.js
r199168 r202933 43 43 formatJavaScript(sourceText, indentString, includeSourceMapData) 44 44 { 45 // Format a JavaScript program. 45 46 let formatter = new EsprimaFormatter(sourceText, indentString); 46 47 if (formatter.success) { … … 57 58 } 58 59 60 // Format valid JSON. 59 61 // The formatter could fail if this was just a JSON string. So try a JSON.parse and stringify. 60 62 // This will produce empty source map data, but it is not code, so it is not as important. … … 66 68 return result; 67 69 } catch (e) {} 70 71 // Format invalid JSON. 72 // Some applications do not use JSON.parse but eval on JSON content. That is more permissive 73 // so try to format invalid JSON. Again no source map data since it is not code. 74 if (/^\s*\{/.test(sourceText)) { 75 let invalidJSONFormatter = new EsprimaFormatter("(" + sourceText + ")", indentString); 76 if (invalidJSONFormatter.success) { 77 let formattedTextWithParens = invalidJSONFormatter.formattedText; 78 let result = {formattedText: formattedTextWithParens.substring(1, formattedTextWithParens.length - 2)}; // Remove "(" and ")\n". 79 if (includeSourceMapData) 80 result.sourceMapData = {mapping: {original: [], formatted: []}, originalLineEndings:[], formattedLineEndings: []}; 81 return result; 82 } 83 } 68 84 69 85 return {formattedText: null};
Note:
See TracChangeset
for help on using the changeset viewer.