Bug 1641546 - Add a regression test for alwaysontop windows pulling focus. r=mstange
authorMike Conley <mconley@mozilla.com>
Fri, 05 Jun 2020 02:35:55 +0000
changeset 598241 4746c37be3e6ff7c566f44070eddd66908acfd20
parent 598240 a2b64d290c0b11b0dd8fb98a44b0a5a7f5ca844a
child 598242 72a62a455c476a293bafb9a0f1c205b44838c0ab
push id13310
push userffxbld-merge
push dateMon, 29 Jun 2020 14:50:06 +0000
treeherdermozilla-beta@15a59a0afa5c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmstange
bugs1641546
milestone79.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1641546 - Add a regression test for alwaysontop windows pulling focus. r=mstange Depends on D77695 Differential Revision: https://phabricator.services.mozilla.com/D77696
widget/tests/chrome.ini
widget/tests/test_alwaysontop_focus.xhtml
--- a/widget/tests/chrome.ini
+++ b/widget/tests/chrome.ini
@@ -1,16 +1,17 @@
 [DEFAULT]
 prefs =
   plugin.load_flash_only=false
 skip-if = os == 'android'
 support-files =
   empty_window.xhtml
   utils.js
 
+[test_alwaysontop_focus.xhtml]
 [test_bug343416.xhtml]
 skip-if = debug
 [test_bug429954.xhtml]
 support-files = window_bug429954.xhtml
 [test_bug444800.xhtml]
 [test_bug478536.xhtml]
 skip-if = true # Bug 561929
 support-files = window_bug478536.xhtml
new file mode 100644
--- /dev/null
+++ b/widget/tests/test_alwaysontop_focus.xhtml
@@ -0,0 +1,33 @@
+<!DOCTYPE HTML>
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+  <meta charset="utf-8" />
+  <title>Test that alwaysontop windows do not pull focus when opened.</title>
+  <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+  <link rel="stylesheet" href="chrome://mochikit/content/tests/SimpleTest/test.css"/>
+  <script><![CDATA[
+    add_task(async function testAlwaysOnTop() {
+      const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
+      let topWin = docShell.rootTreeItem.domWindow;
+      await SimpleTest.promiseFocus(topWin);
+      is(Services.focus.activeWindow, topWin, "Top level window is focused");
+
+      let newWin = Services.ww.openWindow(null, "about:blank", null, "chrome,alwaysontop,width=300,height=300", null);
+      await new Promise(resolve => {
+        newWin.addEventListener("load", resolve, { once: true });
+      });
+
+      // Wait one tick of the event loop to give the window a chance to focus.
+      await new Promise(resolve => { SimpleTest.executeSoon(resolve); });
+
+      is(Services.focus.activeWindow, topWin, "Top level window is still focused");
+      newWin.close();
+    });
+  ]]></script>
+</head>
+<body>
+<p id="display"></p>
+<div id="content" style="display: none"></div>
+<pre id="test"></pre>
+</body>
+</html>