| Index: LayoutTests/app_banner/app-banner-event-prompt.html
|
| diff --git a/LayoutTests/app_banner/app-banner-event-prompt.html b/LayoutTests/app_banner/app-banner-event-prompt.html
|
| index b5edae164c381abd3475a70c2f4f61f631bfeee5..6fed8f7732e7561a74d68c7c4c8f3a9bcdc3d187 100644
|
| --- a/LayoutTests/app_banner/app-banner-event-prompt.html
|
| +++ b/LayoutTests/app_banner/app-banner-event-prompt.html
|
| @@ -44,7 +44,7 @@ var prompt_test_cases = [
|
| ];
|
|
|
| function verify_prompt_resolve(e, t) {
|
| - e.prompt().then(function() { }, t.unreached_func("prompt() promise should resolve."));
|
| + e.prompt().then(undefined, t.unreached_func("prompt() promise should resolve."));
|
| }
|
|
|
| function verify_prompt_reject(e, t) {
|
| @@ -75,30 +75,34 @@ function verify_userChoice(e, t, test_case, index) {
|
| }), t.unreached_func("userChoice promise should resolve."));
|
| }
|
|
|
| +var events = []; // For storing the beforeinstallprompt event.
|
| function prompt_test(index) {
|
| if (index >= prompt_test_cases.length)
|
| return;
|
|
|
| var test_case = prompt_test_cases[index];
|
| async_test(function(t) {
|
| - var event = null;
|
| var event_handler = t.step_func(function(e) {
|
| // Remove the event handler to prevent it being used in subsequent
|
| // invocations of prompt_test(). Save event object for call outside handler.
|
| window.removeEventListener('beforeinstallprompt', event_handler);
|
| - event = e;
|
|
|
| assert_equals(e.platforms.length, 2, 'Number of platforms');
|
| assert_equals(e.platforms[0], 'foo', 'First platform');
|
| assert_equals(e.platforms[1], 'bar', 'Second platform');
|
|
|
| + if (test_case.cancel) {
|
| + e.preventDefault();
|
| + }
|
| +
|
| if (test_case.late) {
|
| + // Exit the handler once we've stopped the event.
|
| + events.push(e);
|
| return;
|
| }
|
|
|
| if (test_case.cancel) {
|
| - // Cancel the event, then call prompt() to restart the display pipeline.
|
| - e.preventDefault();
|
| + // Call prompt() to restart the pipeline.
|
| verify_prompt_resolve(e, t);
|
| } else {
|
| // A call to prompt() before preventDefault should reject.
|
| @@ -117,14 +121,14 @@ function prompt_test(index) {
|
|
|
| // Test that firing prompt() outside of the handler resolves or rejects correctly.
|
| if (test_case.late) {
|
| + e = events.pop();
|
| if (test_case.cancel) {
|
| - event.preventDefault();
|
| - verify_prompt_resolve(event, t);
|
| + verify_prompt_resolve(e, t);
|
| } else {
|
| - verify_prompt_reject(event, t);
|
| + verify_prompt_reject(e, t);
|
| }
|
| // Check userChoice and call the next test.
|
| - verify_userChoice(event, t, test_case, index);
|
| + verify_userChoice(e, t, test_case, index);
|
| }
|
| }, test_case.name);
|
| }
|
|
|