Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1656)

Unified Diff: Source/modules/notifications/Notification.cpp

Issue 923443005: Disallow constructing the Notification object in a Service Worker. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: comments Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « LayoutTests/http/tests/notifications/serviceworker-throw-constructor.html ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/modules/notifications/Notification.cpp
diff --git a/Source/modules/notifications/Notification.cpp b/Source/modules/notifications/Notification.cpp
index 4fbf7eb9b9f1481742549890101193ebfc5d26f2..f61571ffe22da3888280c12f1075650bf822ca5f 100644
--- a/Source/modules/notifications/Notification.cpp
+++ b/Source/modules/notifications/Notification.cpp
@@ -66,6 +66,12 @@ Notification* Notification::create(ExecutionContext* context, const String& titl
return nullptr;
}
+ // The Web Notification constructor may not be used in Service Worker contexts.
+ if (context->isServiceWorkerGlobalScope()) {
+ exceptionState.throwTypeError("Illegal constructor.");
+ return nullptr;
+ }
+
Notification* notification = new Notification(title, context);
notification->setBody(options.body());
« no previous file with comments | « LayoutTests/http/tests/notifications/serviceworker-throw-constructor.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698