зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1691144 - Trigger windows.onFocusChanged with no private window permission. r=zombie
Credits to Jonathan Mayer for submitting the original patch. The patch changes the onFocusChanged extension event handler so that it no longer bails out if focus is moving to a private window, ensuring that the onFocusChanged event gets generated with the proper WINDOW_ID_NONE identifier. Differential Revision: https://phabricator.services.mozilla.com/D104732
This commit is contained in:
Родитель
84e35e0326
Коммит
b265358b2c
|
@ -92,10 +92,7 @@ this.windows = class extends ExtensionAPI {
|
|||
Promise.resolve().then(() => {
|
||||
let windowId = Window.WINDOW_ID_NONE;
|
||||
let window = Services.focus.activeWindow;
|
||||
if (window) {
|
||||
if (!context.canAccessWindow(window)) {
|
||||
return;
|
||||
}
|
||||
if (window && context.canAccessWindow(window)) {
|
||||
windowId = windowTracker.getId(window);
|
||||
}
|
||||
if (windowId !== lastOnFocusChangedWindowId) {
|
||||
|
|
|
@ -15,7 +15,22 @@ add_task(async function test_window_incognito() {
|
|||
permissions: ["http://mochi.test/"],
|
||||
},
|
||||
background() {
|
||||
let lastFocusedWindowId = null;
|
||||
// Catch focus change events to power the test below.
|
||||
browser.windows.onFocusChanged.addListener(function listener(
|
||||
eventWindowId
|
||||
) {
|
||||
lastFocusedWindowId = eventWindowId;
|
||||
browser.windows.onFocusChanged.removeListener(listener);
|
||||
});
|
||||
|
||||
browser.test.onMessage.addListener(async pbw => {
|
||||
browser.test.assertEq(
|
||||
browser.windows.WINDOW_ID_NONE,
|
||||
lastFocusedWindowId,
|
||||
"Focus on private window sends the event, but doesn't reveal windowId (without permissions)"
|
||||
);
|
||||
|
||||
await browser.test.assertRejects(
|
||||
browser.windows.get(pbw.windowId),
|
||||
/Invalid window ID/,
|
||||
|
@ -59,9 +74,13 @@ add_task(async function test_window_incognito() {
|
|||
},
|
||||
});
|
||||
|
||||
await extension.startup();
|
||||
|
||||
// The tests expect the incognito window to be
|
||||
// created after the extension is started, so think
|
||||
// carefully when moving this line.
|
||||
let winData = await getIncognitoWindow(url);
|
||||
|
||||
await extension.startup();
|
||||
extension.sendMessage(winData.details);
|
||||
await extension.awaitFinish("pass");
|
||||
await BrowserTestUtils.closeWindow(winData.win);
|
||||
|
|
Загрузка…
Ссылка в новой задаче