Return the userChoice promise from beforeinstallpromptevent.prompt().

This corrects a spec violation in the implementation of
beforeinstallpromptevent, where the prompt() method was not returning
the event's userChoice promise. Web tests are updated to test this.

BUG=965939

Change-Id: I6e1bd2f83a287d4e7888a873984760bdecab0161
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1626444
Commit-Queue: Mounir Lamouri <mlamouri@chromium.org>
Auto-Submit: Dominick Ng <dominickn@chromium.org>
Reviewed-by: Mounir Lamouri <mlamouri@chromium.org>
Cr-Commit-Position: refs/heads/master@{#662659}
diff --git a/third_party/blink/renderer/modules/app_banner/before_install_prompt_event.cc b/third_party/blink/renderer/modules/app_banner/before_install_prompt_event.cc
index 7b50354..39484a1 100644
--- a/third_party/blink/renderer/modules/app_banner/before_install_prompt_event.cc
+++ b/third_party/blink/renderer/modules/app_banner/before_install_prompt_event.cc
@@ -97,7 +97,7 @@
 
   UseCounter::Count(context, WebFeature::kBeforeInstallPromptEventPrompt);
   banner_service_->DisplayAppBanner();
-  return ScriptPromise::CastUndefined(script_state);
+  return user_choice_->Promise(script_state->World());
 }
 
 const AtomicString& BeforeInstallPromptEvent::InterfaceName() const {
diff --git a/third_party/blink/web_tests/app_banner/app-banner-event-prompt.html b/third_party/blink/web_tests/app_banner/app-banner-event-prompt.html
index 16beb46..677cb7b 100644
--- a/third_party/blink/web_tests/app_banner/app-banner-event-prompt.html
+++ b/third_party/blink/web_tests/app_banner/app-banner-event-prompt.html
@@ -108,9 +108,11 @@
     }
 ];
 
-function verify_prompt_resolve(e, t) {
-    callWithKeyDown(() => e.prompt().then(
-        function() { }, t.unreached_func("prompt() promise should resolve.")));
+function verify_prompt_resolve(e, t, test_case) {
+    callWithKeyDown(() => e.prompt().then(t.step_func(function(result) {
+        assert_equals(result.platform, test_case.platform, 'Resolved platform');
+        assert_equals(result.outcome, test_case.outcome, 'Outcome');
+    }), t.unreached_func("prompt() promise should resolve.")));
 }
 
 function verify_prompt_reject(e, t) {
@@ -170,7 +172,7 @@
                     assert_false(event == null, "event is null outside handler");
 
                     // Test that firing prompt() outside of the handler resolves or rejects correctly.
-                    verify_prompt_resolve(event, t);
+                    verify_prompt_resolve(event, t, test_case);
                     // Check userChoice and call the next test.
                     verify_userChoice(event, t, test_case, index);
                 }, 0);
@@ -181,7 +183,7 @@
             verify_prompt_reject(e, t);
 
             // Call prompt() to restart the pipeline.
-            verify_prompt_resolve(e, t);
+            verify_prompt_resolve(e, t, test_case);
 
             // prompt() has been fired, so check the userChoice promise and call the next test.
             verify_userChoice(e, t, test_case, index);