mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 987492 - CustomizableUI.jsm should provide convenience APIs around windows, r=gijs,mconley
This commit is contained in:
parent
699abc28d5
commit
87fe853785
@ -810,6 +810,8 @@ let CustomizableUIInternal = {
|
||||
|
||||
aWindow.addEventListener("unload", this);
|
||||
aWindow.addEventListener("command", this, true);
|
||||
|
||||
this.notifyListeners("onWindowOpened", aWindow);
|
||||
}
|
||||
},
|
||||
|
||||
@ -850,6 +852,8 @@ let CustomizableUIInternal = {
|
||||
areaMap.delete(toDelete);
|
||||
}
|
||||
}
|
||||
|
||||
this.notifyListeners("onWindowClosed", aWindow);
|
||||
},
|
||||
|
||||
setLocationAttributes: function(aNode, aArea) {
|
||||
@ -2476,6 +2480,18 @@ this.CustomizableUI = {
|
||||
*/
|
||||
get PANEL_COLUMN_COUNT() 3,
|
||||
|
||||
/**
|
||||
* An iteratable property of windows managed by CustomizableUI.
|
||||
* Note that this can *only* be used as an iterator. ie:
|
||||
* for (let window of CustomizableUI.windows) { ... }
|
||||
*/
|
||||
windows: {
|
||||
"@@iterator": function*() {
|
||||
for (let [window,] of gBuildWindows)
|
||||
yield window;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Add a listener object that will get fired for various events regarding
|
||||
* customization.
|
||||
@ -2559,6 +2575,12 @@ this.CustomizableUI = {
|
||||
* - onWidgetUnderflow(aNode, aContainer)
|
||||
* Fired when a widget's DOM node is *not* overflowing its container, a
|
||||
* toolbar, anymore.
|
||||
* - onWindowOpened(aWindow)
|
||||
* Fired when a window has been opened that is managed by CustomizableUI,
|
||||
* once all of the prerequisite setup has been done.
|
||||
* - onWindowClosed(aWindow)
|
||||
* Fired when a window that has been managed by CustomizableUI has been
|
||||
* closed.
|
||||
*/
|
||||
addListener: function(aListener) {
|
||||
CustomizableUIInternal.addListener(aListener);
|
||||
@ -3274,7 +3296,7 @@ this.CustomizableUI = {
|
||||
}
|
||||
};
|
||||
Object.freeze(this.CustomizableUI);
|
||||
|
||||
Object.freeze(this.CustomizableUI.windows);
|
||||
|
||||
/**
|
||||
* All external consumers of widgets are really interacting with these wrappers
|
||||
|
@ -93,4 +93,5 @@ skip-if = os == "linux"
|
||||
[browser_981305_separator_insertion.js]
|
||||
[browser_987177_destroyWidget_xul.js]
|
||||
[browser_987177_xul_wrapper_updating.js]
|
||||
[browser_987492_window_api.js]
|
||||
[browser_panel_toggle.js]
|
||||
|
@ -0,0 +1,54 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
"use strict";
|
||||
|
||||
|
||||
add_task(function* testOneWindow() {
|
||||
let windows = [];
|
||||
for (let win of CustomizableUI.windows)
|
||||
windows.push(win);
|
||||
is(windows.length, 1, "Should have one customizable window");
|
||||
});
|
||||
|
||||
|
||||
add_task(function* testOpenCloseWindow() {
|
||||
let newWindow = null;
|
||||
let openListener = {
|
||||
onWindowOpened: function(window) {
|
||||
newWindow = window;
|
||||
}
|
||||
}
|
||||
CustomizableUI.addListener(openListener);
|
||||
let win = yield openAndLoadWindow(null, true);
|
||||
isnot(newWindow, null, "Should have gotten onWindowOpen event");
|
||||
is(newWindow, win, "onWindowOpen event should have received expected window");
|
||||
CustomizableUI.removeListener(openListener);
|
||||
|
||||
let windows = [];
|
||||
for (let win of CustomizableUI.windows)
|
||||
windows.push(win);
|
||||
is(windows.length, 2, "Should have two customizable windows");
|
||||
isnot(windows.indexOf(window), -1, "Current window should be in window collection.");
|
||||
isnot(windows.indexOf(newWindow), -1, "New window should be in window collection.");
|
||||
|
||||
let closedWindow = null;
|
||||
let closeListener = {
|
||||
onWindowClosed: function(window) {
|
||||
closedWindow = window;
|
||||
}
|
||||
}
|
||||
CustomizableUI.addListener(closeListener);
|
||||
yield promiseWindowClosed(newWindow);
|
||||
isnot(closedWindow, null, "Should have gotten onWindowClosed event")
|
||||
is(newWindow, closedWindow, "Closed window should match previously opened window");
|
||||
CustomizableUI.removeListener(closeListener);
|
||||
|
||||
let windows = [];
|
||||
for (let win of CustomizableUI.windows)
|
||||
windows.push(win);
|
||||
is(windows.length, 1, "Should have one customizable window");
|
||||
isnot(windows.indexOf(window), -1, "Current window should be in window collection.");
|
||||
is(windows.indexOf(closedWindow), -1, "Closed window should not be in window collection.");
|
||||
});
|
Loading…
Reference in New Issue
Block a user