blob: 3022744e7cf6782de1dfd03685c2aa6b68294ea1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
import { Module } from "chrome://remote/content/shared/messagehandler/Module.sys.mjs";
// Store counters in the JSM scope to persist them across reloads.
let callsToBlockedOneTime = 0;
let callsToBlockedTenTimes = 0;
let callsToBlockedElevenTimes = 0;
// This module provides various commands which all hang for various reasons.
// The test is supposed to trigger the command and then destroy the
// JSWindowActor pair by any mean (eg a navigation) in order to trigger an
// AbortError and a retry.
class RetryModule extends Module {
destroy() {}
/**
* Commands
*/
// Resolves only if called while on the example.net domain.
async blockedOnNetDomain(params) {
// Note: we do not store a call counter here, because this is used for a
// cross-group navigation test, and the JSM will be loaded in different
// processes.
const uri = this.messageHandler.window.document.baseURI;
if (!uri.includes("example.net")) {
await new Promise(() => {});
}
return { ...params };
}
// Resolves only if called more than once.
async blockedOneTime(params) {
callsToBlockedOneTime++;
if (callsToBlockedOneTime < 2) {
await new Promise(() => {});
}
// Return:
// - params sent to the command to check that retries have correct params
// - the call counter
return { ...params, callsToCommand: callsToBlockedOneTime };
}
// Resolves only if called more than ten times (which is exactly the maximum
// of retry attempts).
async blockedTenTimes(params) {
callsToBlockedTenTimes++;
if (callsToBlockedTenTimes < 11) {
await new Promise(() => {});
}
// Return:
// - params sent to the command to check that retries have correct params
// - the call counter
return { ...params, callsToCommand: callsToBlockedTenTimes };
}
// Resolves only if called more than eleven times (which is greater than the
// maximum of retry attempts).
async blockedElevenTimes(params) {
callsToBlockedElevenTimes++;
if (callsToBlockedElevenTimes < 12) {
await new Promise(() => {});
}
// Return:
// - params sent to the command to check that retries have correct params
// - the call counter
return { ...params, callsToCommand: callsToBlockedElevenTimes };
}
cleanup() {
callsToBlockedOneTime = 0;
callsToBlockedTenTimes = 0;
callsToBlockedElevenTimes = 0;
}
}
export const retry = RetryModule;
|