Bug 1591922 - [remote] Page.bringToFront has to wait for activate and focus events. r=remote-protocol-reviewers,ato

Differential Revision: https://phabricator.services.mozilla.com/D52000

--HG--
rename : remote/domains/parent/target/TabManager.jsm => remote/TabManager.jsm
extra : moz-landing-system : lando
This commit is contained in:
Henrik Skupin 2019-11-07 14:47:53 +00:00
Родитель 84cc2511ab
Коммит e19b0aa009
5 изменённых файлов: 47 добавлений и 15 удалений

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

@ -19,7 +19,7 @@ var TabManager = {
triggeringPrincipal: Services.scriptSecurityManager.getSystemPrincipal(),
userContextId,
});
this.gBrowser.selectedTab = tab;
this.selectTab(tab);
return tab;
},
@ -27,4 +27,8 @@ var TabManager = {
removeTab(tab) {
this.gBrowser.removeTab(tab);
},
selectTab(tab) {
this.gBrowser.selectedTab = tab;
},
};

25
remote/WindowManager.jsm Normal file
Просмотреть файл

@ -0,0 +1,25 @@
/* 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";
var EXPORTED_SYMBOLS = ["WindowManager"];
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
const { EventPromise } = ChromeUtils.import("chrome://remote/content/Sync.jsm");
var WindowManager = {
async focus(window) {
if (window != Services.focus.activeWindow) {
const promises = [
EventPromise(window, "activate"),
EventPromise(window, "focus", { capture: true }),
];
window.focus();
await Promise.all(promises);
}
},
};

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

@ -15,6 +15,12 @@ const { Domain } = ChromeUtils.import(
const { UnsupportedError } = ChromeUtils.import(
"chrome://remote/content/Error.jsm"
);
const { TabManager } = ChromeUtils.import(
"chrome://remote/content/TabManager.jsm"
);
const { WindowManager } = ChromeUtils.import(
"chrome://remote/content/WindowManager.jsm"
);
class Page extends Domain {
constructor(session) {
@ -147,16 +153,12 @@ class Page extends Domain {
}
}
bringToFront() {
const { browser } = this.session.target;
const navigator = browser.ownerGlobal;
const { gBrowser } = navigator;
async bringToFront() {
const { tab, window } = this.session.target;
// Focus the window responsible for this page.
navigator.focus();
// Select the corresponding tab
gBrowser.selectedTab = gBrowser.getTabForBrowser(browser);
// Focus the window, and select the corresponding tab
await WindowManager.focus(window);
TabManager.selectTab(tab);
}
/**

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

@ -6,18 +6,18 @@
var EXPORTED_SYMBOLS = ["Target"];
const { ContextualIdentityService } = ChromeUtils.import(
"resource://gre/modules/ContextualIdentityService.jsm"
);
const { Domain } = ChromeUtils.import(
"chrome://remote/content/domains/Domain.jsm"
);
const { TabManager } = ChromeUtils.import(
"chrome://remote/content/domains/parent/target/TabManager.jsm"
"chrome://remote/content/TabManager.jsm"
);
const { TabSession } = ChromeUtils.import(
"chrome://remote/content/sessions/TabSession.jsm"
);
const { ContextualIdentityService } = ChromeUtils.import(
"resource://gre/modules/ContextualIdentityService.jsm"
);
let sessionIds = 1;
let browserContextIds = 1;

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

@ -14,6 +14,8 @@ remote.jar:
content/Protocol.jsm (Protocol.jsm)
content/RecommendedPreferences.jsm (RecommendedPreferences.jsm)
content/Sync.jsm (Sync.jsm)
content/TabManager.jsm (TabManager.jsm)
content/WindowManager.jsm (WindowManager.jsm)
# sessions
content/sessions/frame-script.js (sessions/frame-script.js)
@ -54,7 +56,6 @@ remote.jar:
content/domains/parent/page/DialogHandler.jsm (domains/parent/page/DialogHandler.jsm)
content/domains/parent/Security.jsm (domains/parent/Security.jsm)
content/domains/parent/Target.jsm (domains/parent/Target.jsm)
content/domains/parent/target/TabManager.jsm (domains/parent/target/TabManager.jsm)
# transport layer
content/server/HTTPD.jsm (../netwerk/test/httpserver/httpd.js)