aboutsummaryrefslogtreecommitdiff
path: root/gnu/packages/patches/icecat-CVE-2016-9064.patch
blob: a5393815e00a76d3ef58c388558c455d991d0ec0 (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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
Copied from
<https://hg.mozilla.org/releases/mozilla-esr45/raw-rev/00c2b7baaa0b>
but with one hunk omitted: the git binary patch for
toolkit/mozapps/extensions/test/addons/test_update_multi2/addon.xpi
which is not present in the IceCat sources.

# HG changeset patch
# User Andrew Swan <aswan@mozilla.com>
# Date 1474063218 25200
# Node ID 00c2b7baaa0b4bfb7d5f1aac31c094ea6b255e1f
# Parent  46b07bdbf8b20cf3fdc28104add57ff58a55832b
Bug 1303418 - Don't allow upgrades that change the addon ID. r=mossop, a=lizzard

MozReview-Commit-ID: JHINo8ShmeI

diff --git a/toolkit/mozapps/extensions/AddonManager.jsm b/toolkit/mozapps/extensions/AddonManager.jsm
--- a/toolkit/mozapps/extensions/AddonManager.jsm
+++ b/toolkit/mozapps/extensions/AddonManager.jsm
@@ -2956,16 +2956,18 @@ this.AddonManager = {
   // The downloaded file seems to be corrupted in some way.
   ERROR_CORRUPT_FILE: -3,
   // An error occured trying to write to the filesystem.
   ERROR_FILE_ACCESS: -4,
   // The add-on must be signed and isn't.
   ERROR_SIGNEDSTATE_REQUIRED: -5,
   // The downloaded add-on had a different type than expected.
   ERROR_UNEXPECTED_ADDON_TYPE: -6,
+  // The addon did not have the expected ID
+  ERROR_INCORRECT_ID: -7,
 
   // These must be kept in sync with AddonUpdateChecker.
   // No error was encountered.
   UPDATE_STATUS_NO_ERROR: 0,
   // The update check timed out
   UPDATE_STATUS_TIMEOUT: -1,
   // There was an error while downloading the update information.
   UPDATE_STATUS_DOWNLOAD_ERROR: -2,
diff --git a/toolkit/mozapps/extensions/internal/XPIProvider.jsm b/toolkit/mozapps/extensions/internal/XPIProvider.jsm
--- a/toolkit/mozapps/extensions/internal/XPIProvider.jsm
+++ b/toolkit/mozapps/extensions/internal/XPIProvider.jsm
@@ -5473,16 +5473,37 @@ AddonInstall.prototype = {
       // loadManifestFromZipReader performs the certificate verification for us
       this.addon = yield loadManifestFromZipReader(zipreader, this.installLocation);
     }
     catch (e) {
       zipreader.close();
       return Promise.reject([AddonManager.ERROR_CORRUPT_FILE, e]);
     }
 
+    if (this.existingAddon) {
+      // Check various conditions related to upgrades
+      if (this.addon.id != this.existingAddon.id) {
+        zipreader.close();
+        return Promise.reject([AddonManager.ERROR_INCORRECT_ID,
+                               `Refusing to upgrade addon ${this.existingAddon.id} to different ID ${this.addon.id}`]);
+      }
+
+      if (this.addon.type == "multipackage") {
+        zipreader.close();
+        return Promise.reject([AddonManager.ERROR_UNEXPECTED_ADDON_TYPE,
+                               `Refusing to upgrade addon ${this.existingAddon.id} to a multi-package xpi`]);
+      }
+
+      if (this.existingAddon.type == "webextension" && this.addon.type != "webextension") {
+        zipreader.close();
+        return Promise.reject([AddonManager.ERROR_UNEXPECTED_ADDON_TYPE,
+                               "Webextensions may not be updated to other extension types"]);
+      }
+    }
+
     if (mustSign(this.addon.type)) {
       if (this.addon.signedState <= AddonManager.SIGNEDSTATE_MISSING) {
         // This add-on isn't properly signed by a signature that chains to the
         // trusted root.
         let state = this.addon.signedState;
         this.addon = null;
         zipreader.close();
 
@@ -5510,23 +5531,16 @@ AddonInstall.prototype = {
         } else {
           zipreader.close();
           return Promise.reject([AddonManager.ERROR_CORRUPT_FILE,
                                  "XPI is incorrectly signed"]);
         }
       }
     }
 
-    if (this.existingAddon && this.existingAddon.type == "webextension" &&
-        this.addon.type != "webextension") {
-      zipreader.close();
-      return Promise.reject([AddonManager.ERROR_UNEXPECTED_ADDON_TYPE,
-                             "WebExtensions may not be upated to other extension types"]);
-    }
-
     if (this.addon.type == "multipackage")
       return this._loadMultipackageManifests(zipreader);
 
     zipreader.close();
 
     this.updateAddonURIs();
 
     this.addon._install = this;
@@ -5791,16 +5805,17 @@ AddonInstall.prototype = {
           else {
             // TODO Should we send some event here (bug 557716)?
             this.state = AddonManager.STATE_CHECKING;
             new UpdateChecker(this.addon, {
               onUpdateFinished: aAddon => this.downloadCompleted(),
             }, AddonManager.UPDATE_WHEN_ADDON_INSTALLED);
           }
         }, ([error, message]) => {
+          this.removeTemporaryFile();
           this.downloadFailed(error, message);
         });
       }
       else {
         if (aRequest instanceof Ci.nsIHttpChannel)
           this.downloadFailed(AddonManager.ERROR_NETWORK_FAILURE,
                               aRequest.responseStatus + " " +
                               aRequest.responseStatusText);
diff --git a/toolkit/mozapps/extensions/test/addons/test_update_multi1/bootstrap.js b/toolkit/mozapps/extensions/test/addons/test_update_multi1/bootstrap.js
new file mode 100644
--- /dev/null
+++ b/toolkit/mozapps/extensions/test/addons/test_update_multi1/bootstrap.js
@@ -0,0 +1,5 @@
+
+function install(data, reason) {}
+function startup(data, reason) {}
+function shutdown(data, reason) {}
+function uninstall(data, reason) {}
diff --git a/toolkit/mozapps/extensions/test/addons/test_update_multi1/install.rdf b/toolkit/mozapps/extensions/test/addons/test_update_multi1/install.rdf
new file mode 100644
--- /dev/null
+++ b/toolkit/mozapps/extensions/test/addons/test_update_multi1/install.rdf
@@ -0,0 +1,16 @@
+<?xml version="1.0"?>
+<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+     xmlns:em="http://www.mozilla.org/2004/em-rdf#">
+<Description about="urn:mozilla:install-manifest">
+  <em:id>updatemulti@tests.mozilla.org</em:id>
+  <em:version>1.0</em:version>
+  <em:updateURL>http://localhost:4444/data/test_update_multi.rdf</em:updateURL>
+  <em:bootstrap>true</em:bootstrap>
+  <em:name>Test Addon 1</em:name>
+<em:targetApplication><Description>
+  <em:id>xpcshell@tests.mozilla.org</em:id>
+  <em:minVersion>1</em:minVersion>
+  <em:maxVersion>1</em:maxVersion>
+</Description></em:targetApplication>
+</Description>
+</RDF>
diff --git a/toolkit/mozapps/extensions/test/addons/test_update_multi2/install.rdf b/toolkit/mozapps/extensions/test/addons/test_update_multi2/install.rdf
new file mode 100644
--- /dev/null
+++ b/toolkit/mozapps/extensions/test/addons/test_update_multi2/install.rdf
@@ -0,0 +1,9 @@
+<?xml version="1.0"?>
+<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+     xmlns:em="http://www.mozilla.org/2004/em-rdf#">
+<Description about="urn:mozilla:install-manifest">
+  <em:id>updatemulti@tests.mozilla.org</em:id>
+  <em:type>32</em:type>
+  <em:version>2.0</em:version>
+</Description>
+</RDF>
diff --git a/toolkit/mozapps/extensions/test/addons/test_updateid1/bootstrap.js b/toolkit/mozapps/extensions/test/addons/test_updateid1/bootstrap.js
new file mode 100644
--- /dev/null
+++ b/toolkit/mozapps/extensions/test/addons/test_updateid1/bootstrap.js
@@ -0,0 +1,5 @@
+
+function install(data, reason) {}
+function startup(data, reason) {}
+function shutdown(data, reason) {}
+function uninstall(data, reason) {}
diff --git a/toolkit/mozapps/extensions/test/addons/test_updateid1/install.rdf b/toolkit/mozapps/extensions/test/addons/test_updateid1/install.rdf
new file mode 100644
--- /dev/null
+++ b/toolkit/mozapps/extensions/test/addons/test_updateid1/install.rdf
@@ -0,0 +1,16 @@
+<?xml version="1.0"?>
+<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+     xmlns:em="http://www.mozilla.org/2004/em-rdf#">
+<Description about="urn:mozilla:install-manifest">
+  <em:id>addon1@tests.mozilla.org</em:id>
+  <em:version>1.0</em:version>
+  <em:updateURL>http://localhost:4444/data/test_updateid.rdf</em:updateURL>
+  <em:bootstrap>true</em:bootstrap>
+  <em:name>Test Addon 1</em:name>
+<em:targetApplication><Description>
+  <em:id>xpcshell@tests.mozilla.org</em:id>
+  <em:minVersion>1</em:minVersion>
+  <em:maxVersion>1</em:maxVersion>
+</Description></em:targetApplication>
+</Description>
+</RDF>
diff --git a/toolkit/mozapps/extensions/test/addons/test_updateid2/bootstrap.js b/toolkit/mozapps/extensions/test/addons/test_updateid2/bootstrap.js
new file mode 100644
--- /dev/null
+++ b/toolkit/mozapps/extensions/test/addons/test_updateid2/bootstrap.js
@@ -0,0 +1,5 @@
+
+function install(data, reason) {}
+function startup(data, reason) {}
+function shutdown(data, reason) {}
+function uninstall(data, reason) {}
diff --git a/toolkit/mozapps/extensions/test/addons/test_updateid2/install.rdf b/toolkit/mozapps/extensions/test/addons/test_updateid2/install.rdf
new file mode 100644
--- /dev/null
+++ b/toolkit/mozapps/extensions/test/addons/test_updateid2/install.rdf
@@ -0,0 +1,16 @@
+<?xml version="1.0"?>
+<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+     xmlns:em="http://www.mozilla.org/2004/em-rdf#">
+<Description about="urn:mozilla:install-manifest">
+  <em:id>addon1.changed@tests.mozilla.org</em:id>
+  <em:version>2.0</em:version>
+  <em:updateURL>http://localhost:4444/data/test_updateid.rdf</em:updateURL>
+  <em:bootstrap>true</em:bootstrap>
+  <em:name>Test Addon 1</em:name>
+<em:targetApplication><Description>
+  <em:id>xpcshell@tests.mozilla.org</em:id>
+  <em:minVersion>1</em:minVersion>
+  <em:maxVersion>1</em:maxVersion>
+</Description></em:targetApplication>
+</Description>
+</RDF>
diff --git a/toolkit/mozapps/extensions/test/addons/test_updateid2_2/install.rdf b/toolkit/mozapps/extensions/test/addons/test_updateid2_2/install.rdf
deleted file mode 100644
--- a/toolkit/mozapps/extensions/test/addons/test_updateid2_2/install.rdf
+++ /dev/null
@@ -1,24 +0,0 @@
-<?xml version="1.0"?>
-
-<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
-     xmlns:em="http://www.mozilla.org/2004/em-rdf#">
-
-  <Description about="urn:mozilla:install-manifest">
-    <em:id>addon2@tests.mozilla.org</em:id>
-    <em:version>2.0</em:version>
-    <em:updateURL>http://localhost:4444/data/test_updateid.rdf</em:updateURL>
-
-    <!-- Front End MetaData -->
-    <em:name>Test 2</em:name>
-    <em:description>Test Description</em:description>
-
-    <em:targetApplication>
-      <Description>
-        <em:id>xpcshell@tests.mozilla.org</em:id>
-        <em:minVersion>1</em:minVersion>
-        <em:maxVersion>1</em:maxVersion>
-      </Description>
-    </em:targetApplication>
-
-  </Description>
-</RDF>
diff --git a/toolkit/mozapps/extensions/test/addons/test_updateid2_5/install.rdf b/toolkit/mozapps/extensions/test/addons/test_updateid2_5/install.rdf
deleted file mode 100644
--- a/toolkit/mozapps/extensions/test/addons/test_updateid2_5/install.rdf
+++ /dev/null
@@ -1,24 +0,0 @@
-<?xml version="1.0"?>
-
-<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
-     xmlns:em="http://www.mozilla.org/2004/em-rdf#">
-
-  <Description about="urn:mozilla:install-manifest">
-    <em:id>addon2@tests.mozilla.org</em:id>
-    <em:version>5.0</em:version>
-    <em:updateURL>http://localhost:4444/data/test_updateid.rdf</em:updateURL>
-
-    <!-- Front End MetaData -->
-    <em:name>Test 2</em:name>
-    <em:description>Test Description</em:description>
-
-    <em:targetApplication>
-      <Description>
-        <em:id>xpcshell@tests.mozilla.org</em:id>
-        <em:minVersion>1</em:minVersion>
-        <em:maxVersion>1</em:maxVersion>
-      </Description>
-    </em:targetApplication>
-
-  </Description>
-</RDF>
diff --git a/toolkit/mozapps/extensions/test/addons/test_updateid3_3/bootstrap.js b/toolkit/mozapps/extensions/test/addons/test_updateid3_3/bootstrap.js
deleted file mode 100644
--- a/toolkit/mozapps/extensions/test/addons/test_updateid3_3/bootstrap.js
+++ /dev/null
@@ -1,21 +0,0 @@
-Components.utils.import("resource://gre/modules/Services.jsm");
-
-function install(data, reason) {
-  Services.prefs.setIntPref("bootstraptest.installed_version", 3);
-  Services.prefs.setIntPref("bootstraptest.install_reason", reason);
-}
-
-function startup(data, reason) {
-  Services.prefs.setIntPref("bootstraptest.active_version", 3);
-  Services.prefs.setIntPref("bootstraptest.startup_reason", reason);
-}
-
-function shutdown(data, reason) {
-  Services.prefs.setIntPref("bootstraptest.active_version", 0);
-  Services.prefs.setIntPref("bootstraptest.shutdown_reason", reason);
-}
-
-function uninstall(data, reason) {
-  Services.prefs.setIntPref("bootstraptest.installed_version", 0);
-  Services.prefs.setIntPref("bootstraptest.uninstall_reason", reason);
-}
diff --git a/toolkit/mozapps/extensions/test/addons/test_updateid3_3/install.rdf b/toolkit/mozapps/extensions/test/addons/test_updateid3_3/install.rdf
deleted file mode 100644
--- a/toolkit/mozapps/extensions/test/addons/test_updateid3_3/install.rdf
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0"?>
-
-<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
-     xmlns:em="http://www.mozilla.org/2004/em-rdf#">
-
-  <Description about="urn:mozilla:install-manifest">
-    <em:id>addon3@tests.mozilla.org</em:id>
-    <em:version>3.0</em:version>
-    <em:updateURL>http://localhost:4444/data/test_updateid.rdf</em:updateURL>
-    <em:bootstrap>true</em:bootstrap>
-
-    <!-- Front End MetaData -->
-    <em:name>Test 3</em:name>
-    <em:description>Test Description</em:description>
-
-    <em:targetApplication>
-      <Description>
-        <em:id>xpcshell@tests.mozilla.org</em:id>
-        <em:minVersion>1</em:minVersion>
-        <em:maxVersion>1</em:maxVersion>
-      </Description>
-    </em:targetApplication>
-
-  </Description>
-</RDF>
diff --git a/toolkit/mozapps/extensions/test/addons/test_updateid4_4/bootstrap.js b/toolkit/mozapps/extensions/test/addons/test_updateid4_4/bootstrap.js
deleted file mode 100644
--- a/toolkit/mozapps/extensions/test/addons/test_updateid4_4/bootstrap.js
+++ /dev/null
@@ -1,21 +0,0 @@
-Components.utils.import("resource://gre/modules/Services.jsm");
-
-function install(data, reason) {
-  Services.prefs.setIntPref("bootstraptest.installed_version", 4);
-  Services.prefs.setIntPref("bootstraptest.install_reason", reason);
-}
-
-function startup(data, reason) {
-  Services.prefs.setIntPref("bootstraptest.active_version", 4);
-  Services.prefs.setIntPref("bootstraptest.startup_reason", reason);
-}
-
-function shutdown(data, reason) {
-  Services.prefs.setIntPref("bootstraptest.active_version", 0);
-  Services.prefs.setIntPref("bootstraptest.shutdown_reason", reason);
-}
-
-function uninstall(data, reason) {
-  Services.prefs.setIntPref("bootstraptest.installed_version", 0);
-  Services.prefs.setIntPref("bootstraptest.uninstall_reason", reason);
-}
diff --git a/toolkit/mozapps/extensions/test/addons/test_updateid4_4/install.rdf b/toolkit/mozapps/extensions/test/addons/test_updateid4_4/install.rdf
deleted file mode 100644
--- a/toolkit/mozapps/extensions/test/addons/test_updateid4_4/install.rdf
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0"?>
-
-<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
-     xmlns:em="http://www.mozilla.org/2004/em-rdf#">
-
-  <Description about="urn:mozilla:install-manifest">
-    <em:id>addon4@tests.mozilla.org</em:id>
-    <em:version>4.0</em:version>
-    <em:updateURL>http://localhost:4444/data/test_updateid.rdf</em:updateURL>
-    <em:bootstrap>true</em:bootstrap>
-
-    <!-- Front End MetaData -->
-    <em:name>Test 4</em:name>
-    <em:description>Test Description</em:description>
-
-    <em:targetApplication>
-      <Description>
-        <em:id>xpcshell@tests.mozilla.org</em:id>
-        <em:minVersion>1</em:minVersion>
-        <em:maxVersion>1</em:maxVersion>
-      </Description>
-    </em:targetApplication>
-
-  </Description>
-</RDF>
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_update_multi.rdf b/toolkit/mozapps/extensions/test/xpcshell/data/test_update_multi.rdf
new file mode 100644
--- /dev/null
+++ b/toolkit/mozapps/extensions/test/xpcshell/data/test_update_multi.rdf
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+     xmlns:em="http://www.mozilla.org/2004/em-rdf#">
+
+  <Description about="urn:mozilla:extension:updatemulti@tests.mozilla.org">
+    <em:updates>
+      <Seq>
+        <li>
+          <Description>
+            <em:version>2.0</em:version>
+            <em:targetApplication>
+              <Description>
+                <em:id>xpcshell@tests.mozilla.org</em:id>
+                <em:minVersion>1</em:minVersion>
+                <em:maxVersion>1</em:maxVersion>
+                <em:updateLink>http://localhost:4444/addons/test_update_multi2.xpi</em:updateLink>
+              </Description>
+            </em:targetApplication>
+          </Description>
+        </li>
+      </Seq>
+    </em:updates>
+  </Description>
+
+</RDF>
diff --git a/toolkit/mozapps/extensions/test/xpcshell/data/test_updateid.rdf b/toolkit/mozapps/extensions/test/xpcshell/data/test_updateid.rdf
--- a/toolkit/mozapps/extensions/test/xpcshell/data/test_updateid.rdf
+++ b/toolkit/mozapps/extensions/test/xpcshell/data/test_updateid.rdf
@@ -9,77 +9,17 @@
         <li>
           <Description>
             <em:version>2.0</em:version>
             <em:targetApplication>
               <Description>
                 <em:id>xpcshell@tests.mozilla.org</em:id>
                 <em:minVersion>1</em:minVersion>
                 <em:maxVersion>1</em:maxVersion>
-                <em:updateLink>http://localhost:4444/addons/test_updateid2_2.xpi</em:updateLink>
-              </Description>
-            </em:targetApplication>
-          </Description>
-        </li>
-      </Seq>
-    </em:updates>
-  </Description>
-
-  <Description about="urn:mozilla:extension:addon2@tests.mozilla.org">
-    <em:updates>
-      <Seq>
-        <li>
-          <Description>
-            <em:version>3.0</em:version>
-            <em:targetApplication>
-              <Description>
-                <em:id>xpcshell@tests.mozilla.org</em:id>
-                <em:minVersion>1</em:minVersion>
-                <em:maxVersion>1</em:maxVersion>
-                <em:updateLink>http://localhost:4444/addons/test_updateid3_3.xpi</em:updateLink>
-              </Description>
-            </em:targetApplication>
-          </Description>
-        </li>
-      </Seq>
-    </em:updates>
-  </Description>
-
-  <Description about="urn:mozilla:extension:addon3@tests.mozilla.org">
-    <em:updates>
-      <Seq>
-        <li>
-          <Description>
-            <em:version>4.0</em:version>
-            <em:targetApplication>
-              <Description>
-                <em:id>xpcshell@tests.mozilla.org</em:id>
-                <em:minVersion>1</em:minVersion>
-                <em:maxVersion>1</em:maxVersion>
-                <em:updateLink>http://localhost:4444/addons/test_updateid4_4.xpi</em:updateLink>
-              </Description>
-            </em:targetApplication>
-          </Description>
-        </li>
-      </Seq>
-    </em:updates>
-  </Description>
-
-  <Description about="urn:mozilla:extension:addon4@tests.mozilla.org">
-    <em:updates>
-      <Seq>
-        <li>
-          <Description>
-            <em:version>5.0</em:version>
-            <em:targetApplication>
-              <Description>
-                <em:id>xpcshell@tests.mozilla.org</em:id>
-                <em:minVersion>1</em:minVersion>
-                <em:maxVersion>1</em:maxVersion>
-                <em:updateLink>http://localhost:4444/addons/test_updateid2_5.xpi</em:updateLink>
+                <em:updateLink>http://localhost:4444/addons/test_updateid2.xpi</em:updateLink>
               </Description>
             </em:targetApplication>
           </Description>
         </li>
       </Seq>
     </em:updates>
   </Description>
 
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_updateid.js b/toolkit/mozapps/extensions/test/xpcshell/test_updateid.js
--- a/toolkit/mozapps/extensions/test/xpcshell/test_updateid.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_updateid.js
@@ -2,421 +2,85 @@
  * http://creativecommons.org/publicdomain/zero/1.0/
  */
 
 // This verifies that updating an add-on to a new ID works
 
 // The test extension uses an insecure update url.
 Services.prefs.setBoolPref("extensions.checkUpdateSecurity", false);
 
-Components.utils.import("resource://testing-common/httpd.js");
-var testserver;
 const profileDir = gProfD.clone();
 profileDir.append("extensions");
 
-function resetPrefs() {
-  Services.prefs.setIntPref("bootstraptest.active_version", -1);
-  Services.prefs.setIntPref("bootstraptest.installed_version", -1);
-  Services.prefs.setIntPref("bootstraptest.startup_reason", -1);
-  Services.prefs.setIntPref("bootstraptest.shutdown_reason", -1);
-  Services.prefs.setIntPref("bootstraptest.install_reason", -1);
-  Services.prefs.setIntPref("bootstraptest.uninstall_reason", -1);
-}
-
-function getActiveVersion() {
-  return Services.prefs.getIntPref("bootstraptest.active_version");
-}
-
-function getInstalledVersion() {
-  return Services.prefs.getIntPref("bootstraptest.installed_version");
-}
-
-function run_test() {
-  createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");
-
-  // Create and configure the HTTP server.
-  testserver = new HttpServer();
-  testserver.registerDirectory("/data/", do_get_file("data"));
-  testserver.registerDirectory("/addons/", do_get_file("addons"));
-  testserver.start(4444);
-
-  do_test_pending();
-  run_test_1();
-}
-
-function end_test() {
-  testserver.stop(do_test_finished);
-}
-
-function installUpdate(aInstall, aCallback) {
-  aInstall.addListener({
-    onInstallEnded: function(aInstall) {
-      // give the startup time to run
-      do_execute_soon(function() {
-        aCallback(aInstall);
-      });
-    }
-  });
-
-  aInstall.install();
-}
-
-// Verify that an update to an add-on with a new ID uninstalls the old add-on
-function run_test_1() {
-  writeInstallRDFForExtension({
-    id: "addon1@tests.mozilla.org",
-    version: "1.0",
-    updateURL: "http://localhost:4444/data/test_updateid.rdf",
-    targetApplications: [{
-      id: "xpcshell@tests.mozilla.org",
-      minVersion: "1",
-      maxVersion: "1"
-    }],
-    name: "Test Addon 1",
-  }, profileDir);
-
-  startupManager();
-
-  AddonManager.getAddonByID("addon1@tests.mozilla.org", function(a1) {
-    do_check_neq(a1, null);
-    do_check_eq(a1.version, "1.0");
+function promiseInstallUpdate(install) {
+  return new Promise((resolve, reject) => {
+    install.addListener({
+      onDownloadFailed: () => {
+        let err = new Error("download error");
+        err.code = install.error;
+        reject(err);
+      },
+      onInstallFailed: () => {
+        let err = new Error("install error");
+        err.code = install.error;
+        reject(err);
+      },
+      onInstallEnded: resolve,
+    });
 
-    a1.findUpdates({
-      onUpdateAvailable: function(addon, install) {
-        do_check_eq(install.name, addon.name);
-        do_check_eq(install.version, "2.0");
-        do_check_eq(install.state, AddonManager.STATE_AVAILABLE);
-        do_check_eq(install.existingAddon, a1);
-
-        installUpdate(install, check_test_1);
-      }
-    }, AddonManager.UPDATE_WHEN_USER_REQUESTED);
-  });
-}
-
-function check_test_1(install) {
-  AddonManager.getAddonByID("addon1@tests.mozilla.org", callback_soon(function(a1) {
-    // Existing add-on should have a pending upgrade
-    do_check_neq(a1.pendingUpgrade, null);
-    do_check_eq(a1.pendingUpgrade.id, "addon2@tests.mozilla.org");
-    do_check_eq(a1.pendingUpgrade.install.existingAddon, a1);
-    do_check_neq(a1.syncGUID);
-
-    let a1SyncGUID = a1.syncGUID;
-
-    restartManager();
-
-    AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org",
-                                 "addon2@tests.mozilla.org"], function([a1, a2]) {
-      // Should have uninstalled the old and installed the new
-      do_check_eq(a1, null);
-      do_check_neq(a2, null);
-      do_check_neq(a2.syncGUID, null);
-
-      // The Sync GUID should change when the ID changes
-      do_check_neq(a1SyncGUID, a2.syncGUID);
-
-      a2.uninstall();
-
-      do_execute_soon(run_test_2);
-    });
-  }));
-}
-
-// Test that when the new add-on already exists we just upgrade that
-function run_test_2() {
-  restartManager();
-  shutdownManager();
-
-  writeInstallRDFForExtension({
-    id: "addon1@tests.mozilla.org",
-    version: "1.0",
-    updateURL: "http://localhost:4444/data/test_updateid.rdf",
-    targetApplications: [{
-      id: "xpcshell@tests.mozilla.org",
-      minVersion: "1",
-      maxVersion: "1"
-    }],
-    name: "Test Addon 1",
-  }, profileDir);
-  writeInstallRDFForExtension({
-    id: "addon2@tests.mozilla.org",
-    version: "1.0",
-    targetApplications: [{
-      id: "xpcshell@tests.mozilla.org",
-      minVersion: "1",
-      maxVersion: "1"
-    }],
-    name: "Test Addon 2",
-  }, profileDir);
-
-  startupManager();
-
-  AddonManager.getAddonByID("addon1@tests.mozilla.org", function(a1) {
-    do_check_neq(a1, null);
-    do_check_eq(a1.version, "1.0");
-
-    a1.findUpdates({
-      onUpdateAvailable: function(addon, install) {
-        installUpdate(install, check_test_2);
-      }
-    }, AddonManager.UPDATE_WHEN_USER_REQUESTED);
+    install.install();
   });
 }
 
-function check_test_2(install) {
-  AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org",
-                               "addon2@tests.mozilla.org"],
-                               callback_soon(function([a1, a2]) {
-    do_check_eq(a1.pendingUpgrade, null);
-    // Existing add-on should have a pending upgrade
-    do_check_neq(a2.pendingUpgrade, null);
-    do_check_eq(a2.pendingUpgrade.id, "addon2@tests.mozilla.org");
-    do_check_eq(a2.pendingUpgrade.install.existingAddon, a2);
-
-    restartManager();
-
-    AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org",
-                                 "addon2@tests.mozilla.org"], function([a1, a2]) {
-      // Should have uninstalled the old and installed the new
-      do_check_neq(a1, null);
-      do_check_neq(a2, null);
-
-      a1.uninstall();
-      a2.uninstall();
-
-      do_execute_soon(run_test_3);
-    });
-  }));
-}
-
-// Test that we rollback correctly when removing the old add-on fails
-function run_test_3() {
-  restartManager();
-  shutdownManager();
-
-  // This test only works on Windows
-  if (!("nsIWindowsRegKey" in AM_Ci)) {
-    run_test_4();
-    return;
-  }
-
-  writeInstallRDFForExtension({
-    id: "addon1@tests.mozilla.org",
-    version: "1.0",
-    updateURL: "http://localhost:4444/data/test_updateid.rdf",
-    targetApplications: [{
-      id: "xpcshell@tests.mozilla.org",
-      minVersion: "1",
-      maxVersion: "1"
-    }],
-    name: "Test Addon 1",
-  }, profileDir);
-
-  startupManager();
+// Create and configure the HTTP server.
+let testserver = createHttpServer(4444);
+testserver.registerDirectory("/data/", do_get_file("data"));
+testserver.registerDirectory("/addons/", do_get_file("addons"));
 
-  AddonManager.getAddonByID("addon1@tests.mozilla.org", function(a1) {
-    do_check_neq(a1, null);
-    do_check_eq(a1.version, "1.0");
-
-    a1.findUpdates({
-      onUpdateAvailable: function(addon, install) {
-        installUpdate(install, check_test_3);
-      }
-    }, AddonManager.UPDATE_WHEN_USER_REQUESTED);
-  });
-}
-
-function check_test_3(install) {
-  AddonManager.getAddonByID("addon1@tests.mozilla.org", callback_soon(function(a1) {
-    // Existing add-on should have a pending upgrade
-    do_check_neq(a1.pendingUpgrade, null);
-    do_check_eq(a1.pendingUpgrade.id, "addon2@tests.mozilla.org");
-    do_check_eq(a1.pendingUpgrade.install.existingAddon, a1);
-
-    // Lock the old add-on open so it can't be uninstalled
-    var file = profileDir.clone();
-    file.append("addon1@tests.mozilla.org");
-    if (!file.exists())
-      file.leafName += ".xpi";
-    else
-      file.append("install.rdf");
-
-    var fstream = AM_Cc["@mozilla.org/network/file-output-stream;1"].
-                  createInstance(AM_Ci.nsIFileOutputStream);
-    fstream.init(file, FileUtils.MODE_APPEND | FileUtils.MODE_WRONLY, FileUtils.PERMS_FILE, 0);
-
-    restartManager();
-
-    fstream.close();
-
-    AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org",
-                                 "addon2@tests.mozilla.org"],
-                                 callback_soon(function([a1, a2]) {
-      // Should not have installed the new add-on but it should still be
-      // pending install
-      do_check_neq(a1, null);
-      do_check_eq(a2, null);
-
-      restartManager();
-
-      AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org",
-                                   "addon2@tests.mozilla.org"], function([a1, a2]) {
-        // Should have installed the new add-on
-        do_check_eq(a1, null);
-        do_check_neq(a2, null);
-
-        a2.uninstall();
-
-        do_execute_soon(run_test_4);
-      });
-    }));
-  }));
+function run_test() {
+  createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");
+  startupManager();
+  run_next_test();
 }
 
