Commit 55fc2a9
mediawiki.requestIdleCallback: Implement timeRemaining()
This matches the native API. This allows callers to better batch and spread out
expensive operations based on actual execution speed.
Right now CentralNotice is manually creating arbitrarily sized batches in
kvStoreMaintenance. Instead this can use a while loop with timeRemaining()
to run as quickly as possible whilst still being able to stop and yield when
it runs for too long. This way will naturally take more iterations on slow
devices and less iterations on faster ones - to be least disruptive.
While timeRemaining() is already available in the native interface,
it was previously unsafe to call because the fallback didn't implement it.
* Remove redundant QUnit.test() expect numbers.
* Add a test for the native one if available. This will catch silly mistakes
like assigning the native one to mw.requestIdleCallback directly that result
in 'Uncaught TypeError: Illegal invocation' due to missing call context.
Change-Id: I9721fab9e89c561e31101b5556a37484313535481 parent 337bf08 commit 55fc2a9
File tree
2 files changed
+65
-98
lines changed- resources/src/mediawiki
- tests/qunit/suites/resources/mediawiki
2 files changed
+65
-98
lines changedLines changed: 13 additions & 32 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 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 | | - | |
| 6 | + | |
| 7 | + | |
31 | 8 | | |
32 | 9 | | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
37 | 19 | | |
38 | 20 | | |
39 | 21 | | |
| |||
43 | 25 | | |
44 | 26 | | |
45 | 27 | | |
46 | | - | |
47 | | - | |
48 | | - | |
| 28 | + | |
| 29 | + | |
49 | 30 | | |
50 | 31 | | |
Lines changed: 52 additions & 66 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
5 | | - | |
| 4 | + | |
6 | 5 | | |
7 | | - | |
8 | | - | |
9 | | - | |
10 | | - | |
11 | 6 | | |
12 | | - | |
| 7 | + | |
13 | 8 | | |
14 | 9 | | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
21 | 16 | | |
22 | 17 | | |
23 | 18 | | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
| 19 | + | |
| 20 | + | |
28 | 21 | | |
29 | 22 | | |
30 | 23 | | |
31 | | - | |
32 | 24 | | |
33 | 25 | | |
34 | | - | |
35 | 26 | | |
36 | | - | |
37 | 27 | | |
38 | | - | |
39 | | - | |
40 | 28 | | |
41 | 29 | | |
42 | | - | |
43 | 30 | | |
44 | 31 | | |
45 | 32 | | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
| 33 | + | |
| 34 | + | |
56 | 35 | | |
57 | 36 | | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
| 37 | + | |
| 38 | + | |
64 | 39 | | |
65 | 40 | | |
66 | 41 | | |
67 | | - | |
68 | 42 | | |
69 | 43 | | |
70 | 44 | | |
71 | 45 | | |
72 | 46 | | |
73 | | - | |
74 | 47 | | |
75 | 48 | | |
76 | 49 | | |
77 | 50 | | |
78 | 51 | | |
79 | | - | |
80 | 52 | | |
81 | 53 | | |
82 | 54 | | |
83 | | - | |
| 55 | + | |
84 | 56 | | |
85 | 57 | | |
86 | 58 | | |
87 | | - | |
| 59 | + | |
88 | 60 | | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | 61 | | |
94 | 62 | | |
95 | | - | |
96 | | - | |
97 | | - | |
98 | | - | |
| 63 | + | |
99 | 64 | | |
100 | | - | |
101 | | - | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | | - | |
106 | | - | |
107 | | - | |
108 | | - | |
109 | | - | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
110 | 84 | | |
111 | 85 | | |
112 | 86 | | |
113 | | - | |
114 | | - | |
| 87 | + | |
| 88 | + | |
115 | 89 | | |
116 | 90 | | |
117 | | - | |
118 | | - | |
| 91 | + | |
| 92 | + | |
119 | 93 | | |
120 | 94 | | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
121 | 107 | | |
0 commit comments