Skip to content

Commit dcba8f2

Browse files
committed
Bug 1992156 - Trigger loading detected backup details in restore component when EmbeddedBackupRestore loads r=omc-reviewers,jprickett
Differential Revision: https://phabricator.services.mozilla.com/D267241 UltraBlame original commit: 988d08ce7423f749256382637c0f6c03655a0fce
1 parent 6ce9dc3 commit dcba8f2

File tree

6 files changed

+331
-0
lines changed

6 files changed

+331
-0
lines changed

browser/components/aboutwelcome/actors/AboutWelcomeChild.sys.mjs

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -818,6 +818,28 @@ AWGetUnhandledCampaignAction
818818
}
819819
)
820820
;
821+
Cu
822+
.
823+
exportFunction
824+
(
825+
this
826+
.
827+
AWFindBackupsInWellKnownLocations
828+
.
829+
bind
830+
(
831+
this
832+
)
833+
window
834+
{
835+
defineAs
836+
:
837+
"
838+
AWFindBackupsInWellKnownLocations
839+
"
840+
}
841+
)
842+
;
821843
}
822844
/
823845
*
@@ -1023,6 +1045,49 @@ screen
10231045
)
10241046
;
10251047
}
1048+
AWFindBackupsInWellKnownLocations
1049+
(
1050+
)
1051+
{
1052+
/
1053+
/
1054+
This
1055+
return
1056+
value
1057+
will
1058+
be
1059+
used
1060+
in
1061+
https
1062+
:
1063+
/
1064+
/
1065+
bugzilla
1066+
.
1067+
mozilla
1068+
.
1069+
org
1070+
/
1071+
show_bug
1072+
.
1073+
cgi
1074+
?
1075+
id
1076+
=
1077+
1992157
1078+
return
1079+
this
1080+
.
1081+
sendQueryAndCloneForContent
1082+
(
1083+
"
1084+
AWPage
1085+
:
1086+
BACKUP_FIND_WELL_KNOWN
1087+
"
1088+
)
1089+
;
1090+
}
10261091
/
10271092
*
10281093
*

browser/components/aboutwelcome/actors/AboutWelcomeParent.sys.mjs

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,24 @@ sys
139139
.
140140
mjs
141141
"
142+
BackupService
143+
:
144+
"
145+
resource
146+
:
147+
/
148+
/
149+
/
150+
modules
151+
/
152+
backup
153+
/
154+
BackupService
155+
.
156+
sys
157+
.
158+
mjs
159+
"
142160
BrowserUtils
143161
:
144162
"
@@ -1892,6 +1910,61 @@ true
18921910
break
18931911
;
18941912
}
1913+
case
1914+
"
1915+
AWPage
1916+
:
1917+
BACKUP_FIND_WELL_KNOWN
1918+
"
1919+
:
1920+
{
1921+
/
1922+
/
1923+
Ask
1924+
the
1925+
BackupService
1926+
to
1927+
probe
1928+
default
1929+
locations
1930+
.
1931+
let
1932+
bs
1933+
;
1934+
try
1935+
{
1936+
bs
1937+
=
1938+
lazy
1939+
.
1940+
BackupService
1941+
.
1942+
get
1943+
(
1944+
)
1945+
;
1946+
}
1947+
catch
1948+
{
1949+
bs
1950+
=
1951+
lazy
1952+
.
1953+
BackupService
1954+
.
1955+
init
1956+
(
1957+
)
1958+
;
1959+
}
1960+
return
1961+
bs
1962+
.
1963+
findBackupsInWellKnownLocations
1964+
(
1965+
)
1966+
;
1967+
}
18951968
default
18961969
:
18971970
lazy

