diff options
Diffstat (limited to 'third_party/WebKit/Source')
7 files changed, 14 insertions, 127 deletions
diff --git a/third_party/WebKit/Source/modules/modules.gypi b/third_party/WebKit/Source/modules/modules.gypi index 69196df..b06446c 100644 --- a/third_party/WebKit/Source/modules/modules.gypi +++ b/third_party/WebKit/Source/modules/modules.gypi @@ -1967,7 +1967,6 @@ 'mediastream/RTCDataChannelTest.cpp', 'notifications/NotificationDataTest.cpp', 'presentation/PresentationAvailabilityTest.cpp', - 'push_messaging/PushManagerTest.cpp', 'push_messaging/PushMessageDataTest.cpp', 'serviceworkers/ServiceWorkerContainerTest.cpp', 'webaudio/AudioBasicProcessorHandlerTest.cpp', diff --git a/third_party/WebKit/Source/modules/push_messaging/PushManager.cpp b/third_party/WebKit/Source/modules/push_messaging/PushManager.cpp index 7d5eacd..0f5a2ff 100644 --- a/third_party/WebKit/Source/modules/push_messaging/PushManager.cpp +++ b/third_party/WebKit/Source/modules/push_messaging/PushManager.cpp @@ -34,29 +34,11 @@ WebPushProvider* pushProvider() return webPushProvider; } -String bufferSourceToString(const ArrayBufferOrArrayBufferView& applicationServerKey, ExceptionState& exceptionState) +WebPushSubscriptionOptions toWebPushSubscriptionOptions(const PushSubscriptionOptions& options) { - // Check the validity of the sender info. It must be a 65 byte unencrypted key, - // which has the byte 0x04 as the first byte as a marker. - char* input; - int length; - if (applicationServerKey.isArrayBuffer()) { - input = static_cast<char*>( - applicationServerKey.getAsArrayBuffer()->data()); - length = applicationServerKey.getAsArrayBuffer()->byteLength(); - } else if (applicationServerKey.isArrayBufferView()) { - input = static_cast<char*>( - applicationServerKey.getAsArrayBufferView()->buffer()->data()); - length = applicationServerKey.getAsArrayBufferView()->buffer()->byteLength(); - } else { - ASSERT_NOT_REACHED(); - return String(); - } - - if (length == 65 && input[0] == 0x04) - return WebString::fromUTF8(input, length); - exceptionState.throwDOMException(InvalidAccessError, "The provided applicationServerKey is not valid."); - return String(); + WebPushSubscriptionOptions webOptions; + webOptions.userVisibleOnly = options.userVisibleOnly(); + return webOptions; } } // namespace @@ -67,26 +49,11 @@ PushManager::PushManager(ServiceWorkerRegistration* registration) ASSERT(registration); } -WebPushSubscriptionOptions PushManager::toWebPushSubscriptionOptions(const PushSubscriptionOptions& options, ExceptionState& exceptionState) -{ - WebPushSubscriptionOptions webOptions; - webOptions.userVisibleOnly = options.userVisibleOnly(); - if (options.hasApplicationServerKey()) { - webOptions.applicationServerKey = bufferSourceToString(options.applicationServerKey(), - exceptionState); - } - return webOptions; -} - -ScriptPromise PushManager::subscribe(ScriptState* scriptState, const PushSubscriptionOptions& options, ExceptionState& exceptionState) +ScriptPromise PushManager::subscribe(ScriptState* scriptState, const PushSubscriptionOptions& options) { if (!m_registration->active()) return ScriptPromise::rejectWithDOMException(scriptState, DOMException::create(AbortError, "Subscription failed - no active Service Worker")); - const WebPushSubscriptionOptions& webOptions = toWebPushSubscriptionOptions(options, exceptionState); - if (exceptionState.hadException()) - return ScriptPromise(); - ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState); ScriptPromise promise = resolver->promise(); @@ -97,9 +64,9 @@ ScriptPromise PushManager::subscribe(ScriptState* scriptState, const PushSubscri Document* document = toDocument(scriptState->executionContext()); if (!document->domWindow() || !document->frame()) return ScriptPromise::rejectWithDOMException(scriptState, DOMException::create(InvalidStateError, "Document is detached from window.")); - PushController::clientFrom(document->frame()).subscribe(m_registration->webRegistration(), webOptions, new PushSubscriptionCallbacks(resolver, m_registration)); + PushController::clientFrom(document->frame()).subscribe(m_registration->webRegistration(), toWebPushSubscriptionOptions(options), new PushSubscriptionCallbacks(resolver, m_registration)); } else { - pushProvider()->subscribe(m_registration->webRegistration(), webOptions, new PushSubscriptionCallbacks(resolver, m_registration)); + pushProvider()->subscribe(m_registration->webRegistration(), toWebPushSubscriptionOptions(options), new PushSubscriptionCallbacks(resolver, m_registration)); } return promise; @@ -114,7 +81,7 @@ ScriptPromise PushManager::getSubscription(ScriptState* scriptState) return promise; } -ScriptPromise PushManager::permissionState(ScriptState* scriptState, const PushSubscriptionOptions& options, ExceptionState& exceptionState) +ScriptPromise PushManager::permissionState(ScriptState* scriptState, const PushSubscriptionOptions& options) { if (scriptState->executionContext()->isDocument()) { Document* document = toDocument(scriptState->executionContext()); @@ -125,7 +92,7 @@ ScriptPromise PushManager::permissionState(ScriptState* scriptState, const PushS ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState); ScriptPromise promise = resolver->promise(); - pushProvider()->getPermissionStatus(m_registration->webRegistration(), toWebPushSubscriptionOptions(options, exceptionState), new PushPermissionStatusCallbacks(resolver)); + pushProvider()->getPermissionStatus(m_registration->webRegistration(), toWebPushSubscriptionOptions(options), new PushPermissionStatusCallbacks(resolver)); return promise; } diff --git a/third_party/WebKit/Source/modules/push_messaging/PushManager.h b/third_party/WebKit/Source/modules/push_messaging/PushManager.h index a4c0729..d6d9cfd 100644 --- a/third_party/WebKit/Source/modules/push_messaging/PushManager.h +++ b/third_party/WebKit/Source/modules/push_messaging/PushManager.h @@ -6,20 +6,16 @@ #define PushManager_h #include "bindings/core/v8/ScriptWrappable.h" -#include "bindings/modules/v8/UnionTypesModules.h" -#include "modules/ModulesExport.h" #include "platform/heap/Handle.h" namespace blink { -class ExceptionState; class PushSubscriptionOptions; class ScriptPromise; class ScriptState; class ServiceWorkerRegistration; -struct WebPushSubscriptionOptions; -class MODULES_EXPORT PushManager final : public GarbageCollected<PushManager>, public ScriptWrappable { +class PushManager final : public GarbageCollected<PushManager>, public ScriptWrappable { DEFINE_WRAPPERTYPEINFO(); public: static PushManager* create(ServiceWorkerRegistration* registration) @@ -27,17 +23,12 @@ public: return new PushManager(registration); } - ScriptPromise subscribe(ScriptState*, const PushSubscriptionOptions&, - ExceptionState&); + ScriptPromise subscribe(ScriptState*, const PushSubscriptionOptions&); ScriptPromise getSubscription(ScriptState*); - ScriptPromise permissionState(ScriptState*, const PushSubscriptionOptions&, - ExceptionState&); + ScriptPromise permissionState(ScriptState*, const PushSubscriptionOptions&); DECLARE_TRACE(); - static WebPushSubscriptionOptions toWebPushSubscriptionOptions( - const PushSubscriptionOptions&, ExceptionState&); - private: explicit PushManager(ServiceWorkerRegistration*); diff --git a/third_party/WebKit/Source/modules/push_messaging/PushManager.idl b/third_party/WebKit/Source/modules/push_messaging/PushManager.idl index 0c4ff864..ddb6139 100644 --- a/third_party/WebKit/Source/modules/push_messaging/PushManager.idl +++ b/third_party/WebKit/Source/modules/push_messaging/PushManager.idl @@ -9,7 +9,7 @@ GarbageCollected, RuntimeEnabled=PushMessaging, ] interface PushManager { - [CallWith=ScriptState, RaisesException] Promise<PushSubscription> subscribe(optional PushSubscriptionOptions options); + [CallWith=ScriptState] Promise<PushSubscription> subscribe(optional PushSubscriptionOptions options); [CallWith=ScriptState] Promise<PushSubscription?> getSubscription(); - [CallWith=ScriptState, RaisesException] Promise permissionState(optional PushSubscriptionOptions options); + [CallWith=ScriptState] Promise permissionState(optional PushSubscriptionOptions options); }; diff --git a/third_party/WebKit/Source/modules/push_messaging/PushManagerTest.cpp b/third_party/WebKit/Source/modules/push_messaging/PushManagerTest.cpp deleted file mode 100644 index e5e7f8f..0000000 --- a/third_party/WebKit/Source/modules/push_messaging/PushManagerTest.cpp +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright 2016 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "modules/push_messaging/PushManager.h" - -#include "bindings/modules/v8/UnionTypesModules.h" -#include "core/dom/DOMArrayBuffer.h" -#include "modules/push_messaging/PushSubscriptionOptions.h" -#include "public/platform/WebString.h" -#include "public/platform/modules/push_messaging/WebPushSubscriptionOptions.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace blink { -namespace { - -const char kValidKeyMarker = 0x04; -const unsigned kValidKeyLength = 65; - -TEST(PushManagerTest, ValidSenderKey) -{ - uint8_t senderKey[kValidKeyLength]; - memset(senderKey, 0, sizeof(senderKey)); - senderKey[0] = kValidKeyMarker; - PushSubscriptionOptions options; - options.setApplicationServerKey( - ArrayBufferOrArrayBufferView::fromArrayBuffer( - DOMArrayBuffer::create(senderKey, kValidKeyLength))); - - TrackExceptionState exceptionState; - WebPushSubscriptionOptions output = PushManager::toWebPushSubscriptionOptions(options, exceptionState); - EXPECT_FALSE(exceptionState.hadException()); - EXPECT_EQ(output.applicationServerKey.length(), kValidKeyLength); - EXPECT_EQ(output.applicationServerKey, WebString::fromUTF8(reinterpret_cast<const char*>(senderKey), kValidKeyLength)); -} - -TEST(PushManagerTest, InvalidSenderKeyMarker) -{ - uint8_t senderKey[kValidKeyLength]; - memset(senderKey, 0, sizeof(senderKey)); - senderKey[0] = 0x05; - PushSubscriptionOptions options; - options.setApplicationServerKey( - ArrayBufferOrArrayBufferView::fromArrayBuffer( - DOMArrayBuffer::create(senderKey, kValidKeyLength))); - - TrackExceptionState exceptionState; - WebPushSubscriptionOptions output = PushManager::toWebPushSubscriptionOptions(options, exceptionState); - EXPECT_TRUE(exceptionState.hadException()); -} - -TEST(PushManagerTest, InvalidSenderKeyLength) -{ - uint8_t senderKey[kValidKeyLength - 1]; - memset(senderKey, 0, sizeof(senderKey)); - senderKey[0] = kValidKeyMarker; - PushSubscriptionOptions options; - options.setApplicationServerKey( - ArrayBufferOrArrayBufferView::fromArrayBuffer( - DOMArrayBuffer::create(senderKey, kValidKeyLength - 1))); - - TrackExceptionState exceptionState; - WebPushSubscriptionOptions output = PushManager::toWebPushSubscriptionOptions(options, exceptionState); - EXPECT_TRUE(exceptionState.hadException()); -} - -} // namespace -} // namespace blink diff --git a/third_party/WebKit/Source/modules/push_messaging/PushSubscriptionOptions.idl b/third_party/WebKit/Source/modules/push_messaging/PushSubscriptionOptions.idl index 48af6cc..f034242 100644 --- a/third_party/WebKit/Source/modules/push_messaging/PushSubscriptionOptions.idl +++ b/third_party/WebKit/Source/modules/push_messaging/PushSubscriptionOptions.idl @@ -6,5 +6,4 @@ dictionary PushSubscriptionOptions { boolean userVisibleOnly = false; - [RuntimeEnabled=PushSubscriptionRestrictions] BufferSource applicationServerKey; }; diff --git a/third_party/WebKit/Source/platform/RuntimeEnabledFeatures.in b/third_party/WebKit/Source/platform/RuntimeEnabledFeatures.in index bd06d46..8a0bcf0 100644 --- a/third_party/WebKit/Source/platform/RuntimeEnabledFeatures.in +++ b/third_party/WebKit/Source/platform/RuntimeEnabledFeatures.in @@ -151,7 +151,6 @@ PresentationReceiver status=test PromiseRejectionEvent status=stable PushMessaging status=stable PushMessagingData status=stable -PushSubscriptionRestrictions status=experimental QuotaPromise status=experimental ReducedReferrerGranularity RenderingPipelineThrottling status=experimental |