mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-13 05:15:45 +00:00
Bug 1202532 - The callback argument of windows.update() is optional. r=billm
--HG-- extra : transplant_source : %87%C8%A5TJ%7E3%C7%3F%91%89v%F7%01%85%5D%C8N5%BC
This commit is contained in:
parent
521114354e
commit
73389bf1f4
@ -60,7 +60,7 @@ extensions.registerAPI((extension, context) => {
|
||||
runSafe(context, callback, WindowManager.convert(extension, window, getInfo));
|
||||
},
|
||||
|
||||
getAll: function(getAll, callback) {
|
||||
getAll: function(getInfo, callback) {
|
||||
let e = Services.wm.getEnumerator("navigator:browser");
|
||||
let windows = [];
|
||||
while (e.hasMoreElements()) {
|
||||
@ -131,7 +131,10 @@ extensions.registerAPI((extension, context) => {
|
||||
Services.focus.activeWindow = window;
|
||||
}
|
||||
// TODO: All the other properties...
|
||||
runSafe(context, callback, WindowManager.convert(extension, window));
|
||||
|
||||
if (callback) {
|
||||
runSafe(context, callback, WindowManager.convert(extension, window));
|
||||
}
|
||||
},
|
||||
|
||||
remove: function(windowId, callback) {
|
||||
|
@ -6,3 +6,4 @@ skip-if = os == 'android' || buildapp == 'b2g' || os == 'mac'
|
||||
[browser_ext_tabs_executeScript.js]
|
||||
[browser_ext_tabs_query.js]
|
||||
[browser_ext_tabs_update.js]
|
||||
[browser_ext_windows_update.js]
|
||||
|
@ -0,0 +1,51 @@
|
||||
add_task(function* () {
|
||||
function promiseWaitForFocus(aWindow) {
|
||||
return new Promise(function(aResolve, aReject) {
|
||||
waitForFocus(function() {
|
||||
ok(Services.focus.activeWindow === aWindow, "correct window focused");
|
||||
aResolve();
|
||||
}, aWindow);
|
||||
});
|
||||
}
|
||||
|
||||
let window1 = window;
|
||||
let window2 = yield BrowserTestUtils.openNewBrowserWindow();
|
||||
|
||||
Services.focus.activeWindow = window2;
|
||||
yield promiseWaitForFocus(window2);
|
||||
|
||||
let extension = ExtensionTestUtils.loadExtension({
|
||||
manifest: {
|
||||
"permissions": ["windows"]
|
||||
},
|
||||
|
||||
background: function() {
|
||||
browser.windows.getAll(undefined, function(wins) {
|
||||
browser.test.assertEq(wins.length, 2, "should have two windows");
|
||||
|
||||
// Sort the unfocused window to the lower index.
|
||||
wins.sort(function(win1, win2) {
|
||||
if (win1.focused === win2.focused) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return win1.focused ? 1 : -1;
|
||||
});
|
||||
|
||||
browser.windows.update(wins[0].id, {focused: true}, function() {
|
||||
browser.test.sendMessage("check");
|
||||
});
|
||||
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
yield extension.startup();
|
||||
yield extension.awaitMessage("check");
|
||||
|
||||
yield promiseWaitForFocus(window1);
|
||||
|
||||
yield extension.unload();
|
||||
|
||||
yield BrowserTestUtils.closeWindow(window2);
|
||||
});
|
Loading…
Reference in New Issue
Block a user