From 26a029d407be480d791972afb5975cf62c9360a6 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 02:47:55 +0200 Subject: Adding upstream version 124.0.1. Signed-off-by: Daniel Baumann --- dom/tests/mochitest/chrome/window_focus.xhtml | 1702 +++++++++++++++++++++++++ 1 file changed, 1702 insertions(+) create mode 100644 dom/tests/mochitest/chrome/window_focus.xhtml (limited to 'dom/tests/mochitest/chrome/window_focus.xhtml') diff --git a/dom/tests/mochitest/chrome/window_focus.xhtml b/dom/tests/mochitest/chrome/window_focus.xhtml new file mode 100644 index 0000000000..e4cfeb6560 --- /dev/null +++ b/dom/tests/mochitest/chrome/window_focus.xhtml @@ -0,0 +1,1702 @@ + + + + + + + + + + + + "; + return goneBack; + }); + }).then(({ location, persisted }) => { + is(location, firstLocation, "should go back to the right page"); + ok(persisted, "test relies on BFCache"); + return ContentTask.spawn(frame, {}, () => { + let fm = Cc["@mozilla.org/focus-manager;1"].getService(Ci.nsIFocusManager); + let t20 = content.document.getElementById("t20"); + return fm.focusedElement === t20; + }); + }).then((focusCorrect) => { + if (SpecialPowers.Services.appinfo.sessionHistoryInParent) { + todo(focusCorrect, "focus restored after history back"); + } else { + ok(focusCorrect, "focus restored after history back"); + } + done(); + }); +} + +function addFrameSwitchingListeners(frame) +{ + frame.contentWindow.addEventListener("focus", frameSwitchingEventOccured); + frame.contentWindow.addEventListener("blur", frameSwitchingEventOccured); + frame.contentDocument.addEventListener("focus", frameSwitchingEventOccured); + frame.contentDocument.addEventListener("blur", frameSwitchingEventOccured); + + var node = frame.contentDocument.body.firstChild; + node.addEventListener("focus", frameSwitchingEventOccured); + node.addEventListener("blur", frameSwitchingEventOccured); +} + +function frameSwitchingEventOccured(event) +{ + if (!gExpectedEvents.length) { + gEventMatched = false; + return; + } + + try { + var events = gExpectedEvents.shift(); + is(event.target, events[0], "event target"); + is(event.type, events[1], "event type"); + is(fm.focusedElement, events[2], "focused element"); + is(fm.focusedWindow, events[3], "focused frame"); + if (events[4]) + is(fm.getFocusedElementForWindow(events[4], false, {}), events[5], "focused element in frame"); + + if (gEventMatched && event.target == events[0] && event.type == events[1] && + fm.focusedElement == events[2] && fm.focusedWindow == events[3]) { + if (!events[4] || fm.getFocusedElementForWindow(events[4], false, {}) == events[5]) + return; + } + } catch (ex) { ok(ex, "exception"); } + + gEventMatched = false; +} + +SimpleTest.waitForExplicitFinish(); +SimpleTest.waitForFocus(startTest); + +]]> + + + + + + + +