From 2aa4a82499d4becd2284cdb482213d541b8804dd Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 28 Apr 2024 16:29:10 +0200 Subject: Adding upstream version 86.0.1. Signed-off-by: Daniel Baumann --- .../test/browser/browser_partialsource.js | 46 ++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 toolkit/components/viewsource/test/browser/browser_partialsource.js (limited to 'toolkit/components/viewsource/test/browser/browser_partialsource.js') diff --git a/toolkit/components/viewsource/test/browser/browser_partialsource.js b/toolkit/components/viewsource/test/browser/browser_partialsource.js new file mode 100644 index 0000000000..5efdc1c1cc --- /dev/null +++ b/toolkit/components/viewsource/test/browser/browser_partialsource.js @@ -0,0 +1,46 @@ +/* Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ + */ + +const frameSource = + "some textother text"; +const sources = [ + ``, + ``, +]; + +add_task(async function partial_source() { + for (let source of sources) { + let tab = await BrowserTestUtils.openNewForegroundTab( + gBrowser, + "data:text/html," + source + ); + + let frameBC = gBrowser.selectedBrowser.browsingContext.children[0]; + + await SpecialPowers.spawn(frameBC, [], () => { + let element = content.document.getElementById("other"); + content.focus(); + content.getSelection().selectAllChildren(element); + }); + + let sourceTab = await openViewPartialSource("#other", frameBC); + + let browser = gBrowser.selectedBrowser; + let textContent = await SpecialPowers.spawn(browser, [], async function() { + return content.document.body.textContent; + }); + is( + textContent, + 'other text', + "Correct content loaded" + ); + let selection = await SpecialPowers.spawn(browser, [], async function() { + return String(content.getSelection()); + }); + is(selection, "other text", "Correct text selected"); + + gBrowser.removeTab(sourceTab); + gBrowser.removeTab(tab); + } +}); -- cgit v1.2.3