browser/components/aboutwelcome/content-src/components/EmbeddedBackupRestore.jsx

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,30 @@ useEffect
137137
=
138138
>
139139
{
140+
const
141+
loadRestore
142+
=
143+
async
144+
(
145+
)
146+
=
147+
>
148+
{
149+
await
150+
window
151+
.
152+
AWFindBackupsInWellKnownLocations
153+
?
154+
.
155+
(
156+
)
157+
;
158+
}
159+
;
160+
loadRestore
161+
(
162+
)
163+
;
140164
/
141165
/
142166
Clear

browser/components/aboutwelcome/content/aboutwelcome.bundle.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21528,6 +21528,30 @@ useEffect
2152821528
=
2152921529
>
2153021530
{
21531+
const
21532+
loadRestore
21533+
=
21534+
async
21535+
(
21536+
)
21537+
=
21538+
>
21539+
{
21540+
await
21541+
window
21542+
.
21543+
AWFindBackupsInWellKnownLocations
21544+
?
21545+
.
21546+
(
21547+
)
21548+
;
21549+
}
21550+
;
21551+
loadRestore
21552+
(
21553+
)
21554+
;
2153121555
_lib_aboutwelcome_utils_mjs__WEBPACK_IMPORTED_MODULE_1__
2153221556
.
2153321557
AboutWelcomeUtils

browser/components/aboutwelcome/tests/unit/ContentTiles.test.jsx

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,43 @@ stub
449449
}
450450
)
451451
;
452+
globals
453+
.
454+
set
455+
(
456+
{
457+
AWSendToParent
458+
:
459+
sandbox
460+
.
461+
stub
462+
(
463+
)
464+
AWFindBackupsInWellKnownLocations
465+
:
466+
sandbox
467+
.
468+
stub
469+
(
470+
)
471+
.
472+
resolves
473+
(
474+
{
475+
found
476+
:
477+
false
478+
multipleBackupsFound
479+
:
480+
false
481+
backupFileToRestore
482+
:
483+
null
484+
}
485+
)
486+
}
487+
)
488+
;
452489
wrapper
453490
=
454491
shallow

browser/components/aboutwelcome/tests/unit/EmbeddedBackupRestore.test.jsx

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,43 @@ stub
101101
}
102102
)
103103
;
104+
globals
105+
.
106+
set
107+
(
108+
{
109+
AWSendToParent
110+
:
111+
sandbox
112+
.
113+
stub
114+
(
115+
)
116+
AWFindBackupsInWellKnownLocations
117+
:
118+
sandbox
119+
.
120+
stub
121+
(
122+
)
123+
.
124+
resolves
125+
(
126+
{
127+
found
128+
:
129+
false
130+
multipleBackupsFound
131+
:
132+
false
133+
backupFileToRestore
134+
:
135+
null
136+
}
137+
)
138+
}
139+
)
140+
;
104141
}
105142
)
106143
;
@@ -261,6 +298,77 @@ to
261298
}
262299
)
263300
;
301+
it
302+
(
303+
"
304+
calls
305+
AWFindBackupsInWellKnownLocations
306+
on
307+
mount
308+
"
309+
async
310+
(
311+
)
312+
=
313+
>
314+
{
315+
wrapper
316+
=
317+
mount
318+
(
319+
<
320+
EmbeddedBackupRestore
321+
/
322+
>
323+
)
324+
;
325+
/
326+
/
327+
Ensure
328+
the
329+
effect
330+
runs
331+
before
332+
we
333+
assert
334+
.
335+
await
336+
new
337+
Promise
338+
(
339+
resolve
340+
=
341+
>
342+
setTimeout
343+
(
344+
resolve
345+
0
346+
)
347+
)
348+
;
349+
assert
350+
.
351+
isTrue
352+
(
353+
window
354+
.
355+
AWFindBackupsInWellKnownLocations
356+
.
357+
calledOnce
358+
"
359+
should
360+
call
361+
AWFindBackupsInWellKnownLocations
362+
exactly
363+
once
364+
on
365+
mount
366+
"
367+
)
368+
;
369+
}
370+
)
371+
;
264372
}
265373
)
266374
;

0 commit comments

Comments
 (0)