2 <script src=
"../resources/testharness.js"></script>
3 <script src=
"../resources/testharnessreport.js"></script>
22 function banner_test(index
) {
23 if (index
>= test_cases
.length
)
26 var test_case
= test_cases
[index
];
27 async_test(function(t
) {
28 var event_handler
= t
.step_func(function(e
) {
29 // Remove the event handler to prevent it being used in subsequent
30 // invocations of banner_test();
31 window
.removeEventListener('beforeinstallprompt', event_handler
);
33 assert_equals(e
.platforms
.length
, 2, 'Number of platforms');
34 assert_equals(e
.platforms
[0], 'foo', 'First platform');
35 assert_equals(e
.platforms
[1], 'bar', 'Second platform');
36 if (test_case
.cancel
) {
41 e
.userChoice
.then(t
.step_func(function(result
) {
42 assert_equals(result
.platform
, test_case
.platform
, 'Resolved platform');
43 assert_equals(result
.outcome
, test_case
.outcome
, 'Outcome');
44 banner_test(index
+ 1);
48 window
.addEventListener('beforeinstallprompt', event_handler
);
50 testRunner
.dispatchBeforeInstallPromptEvent(index
, ['foo', 'bar'], t
.step_func(function(result
) {
51 assert_equals(result
, test_case
.cancel
, 'Event canceled');
52 if (test_case
.cancel
) {
53 banner_test(index
+ 1);
57 testRunner
.resolveBeforeInstallPromptPromise(index
, test_case
.platform
);