|
1 /* Any copyright is dedicated to the Public Domain. |
|
2 * http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
3 |
|
4 function testForceCheck() { |
|
5 addChromeEventListener("update-available", function(evt) { |
|
6 isFinishUpdate(evt.detail); |
|
7 statusSettingIs("check-complete", testDownload); |
|
8 return true; |
|
9 }); |
|
10 sendContentEvent("force-update-check"); |
|
11 } |
|
12 |
|
13 function testDownload() { |
|
14 let gotStarted = false, gotProgress = false, gotStopped = false; |
|
15 let progress = 0, total = 0; |
|
16 |
|
17 addChromeEventListener("update-download-started", function(evt) { |
|
18 gotStarted = true; |
|
19 return true; |
|
20 }); |
|
21 addChromeEventListener("update-download-progress", function(evt) { |
|
22 progress = evt.detail.progress; |
|
23 total = evt.detail.total; |
|
24 gotProgress = true; |
|
25 if (total == progress) { |
|
26 ok(gotStarted); |
|
27 return true; |
|
28 } |
|
29 return false; |
|
30 }); |
|
31 addChromeEventListener("update-download-stopped", function(evt) { |
|
32 is(evt.detail.paused, false); |
|
33 gotStopped = true; |
|
34 ok(gotStarted); |
|
35 ok(gotProgress); |
|
36 return true; |
|
37 }); |
|
38 addChromeEventListener("update-downloaded", function(evt) { |
|
39 ok(gotStarted); |
|
40 ok(gotProgress); |
|
41 ok(gotStopped); |
|
42 is(progress, total); |
|
43 return true; |
|
44 }); |
|
45 addChromeEventListener("update-prompt-apply", function(evt) { |
|
46 isStartToFinishUpdate(evt.detail); |
|
47 cleanUp(); |
|
48 }); |
|
49 sendContentEvent("update-available-result", { |
|
50 result: "download" |
|
51 }); |
|
52 } |
|
53 |
|
54 function testApplied() { |
|
55 let finish = getFinishBuild(); |
|
56 is(Services.appinfo.version, finish.app_version, |
|
57 "Services.appinfo.version should be " + finish.app_version); |
|
58 is(Services.appinfo.platformVersion, finish.platform_milestone, |
|
59 "Services.appinfo.platformVersion should be " + finish.platform_milestone); |
|
60 is(Services.appinfo.appBuildID, finish.app_build_id, |
|
61 "Services.appinfo.appBuildID should be " + finish.app_build_id); |
|
62 cleanUp(); |
|
63 } |
|
64 |
|
65 // Update lifecycle callbacks |
|
66 function preUpdate() { |
|
67 testForceCheck(); |
|
68 } |
|
69 |
|
70 function postUpdate() { |
|
71 testApplied(); |
|
72 } |