Add showTrigger to Notification properties.

Bug: 891339
Change-Id: I76dc38e26dd359c656e16910dfb1d317e2f64528
Reviewed-on: https://chromium-review.googlesource.com/c/1470691
Commit-Queue: Richard Knoll <knollr@chromium.org>
Reviewed-by: Yuki Shiino <yukishiino@chromium.org>
Reviewed-by: Kentaro Hara <haraken@chromium.org>
Reviewed-by: Peter Beverloo <peter@chromium.org>
Cr-Commit-Position: refs/heads/master@{#636068}
diff --git a/third_party/blink/renderer/modules/notifications/notification.cc b/third_party/blink/renderer/modules/notifications/notification.cc
index f06c3c8..6b8a74b 100644
--- a/third_party/blink/renderer/modules/notifications/notification.cc
+++ b/third_party/blink/renderer/modules/notifications/notification.cc
@@ -166,7 +166,12 @@
       prepare_show_timer_(context->GetTaskRunner(TaskType::kMiscPlatformAPI),
                           this,
                           &Notification::PrepareShow),
-      listener_binding_(this) {}
+      listener_binding_(this) {
+  if (data_->show_trigger_timestamp.has_value()) {
+    show_trigger_ = TimestampTrigger::Create(static_cast<DOMTimeStamp>(
+        data_->show_trigger_timestamp.value().ToJsTime()));
+  }
+}
 
 Notification::~Notification() = default;
 
@@ -494,6 +499,7 @@
 }
 
 void Notification::Trace(blink::Visitor* visitor) {
+  visitor->Trace(show_trigger_);
   visitor->Trace(loader_);
   EventTargetWithInlineData::Trace(visitor);
   ContextLifecycleObserver::Trace(visitor);
diff --git a/third_party/blink/renderer/modules/notifications/notification.h b/third_party/blink/renderer/modules/notifications/notification.h
index f204b99..e9dac05 100644
--- a/third_party/blink/renderer/modules/notifications/notification.h
+++ b/third_party/blink/renderer/modules/notifications/notification.h
@@ -55,6 +55,7 @@
 class NotificationResourcesLoader;
 class ScriptState;
 class V8NotificationPermissionCallback;
+class TimestampTrigger;
 
 class MODULES_EXPORT Notification final
     : public EventTargetWithInlineData,
@@ -117,6 +118,7 @@
   bool requireInteraction() const;
   ScriptValue data(ScriptState* script_state);
   Vector<v8::Local<v8::Value>> actions(ScriptState* script_state) const;
+  TimestampTrigger* showTrigger() const { return show_trigger_; }
 
   static String PermissionString(mojom::blink::PermissionStatus permission);
   static String permission(ExecutionContext* context);
@@ -180,6 +182,8 @@
 
   mojom::blink::NotificationDataPtr data_;
 
+  Member<TimestampTrigger> show_trigger_;
+
   String notification_id_;
 
   String token_;
diff --git a/third_party/blink/renderer/modules/notifications/notification.idl b/third_party/blink/renderer/modules/notifications/notification.idl
index dd81645c..6d358f68 100644
--- a/third_party/blink/renderer/modules/notifications/notification.idl
+++ b/third_party/blink/renderer/modules/notifications/notification.idl
@@ -76,6 +76,7 @@
     readonly attribute boolean requireInteraction;
     [CallWith=ScriptState, SameObject, SaveSameObject] readonly attribute any data;
     [CallWith=ScriptState, SameObject, SaveSameObject] readonly attribute FrozenArray<NotificationAction> actions;
+    [RuntimeEnabled=NotificationTriggers, SameObject] readonly attribute TimestampTrigger showTrigger;
 
     [MeasureAs=NotificationClosed] void close();
 };
diff --git a/third_party/blink/web_tests/http/tests/notifications/serviceworker-notification-properties.html b/third_party/blink/web_tests/http/tests/notifications/serviceworker-notification-properties.html
index 3a6ebc3e..e83c00e 100644
--- a/third_party/blink/web_tests/http/tests/notifications/serviceworker-notification-properties.html
+++ b/third_party/blink/web_tests/http/tests/notifications/serviceworker-notification-properties.html
@@ -110,6 +110,7 @@
               assert_equals(notifications[0].data, notifications[0].data, '`data` attribute equality');
               assert_equals(notifications[0].vibrate, notifications[0].vibrate, '`vibrate` attribute equality');
 
+              assert_equals(notifications[0].showTrigger, notifications[0].showTrigger, '`showTrigger` attribute equality');
               test.done();
           }).catch(unreached_rejection(test));
 
diff --git a/third_party/blink/web_tests/http/tests/serviceworker/webexposed/global-interface-listing-service-worker-expected.txt b/third_party/blink/web_tests/http/tests/serviceworker/webexposed/global-interface-listing-service-worker-expected.txt
index 07a47508..3973084 100644
--- a/third_party/blink/web_tests/http/tests/serviceworker/webexposed/global-interface-listing-service-worker-expected.txt
+++ b/third_party/blink/web_tests/http/tests/serviceworker/webexposed/global-interface-listing-service-worker-expected.txt
@@ -835,6 +835,7 @@
     getter onshow
     getter renotify
     getter requireInteraction
+    getter showTrigger
     getter silent
     getter tag
     getter timestamp
diff --git a/third_party/blink/web_tests/webexposed/global-interface-listing-dedicated-worker-expected.txt b/third_party/blink/web_tests/webexposed/global-interface-listing-dedicated-worker-expected.txt
index 78f612d..591cf7c2 100644
--- a/third_party/blink/web_tests/webexposed/global-interface-listing-dedicated-worker-expected.txt
+++ b/third_party/blink/web_tests/webexposed/global-interface-listing-dedicated-worker-expected.txt
@@ -789,6 +789,7 @@
 [Worker]     getter onshow
 [Worker]     getter renotify
 [Worker]     getter requireInteraction
+[Worker]     getter showTrigger
 [Worker]     getter silent
 [Worker]     getter tag
 [Worker]     getter timestamp
diff --git a/third_party/blink/web_tests/webexposed/global-interface-listing-expected.txt b/third_party/blink/web_tests/webexposed/global-interface-listing-expected.txt
index 0dc833f..29e7d7e 100644
--- a/third_party/blink/web_tests/webexposed/global-interface-listing-expected.txt
+++ b/third_party/blink/web_tests/webexposed/global-interface-listing-expected.txt
@@ -4962,6 +4962,7 @@
     getter onshow
     getter renotify
     getter requireInteraction
+    getter showTrigger
     getter silent
     getter tag
     getter timestamp
diff --git a/third_party/blink/web_tests/webexposed/global-interface-listing-shared-worker-expected.txt b/third_party/blink/web_tests/webexposed/global-interface-listing-shared-worker-expected.txt
index 0823a1e..22af926 100644
--- a/third_party/blink/web_tests/webexposed/global-interface-listing-shared-worker-expected.txt
+++ b/third_party/blink/web_tests/webexposed/global-interface-listing-shared-worker-expected.txt
@@ -774,6 +774,7 @@
 [Worker]     getter onshow
 [Worker]     getter renotify
 [Worker]     getter requireInteraction
+[Worker]     getter showTrigger
 [Worker]     getter silent
 [Worker]     getter tag
 [Worker]     getter timestamp