diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
commit | 6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch) | |
tree | a68f146d7fa01f0134297619fbe7e33db084e0aa /devtools/client/inspector/test/browser_inspector_reload_invalid_iframe.js | |
parent | Initial commit. (diff) | |
download | thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.tar.xz thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.zip |
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | devtools/client/inspector/test/browser_inspector_reload_invalid_iframe.js | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/devtools/client/inspector/test/browser_inspector_reload_invalid_iframe.js b/devtools/client/inspector/test/browser_inspector_reload_invalid_iframe.js new file mode 100644 index 0000000000..2a6bd69e48 --- /dev/null +++ b/devtools/client/inspector/test/browser_inspector_reload_invalid_iframe.js @@ -0,0 +1,63 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +"use strict"; + +// When reselecting the selected node, if an element expected to be an iframe is +// NOT actually an iframe, we should still fallback on the root body element. + +const TEST_URI = "data:text/html;charset=utf-8,<div id='fake-iframe'>"; + +add_task(async function () { + const { inspector } = await openInspectorForURL(TEST_URI); + + info("Replace fake-iframe div with a real iframe"); + await ContentTask.spawn(gBrowser.selectedBrowser, null, async function () { + await new Promise(resolve => { + // Remove the fake-iframe div + content.document.querySelector("#fake-iframe").remove(); + + // Create an iframe element with the same id "fake-iframe". + const iframe = content.document.createElement("iframe"); + content.document.body.appendChild(iframe); + iframe.setAttribute("id", "fake-iframe"); + + iframe.contentWindow.addEventListener("load", () => { + // Create a div element and append it to the iframe + const div = content.document.createElement("div"); + div.id = "in-frame"; + div.textContent = "div in frame"; + + const frameContent = + iframe.contentWindow.document.querySelector("body"); + frameContent.appendChild(div); + resolve(); + }); + }); + }); + + ok( + await hasMatchingElementInContentPage("iframe"), + "The iframe has been added to the page" + ); + + info("Select node inside iframe."); + await selectNodeInFrames(["iframe", "#in-frame"], inspector); + + const markupLoaded = inspector.once("markuploaded"); + + info("Reloading page."); + await navigateTo(TEST_URI); + + info("Waiting for markupview to load after reload."); + await markupLoaded; + + const rootNodeFront = await getNodeFront("body", inspector); + + is( + inspector.selection.nodeFront, + rootNodeFront, + "body node selected after reload." + ); +}); |