-// Tests that upgrading to a bootstrapped add-on works but requires a restart
-function run_test_4() {
-  restartManager();
-  shutdownManager();
-
-  writeInstallRDFForExtension({
-    id: "addon2@tests.mozilla.org",
-    version: "2.0",
-    updateURL: "http://localhost:4444/data/test_updateid.rdf",
-    targetApplications: [{
-      id: "xpcshell@tests.mozilla.org",
-      minVersion: "1",
-      maxVersion: "1"
-    }],
-    name: "Test Addon 2",
-  }, profileDir);
-
-  startupManager();
-
-  resetPrefs();
-
-  AddonManager.getAddonByID("addon2@tests.mozilla.org", function(a2) {
-    do_check_neq(a2, null);
-    do_check_neq(a2.syncGUID, null);
-    do_check_eq(a2.version, "2.0");
-
-    a2.findUpdates({
-      onUpdateAvailable: function(addon, install) {
-        installUpdate(install, check_test_4);
-      }
-    }, AddonManager.UPDATE_WHEN_USER_REQUESTED);
-  });
-}
-
-function check_test_4() {
-  AddonManager.getAddonsByIDs(["addon2@tests.mozilla.org",
-                               "addon3@tests.mozilla.org"],
-                               callback_soon(function([a2, a3]) {
-    // Should still be pending install even though the new add-on is restartless
-    do_check_neq(a2, null);
-    do_check_eq(a3, null);
-
-    do_check_neq(a2.pendingUpgrade, null);
-    do_check_eq(a2.pendingUpgrade.id, "addon3@tests.mozilla.org");
-
-    do_check_eq(getInstalledVersion(), -1);
-    do_check_eq(getActiveVersion(), -1);
-
-    restartManager();
-
-    AddonManager.getAddonsByIDs(["addon2@tests.mozilla.org",
-                                 "addon3@tests.mozilla.org"], function([a2, a3]) {
-      // Should have updated
-      do_check_eq(a2, null);
-      do_check_neq(a3, null);
-
-      do_check_eq(getInstalledVersion(), 3);
-      do_check_eq(getActiveVersion(), 3);
-
-      do_execute_soon(run_test_5);
-    });
-  }));
-}
-
-// Tests that upgrading to another bootstrapped add-on works without a restart
-function run_test_5() {
-  AddonManager.getAddonByID("addon3@tests.mozilla.org", function(a3) {
-    do_check_neq(a3, null);
-    do_check_eq(a3.version, "3.0");
+// Verify that an update to an add-on with a new ID fails
+add_task(function* test_update_new_id() {
+  yield promiseInstallAllFiles([do_get_addon("test_updateid1")]);
 
-    a3.findUpdates({
-      onUpdateAvailable: function(addon, install) {
-        installUpdate(install, check_test_5);
-      }
-    }, AddonManager.UPDATE_WHEN_USER_REQUESTED);
-  });
-}
-
-function check_test_5() {
-  AddonManager.getAddonsByIDs(["addon3@tests.mozilla.org",
-                               "addon4@tests.mozilla.org"],
-                               callback_soon(function([a3, a4]) {
-    // Should have updated
-    do_check_eq(a3, null);
-    do_check_neq(a4, null);
-
-    do_check_eq(getInstalledVersion(), 4);
-    do_check_eq(getActiveVersion(), 4);
-
-    restartManager();
-
-    AddonManager.getAddonsByIDs(["addon3@tests.mozilla.org",
-                                 "addon4@tests.mozilla.org"], function([a3, a4]) {
-      // Should still be gone
-      do_check_eq(a3, null);
-      do_check_neq(a4, null);
-
-      do_check_eq(getInstalledVersion(), 4);
-      do_check_eq(getActiveVersion(), 4);
-
-      run_test_6();
-    });
-  }));
-}
+  let addon = yield promiseAddonByID("addon1@tests.mozilla.org");
+  do_check_neq(addon, null);
+  do_check_eq(addon.version, "1.0");
 
-// Tests that upgrading to a non-bootstrapped add-on works but requires a restart
-function run_test_6() {
-  AddonManager.getAddonByID("addon4@tests.mozilla.org", function(a4) {
-    do_check_neq(a4, null);
-    do_check_eq(a4.version, "4.0");
-
-    a4.findUpdates({
-      onUpdateAvailable: function(addon, install) {
-        installUpdate(install, check_test_6);
-      }
-    }, AddonManager.UPDATE_WHEN_USER_REQUESTED);
-  });
-}
+  let update = yield promiseFindAddonUpdates(addon, AddonManager.UPDATE_WHEN_USER_REQUESTED);
+  let install = update.updateAvailable;
+  do_check_eq(install.name, addon.name);
+  do_check_eq(install.version, "2.0");
+  do_check_eq(install.state, AddonManager.STATE_AVAILABLE);
+  do_check_eq(install.existingAddon, addon);
 
-function check_test_6() {
-  AddonManager.getAddonsByIDs(["addon4@tests.mozilla.org",
-                               "addon2@tests.mozilla.org"],
-                               callback_soon(function([a4, a2]) {
-    // Should still be pending install even though the old add-on is restartless
-    do_check_neq(a4, null);
-    do_check_eq(a2, null);
-
-    do_check_neq(a4.pendingUpgrade, null);
-    do_check_eq(a4.pendingUpgrade.id, "addon2@tests.mozilla.org");
-
-    do_check_eq(getInstalledVersion(), 4);
-    do_check_eq(getActiveVersion(), 4);
+  yield Assert.rejects(promiseInstallUpdate(install),
+                       function(err) { return err.code == AddonManager.ERROR_INCORRECT_ID },
+                       "Upgrade to a different ID fails");
 
-    restartManager();
+  addon.uninstall();
+});
 
-    AddonManager.getAddonsByIDs(["addon4@tests.mozilla.org",
-                                 "addon2@tests.mozilla.org"], function([a4, a2]) {
-      // Should have updated
-      do_check_eq(a4, null);
-      do_check_neq(a2, null);
+// Verify that an update to a multi-package xpi fails
+add_task(function* test_update_new_id() {
+  yield promiseInstallAllFiles([do_get_addon("test_update_multi1")]);
 
-      do_check_eq(getInstalledVersion(), 0);
-      do_check_eq(getActiveVersion(), 0);
+  let addon = yield promiseAddonByID("updatemulti@tests.mozilla.org");
+  do_check_neq(addon, null);
+  do_check_eq(addon.version, "1.0");
 
-      end_test();
-    });
-  }));
-}
+  let update = yield promiseFindAddonUpdates(addon, AddonManager.UPDATE_WHEN_USER_REQUESTED);
+  let install = update.updateAvailable;
+  do_check_eq(install.name, addon.name);
+  do_check_eq(install.version, "2.0");
+  do_check_eq(install.state, AddonManager.STATE_AVAILABLE);
+  do_check_eq(install.existingAddon, addon);
+
+  yield Assert.rejects(promiseInstallUpdate(install),
+                       function(err) { return err.code == AddonManager.ERROR_UNEXPECTED_ADDON_TYPE },
+                       "Upgrade to a multipackage xpi fails");
+
+  addon.uninstall();
+});