Bug 1248772 - Trigger a OS window focus in ServiceWorkerClients::OpenWindow. r=ehsan

This commit is contained in:
Catalin Badea 2016-03-31 16:06:00 +02:00
Родитель 1ea26e16ac
Коммит 5082e816d8
4 изменённых файлов: 29 добавлений и 4 удалений

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

@ -3829,6 +3829,22 @@ nsContentUtils::DispatchChromeEvent(nsIDocument *aDoc,
return rv;
}
/* static */
nsresult
nsContentUtils::DispatchFocusChromeEvent(nsPIDOMWindowOuter* aWindow)
{
MOZ_ASSERT(aWindow);
nsCOMPtr<nsIDocument> doc = aWindow->GetExtantDoc();
if (!doc) {
return NS_ERROR_FAILURE;
}
return DispatchChromeEvent(doc, aWindow,
NS_LITERAL_STRING("DOMServiceWorkerFocusClient"),
true, true);
}
nsresult
nsContentUtils::DispatchEventOnlyToChrome(nsIDocument* aDoc,
nsISupports* aTarget,

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

@ -1125,6 +1125,13 @@ public:
bool aCancelable,
bool *aDefaultAction = nullptr);
/**
* Helper function for dispatching a "DOMServiceWorkerFocusClient" event to
* the chrome event handler of the given DOM Window. This has the effect
* of focusing the corresponding tab and bringing the browser window
* to the foreground.
*/
static nsresult DispatchFocusChromeEvent(nsPIDOMWindowOuter* aWindow);
/**
* This method creates and dispatches a trusted event.

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

@ -503,6 +503,11 @@ public:
if (NS_SUCCEEDED(rv)) {
MOZ_ASSERT(window);
rv = nsContentUtils::DispatchFocusChromeEvent(window);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
WorkerPrivate* workerPrivate = mPromiseProxy->GetWorkerPrivate();
MOZ_ASSERT(workerPrivate);

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

@ -95,10 +95,7 @@ public:
if (window) {
nsCOMPtr<nsIDocument> doc = window->GetDocument();
if (doc) {
nsContentUtils::DispatchChromeEvent(doc,
window->GetOuterWindow(),
NS_LITERAL_STRING("DOMServiceWorkerFocusClient"),
true, true);
nsContentUtils::DispatchFocusChromeEvent(window->GetOuterWindow());
clientInfo.reset(new ServiceWorkerClientInfo(doc));
}
}