Ship Notification action buttons by default
Intent to ship:
https://groups.google.com/a/chromium.org/d/topic/blink-dev/8iSlPpwokbY/discussion
BUG=513671,513672,548297
Review URL: https://codereview.chromium.org/1412223007
Cr-Commit-Position: refs/heads/master@{#358304}
diff --git a/third_party/WebKit/LayoutTests/virtual/stable/http/tests/serviceworker/webexposed/global-interface-listing-service-worker-expected.txt b/third_party/WebKit/LayoutTests/virtual/stable/http/tests/serviceworker/webexposed/global-interface-listing-service-worker-expected.txt
index d8b897b..48d165e3 100644
--- a/third_party/WebKit/LayoutTests/virtual/stable/http/tests/serviceworker/webexposed/global-interface-listing-service-worker-expected.txt
+++ b/third_party/WebKit/LayoutTests/virtual/stable/http/tests/serviceworker/webexposed/global-interface-listing-service-worker-expected.txt
@@ -381,6 +381,7 @@
method start
setter onmessage
interface Notification : EventTarget
+ static getter maxActions
static getter permission
getter body
getter data
diff --git a/third_party/WebKit/LayoutTests/virtual/stable/webexposed/global-interface-listing-dedicated-worker-expected.txt b/third_party/WebKit/LayoutTests/virtual/stable/webexposed/global-interface-listing-dedicated-worker-expected.txt
index e096619..886ce38 100644
--- a/third_party/WebKit/LayoutTests/virtual/stable/webexposed/global-interface-listing-dedicated-worker-expected.txt
+++ b/third_party/WebKit/LayoutTests/virtual/stable/webexposed/global-interface-listing-dedicated-worker-expected.txt
@@ -379,6 +379,7 @@
[Worker] method start
[Worker] setter onmessage
[Worker] interface Notification : EventTarget
+[Worker] static getter maxActions
[Worker] static getter permission
[Worker] getter body
[Worker] getter data
diff --git a/third_party/WebKit/LayoutTests/virtual/stable/webexposed/global-interface-listing-expected.txt b/third_party/WebKit/LayoutTests/virtual/stable/webexposed/global-interface-listing-expected.txt
index 12b0967..e26f5d4 100644
--- a/third_party/WebKit/LayoutTests/virtual/stable/webexposed/global-interface-listing-expected.txt
+++ b/third_party/WebKit/LayoutTests/virtual/stable/webexposed/global-interface-listing-expected.txt
@@ -3095,6 +3095,7 @@
method constructor
method item
interface Notification : EventTarget
+ static getter maxActions
static getter permission
static method requestPermission
getter body
diff --git a/third_party/WebKit/LayoutTests/virtual/stable/webexposed/global-interface-listing-shared-worker-expected.txt b/third_party/WebKit/LayoutTests/virtual/stable/webexposed/global-interface-listing-shared-worker-expected.txt
index c832f54..9af80ab 100644
--- a/third_party/WebKit/LayoutTests/virtual/stable/webexposed/global-interface-listing-shared-worker-expected.txt
+++ b/third_party/WebKit/LayoutTests/virtual/stable/webexposed/global-interface-listing-shared-worker-expected.txt
@@ -369,6 +369,7 @@
[Worker] method start
[Worker] setter onmessage
[Worker] interface Notification : EventTarget
+[Worker] static getter maxActions
[Worker] static getter permission
[Worker] getter body
[Worker] getter data
diff --git a/third_party/WebKit/Source/modules/notifications/Notification.idl b/third_party/WebKit/Source/modules/notifications/Notification.idl
index 38297e7..b985e3db 100644
--- a/third_party/WebKit/Source/modules/notifications/Notification.idl
+++ b/third_party/WebKit/Source/modules/notifications/Notification.idl
@@ -53,7 +53,7 @@
[CallWith=ScriptState, Exposed=Window, MeasureAs=NotificationPermissionRequested] static Promise<NotificationPermission> requestPermission(optional NotificationPermissionCallback deprecatedCallback);
- [RuntimeEnabled=NotificationExperimental] static readonly attribute unsigned long maxActions;
+ static readonly attribute unsigned long maxActions;
attribute EventHandler onclick;
[MeasureAs=NotificationShowEvent] attribute EventHandler onshow;
@@ -72,7 +72,9 @@
readonly attribute boolean requireInteraction;
[CallWith=ScriptState, SameObject] readonly attribute any data;
- // TODO(johnme): The spec requires a FrozenArray, but sequence seems to behave like one already?! https://crbug.com/515920
+ // TODO(johnme): Ship once Blink supports FrozenArray (https://crbug.com/515920)
+ // and we've implemented the additional Object.freeze described in
+ // https://notifications.spec.whatwg.org/#dom-notification-actions
[RuntimeEnabled=NotificationExperimental] readonly attribute sequence<NotificationAction> actions;
[MeasureAs=NotificationClosed] void close();
diff --git a/third_party/WebKit/Source/modules/notifications/NotificationData.cpp b/third_party/WebKit/Source/modules/notifications/NotificationData.cpp
index 34b697d9..4052706 100644
--- a/third_party/WebKit/Source/modules/notifications/NotificationData.cpp
+++ b/third_party/WebKit/Source/modules/notifications/NotificationData.cpp
@@ -71,35 +71,32 @@
webData.data = serializedData;
}
- // Ignore experimental NotificationOptions members if the flag is not set.
- if (RuntimeEnabledFeatures::notificationExperimentalEnabled()) {
- Vector<WebNotificationAction> actions;
+ Vector<WebNotificationAction> actions;
- const size_t maxActions = Notification::maxActions();
- for (const NotificationAction& action : options.actions()) {
- if (action.action().isEmpty()) {
- exceptionState.throwTypeError("NotificationAction `action` must not be empty.");
- return WebNotificationData();
- }
-
- if (action.title().isEmpty()) {
- exceptionState.throwTypeError("NotificationAction `title` must not be empty.");
- return WebNotificationData();
- }
-
- if (actions.size() >= maxActions)
- continue;
-
- WebNotificationAction webAction;
- webAction.action = action.action();
- webAction.title = action.title();
-
- actions.append(webAction);
+ const size_t maxActions = Notification::maxActions();
+ for (const NotificationAction& action : options.actions()) {
+ if (action.action().isEmpty()) {
+ exceptionState.throwTypeError("NotificationAction `action` must not be empty.");
+ return WebNotificationData();
}
- webData.actions = actions;
+ if (action.title().isEmpty()) {
+ exceptionState.throwTypeError("NotificationAction `title` must not be empty.");
+ return WebNotificationData();
+ }
+
+ if (actions.size() >= maxActions)
+ continue;
+
+ WebNotificationAction webAction;
+ webAction.action = action.action();
+ webAction.title = action.title();
+
+ actions.append(webAction);
}
+ webData.actions = actions;
+
return webData;
}
diff --git a/third_party/WebKit/Source/modules/notifications/NotificationOptions.idl b/third_party/WebKit/Source/modules/notifications/NotificationOptions.idl
index 3047c296..feba5b0e 100644
--- a/third_party/WebKit/Source/modules/notifications/NotificationOptions.idl
+++ b/third_party/WebKit/Source/modules/notifications/NotificationOptions.idl
@@ -21,5 +21,5 @@
boolean silent = false;
boolean requireInteraction = false;
any data = null;
- [RuntimeEnabled=NotificationExperimental] sequence<NotificationAction> actions = [];
+ sequence<NotificationAction> actions = [];
};