browser_dbg-no-duplicate-breakpoints-on-frame-reload.js (2727B)
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 // This tests makes sure that on reload of a remote iframe, there 6 // are no duplicated breakpoints. The test case relates to a specific 7 // issue in Bug 1728587 8 "use strict"; 9 10 add_task(async function () { 11 const dbg = await initDebugger( 12 "doc_dbg-fission-frame-sources.html", 13 "simple2.js" 14 ); 15 16 info( 17 "Open a tab for a source in the top document to assert it doesn't disappear" 18 ); 19 await selectSource(dbg, "simple1.js"); 20 21 info("Add breakpoint to the source (simple2.js) in the remote frame"); 22 await selectSource(dbg, "simple2.js"); 23 await addBreakpoint(dbg, "simple2.js", 3); 24 25 is(dbg.selectors.getBreakpointCount(), 1, "Only one breakpoint exists"); 26 27 const source = findSource(dbg, "simple2.js"); 28 assertBreakpointsList(dbg, source); 29 30 is( 31 countTabs(dbg), 32 2, 33 "We see the tabs for the sources of both top and iframe documents" 34 ); 35 36 const onBreakpointSet = waitForDispatch(dbg.store, "SET_BREAKPOINT"); 37 38 info("reload the iframe"); 39 const iframeBrowsingContext = await SpecialPowers.spawn( 40 gBrowser.selectedBrowser, 41 [], 42 function () { 43 const iframe = content.document.querySelector("iframe"); 44 return iframe.browsingContext; 45 } 46 ); 47 await SpecialPowers.spawn(iframeBrowsingContext, [], () => { 48 content.location.reload(); 49 }); 50 51 await onBreakpointSet; 52 53 await waitForSelectedSource(dbg, "simple2.js"); 54 55 is(dbg.selectors.getBreakpointCount(), 1, "Only one breakpoint still exists"); 56 57 const sourceAfterReload = findSource(dbg, "simple2.js"); 58 assertBreakpointsList(dbg, sourceAfterReload); 59 60 is(countTabs(dbg), 2, "We still see the tabs for the two sources"); 61 62 await removeBreakpoint(dbg, sourceAfterReload.id, 3); 63 }); 64 65 function assertBreakpointsList(dbg, source) { 66 const breakpointHeadings = findAllElements(dbg, "breakpointHeadings"); 67 const breakpointItems = findAllElements(dbg, "breakpointItems"); 68 69 is( 70 breakpointHeadings.length, 71 1, 72 "The breakpoint list show one breakpoint source" 73 ); 74 is( 75 breakpointItems.length, 76 1, 77 "The breakpoint list shows only one breakpoint" 78 ); 79 80 is( 81 breakpointHeadings[0].title, 82 source.url, 83 "The info displayed for the breakpoint tooltip of the 1st breakpoint is correct" 84 ); 85 is( 86 breakpointHeadings[0].textContent, 87 "simple2.js", 88 "The info displayed for the breakpoint heading of the 1st breakpoint is correct" 89 ); 90 is( 91 breakpointItems[0].textContent, 92 "return x + y;3:5", 93 "The info displayed for the 1st breakpoint is correct" 94 ); 95 }