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 /dom/html/test/test_bug1322678.html | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/html/test/test_bug1322678.html')
-rw-r--r-- | dom/html/test/test_bug1322678.html | 113 |
1 files changed, 113 insertions, 0 deletions
diff --git a/dom/html/test/test_bug1322678.html b/dom/html/test/test_bug1322678.html new file mode 100644 index 0000000000..57b43f039c --- /dev/null +++ b/dom/html/test/test_bug1322678.html @@ -0,0 +1,113 @@ +<!DOCTYPE html> +<html> +<!-- +https://bugzilla.mozilla.org/show_bug.cgi?id=1322678 +--> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> +<title>Test for Bug 1322678</title> +<script src="/tests/SimpleTest/EventUtils.js"></script> +<script src="/tests/SimpleTest/SimpleTest.js"></script> +<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> +</head> +<body> +<script type="text/javascript"> + +const CUSTOM_TITLE = "Custom Title"; + +async function openNewWindowForTest() { + let win = window.open("bug369370-popup.png", "bug1322678", + "width=400,height=300,scrollbars=no"); + ok(win, "opened child window"); + + await new Promise(resolve => { + win.onload = function() { + ok(true, "window loaded"); + resolve(); + }; + }); + + return win; +} + +async function testCustomTitle(aWin, aTitle) { + let doc = aWin.document; + let elements = doc.getElementsByTagName("img"); + is(elements.length, 1, "looking for img in ImageDocument"); + let img = elements[0]; + + // Click to zoom in + synthesizeMouse(img, 25, 25, { }, aWin); + is(doc.title, aTitle, "Checking title"); + + // Click there again to zoom out + synthesizeMouse(img, 25, 25, { }, aWin); + is(doc.title, aTitle, "Checking title"); + + // Now try resizing the window so the image fits vertically and horizontally. + await new Promise(resolve => { + aWin.addEventListener("resize", function() { + // Give the image document time to respond + SimpleTest.executeSoon(function() { + is(doc.title, aTitle, "Checking title"); + resolve(); + }); + }, {once: true}); + + let decorationSize = aWin.outerHeight - aWin.innerHeight; + aWin.resizeTo(800 + 50 + decorationSize, 600 + 50 + decorationSize); + }); + + // Now try resizing the window so the image no longer fits. + await new Promise(resolve => { + aWin.addEventListener("resize", function() { + // Give the image document time to respond + SimpleTest.executeSoon(function() { + is(doc.title, aTitle, "Checking title"); + resolve(); + }); + }, {once: true}); + + aWin.resizeTo(400, 300); + }); +} + +// eslint-disable-next-line mozilla/no-addtask-setup +add_task(async function setup() { + await SpecialPowers.pushPrefEnv({"set": [ + ["browser.enable_automatic_image_resizing", true], + ]}); +}); + +add_task(async function testUpdateDocumentTitle() { + let win = await openNewWindowForTest(); + // Set custom title. + win.document.title = CUSTOM_TITLE; + await testCustomTitle(win, CUSTOM_TITLE); + win.close(); +}); + +add_task(async function testUpdateTitleElement() { + let win = await openNewWindowForTest(); + // Set custom title. + let title = win.document.getElementsByTagName("title")[0]; + title.text = CUSTOM_TITLE; + await testCustomTitle(win, CUSTOM_TITLE); + win.close(); +}); + +add_task(async function testAppendNewTitleElement() { + let win = await openNewWindowForTest(); + // Set custom title. + let doc = win.document; + doc.getElementsByTagName("title")[0].remove(); + let title = doc.createElement("title"); + title.text = CUSTOM_TITLE; + doc.head.appendChild(title); + await testCustomTitle(win, CUSTOM_TITLE); + win.close(); +}); + +</script> +</body> +</html> |