Bug 1253130: [webext] Support the `alwaysOnTop` in the browser.windows API. r=gabor

MozReview-Commit-ID: FNBCsDt0UT8

--HG--
extra : rebase_source : 80ec6a949237e4e59b17a9a9b31b5001d9f09606
This commit is contained in:
Kris Maglione 2016-03-22 23:11:35 +01:00
Родитель 44a9c4e544
Коммит 5c47b4916d
4 изменённых файлов: 40 добавлений и 1 удалений

Просмотреть файл

@ -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) {

Просмотреть файл

@ -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."
},

Просмотреть файл

@ -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]

Просмотреть файл

@ -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);
});