diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /devtools/client/inspector/test/browser_inspector_iframe-navigation.js | |
parent | Initial commit. (diff) | |
download | firefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz firefox-26a029d407be480d791972afb5975cf62c9360a6.zip |
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | devtools/client/inspector/test/browser_inspector_iframe-navigation.js | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/devtools/client/inspector/test/browser_inspector_iframe-navigation.js b/devtools/client/inspector/test/browser_inspector_iframe-navigation.js new file mode 100644 index 0000000000..de97b1e020 --- /dev/null +++ b/devtools/client/inspector/test/browser_inspector_iframe-navigation.js @@ -0,0 +1,58 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ +"use strict"; + +// Test that the highlighter element picker still works through iframe +// navigations. + +const TEST_URI = + "data:text/html;charset=utf-8," + + "<p>bug 699308 - test iframe navigation</p>" + + "<iframe src='data:text/html;charset=utf-8,hello world'></iframe>"; + +add_task(async function () { + const { inspector, toolbox, highlighterTestFront } = + await openInspectorForURL(TEST_URI); + + info("Starting element picker."); + await startPicker(toolbox); + + info("Mouse over for body element."); + await hoverElement(inspector, "body"); + + let isVisible = await highlighterTestFront.isHighlighting(); + ok(isVisible, "Inspector is highlighting."); + + await reloadIframe(inspector); + info("Frame reloaded. Reloading again."); + + await reloadIframe(inspector); + info("Frame reloaded twice."); + + isVisible = await highlighterTestFront.isHighlighting(); + ok(isVisible, "Inspector is highlighting after iframe nav."); + + info("Stopping element picker."); + await toolbox.nodePicker.stop({ canceled: true }); +}); + +async function reloadIframe(inspector) { + const { resourceCommand } = inspector.commands; + + const { onResource: onNewRoot } = await resourceCommand.waitForNextResource( + resourceCommand.TYPES.ROOT_NODE, + { + ignoreExistingResources: true, + } + ); + + await SpecialPowers.spawn(gBrowser.selectedBrowser, [], async () => { + const iframeEl = content.document.querySelector("iframe"); + await new Promise(resolve => { + iframeEl.addEventListener("load", () => resolve(), { once: true }); + iframeEl.contentWindow.location.reload(); + }); + }); + + await onNewRoot; +} |