diff --git a/browser/components/extensions/ext-utils.js b/browser/components/extensions/ext-utils.js index e2e8ea73e723..91db5bdda2a3 100644 --- a/browser/components/extensions/ext-utils.js +++ b/browser/components/extensions/ext-utils.js @@ -738,6 +738,11 @@ global.WindowManager = { state = "fullscreen"; } + let xulWindow = window.QueryInterface(Ci.nsIInterfaceRequestor) + .getInterface(Ci.nsIDocShell) + .treeOwner.QueryInterface(Ci.nsIInterfaceRequestor) + .getInterface(Ci.nsIXULWindow); + let result = { id: this.getId(window), focused: window.document.hasFocus(), @@ -748,6 +753,7 @@ global.WindowManager = { incognito: PrivateBrowsingUtils.isWindowPrivate(window), type: this.windowType(window), state, + alwaysOnTop: xulWindow.zLevel >= Ci.nsIXULWindow.raisedZ, }; if (getInfo && getInfo.populate) { diff --git a/browser/components/extensions/schemas/windows.json b/browser/components/extensions/schemas/windows.json index 88a0f0149efa..a733b5da8278 100644 --- a/browser/components/extensions/schemas/windows.json +++ b/browser/components/extensions/schemas/windows.json @@ -88,7 +88,6 @@ "description": "The state of this browser window." }, "alwaysOnTop": { - "unsupported": true, "type": "boolean", "description": "Whether the window is set to be always on top." }, diff --git a/browser/components/extensions/test/browser/browser.ini b/browser/components/extensions/test/browser/browser.ini index 2480a1bab11b..10a1f112af46 100644 --- a/browser/components/extensions/test/browser/browser.ini +++ b/browser/components/extensions/test/browser/browser.ini @@ -56,6 +56,7 @@ support-files = [browser_ext_windows_create.js] tags = fullscreen [browser_ext_windows_create_tabId.js] +[browser_ext_windows.js] [browser_ext_windows_update.js] tags = fullscreen [browser_ext_contentscript_connect.js] diff --git a/browser/components/extensions/test/browser/browser_ext_windows.js b/browser/components/extensions/test/browser/browser_ext_windows.js new file mode 100644 index 000000000000..d3dd6ecdbe06 --- /dev/null +++ b/browser/components/extensions/test/browser/browser_ext_windows.js @@ -0,0 +1,33 @@ +/* -*- Mode: indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* vim: set sts=2 sw=2 et tw=80: */ +"use strict"; + +add_task(function* () { + let raisedWin = Services.ww.openWindow( + null, Services.prefs.getCharPref("browser.chromeURL"), "_blank", + "chrome,dialog=no,all,alwaysRaised", null); + + yield TestUtils.topicObserved("browser-delayed-startup-finished", + subject => subject == raisedWin); + + let extension = ExtensionTestUtils.loadExtension({ + background: function() { + browser.windows.getAll((wins) => { + browser.test.assertEq(wins.length, 2, "Expect two windows"); + + browser.test.assertEq(false, wins[0].alwaysOnTop, + "Expect first window not to be always on top"); + browser.test.assertEq(true, wins[1].alwaysOnTop, + "Expect first window to be always on top"); + + browser.test.notifyPass("alwaysOnTop"); + }); + }, + }); + + yield extension.startup(); + yield extension.awaitFinish("alwaysOnTop"); + yield extension.unload(); + + yield BrowserTestUtils.closeWindow(raisedWin); +});