diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /devtools/client/framework/test/browser_source_map-late-script.js | |
parent | Initial commit. (diff) | |
download | firefox-esr-upstream.tar.xz firefox-esr-upstream.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'devtools/client/framework/test/browser_source_map-late-script.js')
-rw-r--r-- | devtools/client/framework/test/browser_source_map-late-script.js | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/devtools/client/framework/test/browser_source_map-late-script.js b/devtools/client/framework/test/browser_source_map-late-script.js new file mode 100644 index 0000000000..f11d530db1 --- /dev/null +++ b/devtools/client/framework/test/browser_source_map-late-script.js @@ -0,0 +1,52 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +// Test that you can subscribe to notifications on a source before it has loaded. + +"use strict"; + +const PAGE_URL = `${URL_ROOT_SSL}doc_empty-tab-01.html`; +const JS_URL = URL_ROOT_SSL + "code_bundle_late_script.js"; + +const ORIGINAL_URL = "webpack:///code_late_script.js"; + +const GENERATED_LINE = 107; +const ORIGINAL_LINE = 11; + +add_task(async function () { + // Start with the empty page, then navigate, so that we can properly + // listen for new sources arriving. + const toolbox = await openNewTabAndToolbox(PAGE_URL, "webconsole"); + const service = toolbox.sourceMapURLService; + + const scriptMapped = new Promise(resolve => { + let count = 0; + service.subscribeByURL( + JS_URL, + GENERATED_LINE, + undefined, + originalLocation => { + if (count === 0) { + resolve(originalLocation); + } + count += 1; + + return () => {}; + } + ); + }); + + // Inject JS script + const sourceSeen = waitForSourceLoad(toolbox, JS_URL); + await createScript(JS_URL); + await sourceSeen; + + // Ensure that the URL service fired an event about the location loading. + const { url, line } = await scriptMapped; + is(url, ORIGINAL_URL, "check mapped URL"); + is(line, ORIGINAL_LINE, "check mapped line number"); + + await toolbox.destroy(); + gBrowser.removeCurrentTab(); + finish(); +}); |