Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / app_banner / app-banner-event-dispatch.html
blob5286e4e540d4dd965e6d27bec6863ec7e9a493ae
1 <!DOCTYPE html>
2 <script src="../resources/testharness.js"></script>
3 <script src="../resources/testharnessreport.js"></script>
4 <script>
5 var test_cases = [
7 name: 'cancel',
8 cancel: true,
9 }, {
10 name: 'accept',
11 cancel: false,
12 platform: 'foo',
13 outcome: 'accepted'
14 }, {
15 name: 'dismiss',
16 cancel: false,
17 platform: '',
18 outcome: 'dismissed'
22 function banner_test(index) {
23 if (index >= test_cases.length)
24 return;
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) {
37 e.preventDefault();
38 return;
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);
45 t.done();
46 }));
47 });
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);
54 t.done();
55 return;
57 testRunner.resolveBeforeInstallPromptPromise(index, test_case.platform);
58 }));
59 }, test_case.name);
62 banner_test(0);
63 </script>