browser_dbg-windowless-service-workers-reload.js (1857B)
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 // Test that service worker sources are still displayed after reloading the page 6 // and that we can hit breakpoints in them. 7 8 "use strict"; 9 10 const SW_URL = EXAMPLE_URL + "service-worker.sjs"; 11 12 add_task(async function () { 13 await pushPref("devtools.debugger.threads-visible", true); 14 await pushPref("dom.serviceWorkers.testing.enabled", true); 15 16 const dbg = await initDebugger("doc-service-workers.html"); 17 18 await SpecialPowers.spawn(gBrowser.selectedBrowser, [], async function () { 19 await content.wrappedJSObject.registerWorker(); 20 }); 21 const workerSource = await waitForSource(dbg, "service-worker.sjs"); 22 23 await reload(dbg, "service-worker.sjs"); 24 25 await addBreakpoint(dbg, "service-worker.sjs", 13); 26 const onFetched = invokeInTab("fetchFromWorker"); 27 28 await waitForPaused(dbg); 29 await assertPausedAtSourceAndLine(dbg, workerSource.id, 13); 30 31 await assertPreviews(dbg, [ 32 { 33 line: 10, 34 column: 9, 35 result: EXAMPLE_URL + "whatever", 36 expression: "url", 37 }, 38 ]); 39 40 await resume(dbg); 41 info("Waiting for the fetch request done from the page to complete"); 42 await onFetched; 43 44 // Reload a second time to ensure we can still debug the SW 45 await reload(dbg, "service-worker.sjs"); 46 47 await waitForPaused(dbg); 48 await assertPausedAtSourceAndLine(dbg, workerSource.id, 13); 49 50 await assertPreviews(dbg, [ 51 { 52 line: 10, 53 column: 9, 54 result: EXAMPLE_URL + "whatever", 55 expression: "url", 56 }, 57 ]); 58 59 await resume(dbg); 60 61 await unregisterServiceWorker(SW_URL); 62 63 await checkAdditionalThreadCount(dbg, 0); 64 65 await waitForRequestsToSettle(dbg); 66 67 await closeTabAndToolbox(); 68 });