aboutsummaryrefslogtreecommitdiffstats
path: root/tools/sw-push-quota.test.js
diff options
context:
space:
mode:
Diffstat (limited to 'tools/sw-push-quota.test.js')
-rw-r--r--tools/sw-push-quota.test.js27
1 files changed, 26 insertions, 1 deletions
diff --git a/tools/sw-push-quota.test.js b/tools/sw-push-quota.test.js
index 544c72e..798b913 100644
--- a/tools/sw-push-quota.test.js
+++ b/tools/sw-push-quota.test.js
@@ -82,8 +82,33 @@ test('elsewhere: quiet stays quiet', async () => {
let asked = 0;
respond = async () => { asked++; return true; };
expect(await push(nwc)).toEqual([]);
- expect(asked).toBe(0); // the open (if hidden) window answers on Android
+ expect(asked).toBe(0); // on a computer the open (if hidden) window answers
windows = [];
respond = async () => false;
expect(await push(nwc)).toEqual(['Spend request']);
});
+
+// An Android phone freezes an app behind another one, minutes in: its relay
+// sockets are dead and the worker's nudge sits unread until it is opened, so
+// a zap sent from another app spun until then (wake to payment: 15 s at the
+// median on Android, 2026-11-10). On a phone only a window on screen is
+// handed the request; behind another app, the worker answers (and nudges the
+// window anyway — the request's lock decides if it is still awake).
+test('an Android phone: the app behind another one does not swallow the request', async () => {
+ endpoint = 'https://fcm.googleapis.com/fcm/send/abc';
+ self.navigator = { userAgent: 'Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/155.0.0.0 Mobile Safari/537.36' };
+ try {
+ let asked = 0, nudged = 0;
+ respond = async () => { asked++; return true; };
+ windows = [{ visibilityState: 'hidden', postMessage: () => { nudged++; } }];
+ expect(await push(nwc)).toEqual([]);
+ expect(asked).toBe(1);
+ expect(nudged).toBe(1);
+ // on screen, it answers itself with everything it knows
+ asked = 0; nudged = 0;
+ windows = [{ visibilityState: 'visible', postMessage: () => { nudged++; } }];
+ expect(await push(nwc)).toEqual([]);
+ expect(asked).toBe(0);
+ expect(nudged).toBe(1);
+ } finally { delete self.navigator; }
+});