| Index: Source/modules/serviceworkers/ServiceWorkerClient.cpp
|
| diff --git a/Source/modules/serviceworkers/ServiceWorkerClient.cpp b/Source/modules/serviceworkers/ServiceWorkerClient.cpp
|
| index 57ab08a2eb23c4b3c75a200154c59bd2d1d900d0..5045e883ae5ce79068b1dd898e88c2414affbbf6 100644
|
| --- a/Source/modules/serviceworkers/ServiceWorkerClient.cpp
|
| +++ b/Source/modules/serviceworkers/ServiceWorkerClient.cpp
|
| @@ -9,6 +9,7 @@
|
| #include "bindings/core/v8/ExceptionState.h"
|
| #include "bindings/core/v8/ScriptPromiseResolver.h"
|
| #include "bindings/core/v8/SerializedScriptValue.h"
|
| +#include "core/page/WindowFocusAllowedIndicator.h"
|
| #include "modules/serviceworkers/ServiceWorkerError.h"
|
| #include "modules/serviceworkers/ServiceWorkerGlobalScopeClient.h"
|
| #include "public/platform/WebString.h"
|
| @@ -43,9 +44,11 @@ ScriptPromise ServiceWorkerClient::focus(ScriptState* scriptState)
|
| RefPtr<ScriptPromiseResolver> resolver = ScriptPromiseResolver::create(scriptState);
|
| ScriptPromise promise = resolver->promise();
|
|
|
| - // FIXME: there should be a check for whether the caller is allowed to focus
|
| - // the client. The promise should succeed with |false| if the call is not
|
| - // allowed. https://crbug.com/437149
|
| + if (!scriptState->executionContext()->isWindowFocusAllowed()) {
|
| + resolver->resolve(false);
|
| + return promise;
|
| + }
|
| + scriptState->executionContext()->consumeWindowFocus();
|
|
|
| ServiceWorkerGlobalScopeClient::from(scriptState->executionContext())->focus(m_id, new CallbackPromiseAdapter<bool, ServiceWorkerError>(resolver));
|
| return promise;
|
|
|