browser_dbg-pretty-print-line-breaks.js (1323B)
1 /* This Source Code Form is subject to the terms of the Mozilla Public 2 * License, v. 2.0. If a copy of the MPL was not distributed with this 3 * file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */ 4 5 // Tests pretty-printing of HTML file with windows line-breaks (\r\n). 6 7 "use strict"; 8 9 requestLongerTimeout(2); 10 11 const httpServer = createTestHTTPServer(); 12 13 httpServer.registerPathHandler("/doc_line_breaks.html", (request, response) => { 14 response.setStatusLine(request.httpVersion, 200, "OK"); 15 response.setHeader("Content-Type", "text/html"); 16 response.write( 17 `TEST with line breaks\r\n<script>(function(){\r\n})('test')</script>` 18 ); 19 }); 20 21 const TEST_URL = `http://localhost:${httpServer.identity.primaryPort}/doc_line_breaks.html`; 22 23 add_task(async function () { 24 const dbg = await initDebuggerWithAbsoluteURL(TEST_URL); 25 26 await selectSource(dbg, "doc_line_breaks.html"); 27 await togglePrettyPrint(dbg); 28 29 const prettyPrintedSource = findSourceContent( 30 dbg, 31 "doc_line_breaks.html:formatted" 32 ); 33 ok(prettyPrintedSource, "Pretty-printed source exists"); 34 35 info("Check that the HTML file was pretty-printed as expected"); 36 is( 37 prettyPrintedSource.value, 38 "TEST with line breaks\n<script>\n(function () {\n}) ('test')\n</script>", 39 "HTML file is pretty printed as expected" 40 ); 41 });