browser_dbg-features-breakable-lines.js (2856B)
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 "use strict"; 6 7 const testServer = createVersionizedHttpTestServer( 8 "../examples/sourcemaps-reload-uncompressed" 9 ); 10 const TEST_URL = testServer.urlFor("index.html"); 11 12 requestLongerTimeout(4); 13 14 // Assert the behavior of the gutter that grays out non-breakable lines 15 add_task(async function testBreakableLinesOverReloads() { 16 const dbg = await initDebuggerWithAbsoluteURL( 17 TEST_URL, 18 "index.html", 19 "script.js", 20 "original.js" 21 ); 22 23 info("Assert breakable lines of the first html page load"); 24 await assertBreakableLines(dbg, "index.html", 85, [ 25 ...getRange(16, 17), 26 21, 27 ...getRange(24, 25), 28 30, 29 36, 30 39, 31 ...getRange(41, 43), 32 ]); 33 34 info("Assert breakable lines of the first original source file, original.js"); 35 // The length of original.js is longer than the test file 36 // because the sourcemap replaces the content of the original file 37 // and appends a few lines with a "WEBPACK FOOTER" comment 38 // All the appended lines are empty lines or comments, so none of them are breakable. 39 await assertBreakableLines(dbg, "original.js", 15, [ 40 ...getRange(1, 3), 41 5, 42 ...getRange(8, 10), 43 ]); 44 45 info("Assert breakable lines of the simple first load of script.js"); 46 await assertBreakableLines(dbg, "script.js", 9, [1, 5, 7, 8, 9]); 47 48 info("Assert breakable lines of the first iframe page load"); 49 await assertBreakableLines(dbg, "iframe.html", 30, [ 50 ...getRange(16, 17), 51 ...getRange(22, 23), 52 ]); 53 54 info( 55 "Reload the page, wait for sources and assert that breakable lines get updated" 56 ); 57 testServer.switchToNextVersion(); 58 await reload(dbg, "index.html", "script.js", "original.js", "iframe.html"); 59 60 // Wait for previously selected source to be re-selected after reload 61 // otherwise it may overlap with the next source selected by assertBreakableLines. 62 await waitForSelectedSource(dbg, "iframe.html"); 63 64 info("Assert breakable lines of the more complex second load of script.js"); 65 await assertBreakableLines(dbg, "script.js", 23, [2, ...getRange(13, 23)]); 66 67 info("Assert breakable lines of the second html page load"); 68 await assertBreakableLines(dbg, "index.html", 33, [25, 27]); 69 70 info("Assert breakable lines of the second orignal file"); 71 // See first assertion about original.js, 72 // the size of original.js doesn't match the size of the test file 73 await assertBreakableLines(dbg, "original.js", 18, [ 74 ...getRange(1, 3), 75 ...getRange(8, 11), 76 13, 77 ]); 78 79 info("Assert breakable lines of the second iframe page load"); 80 await selectSource(dbg, "iframe.html"); 81 await assertBreakableLines(dbg, "iframe.html", 30, [15, 17, 21, 23]); 82 });