summaryrefslogtreecommitdiff
path: root/toolkit/mozapps/extensions/test/browser/browser_details.js
blob: ce4c51b5aa226e9ba2264ae1b9dfb59d2ab4979b (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
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
/* Any copyright is dedicated to the Public Domain.
 * http://creativecommons.org/publicdomain/zero/1.0/
 */

// Tests various aspects of the details view

const { REQUIRE_SIGNING } = Components.utils.import("resource://gre/modules/addons/AddonConstants.jsm", {});

const PREF_AUTOUPDATE_DEFAULT = "extensions.update.autoUpdateDefault";
const PREF_GETADDONS_GETSEARCHRESULTS = "extensions.getAddons.search.url";
const SEARCH_URL = TESTROOT + "browser_details.xml";
const PREF_EM_HOTFIX_ID = "extensions.hotfix.id";

var gManagerWindow;
var gCategoryUtilities;
var gProvider;

var gApp = document.getElementById("bundle_brand").getString("brandShortName");
var gVersion = Services.appinfo.version;
var gDate = new Date(2010, 7, 1);
var infoURL = Services.urlFormatter.formatURLPref("app.support.baseURL") + "unsigned-addons";

function open_details(aId, aType, aCallback) {
  requestLongerTimeout(2);

  gCategoryUtilities.openType(aType, function() {
    var list = gManagerWindow.document.getElementById("addon-list");
    var item = list.firstChild;
    while (item) {
      if ("mAddon" in item && item.mAddon.id == aId) {
        list.ensureElementIsVisible(item);
        EventUtils.synthesizeMouseAtCenter(item, { clickCount: 1 }, gManagerWindow);
        EventUtils.synthesizeMouseAtCenter(item, { clickCount: 2 }, gManagerWindow);
        wait_for_view_load(gManagerWindow, aCallback);
        return;
      }
      item = item.nextSibling;
    }
    ok(false, "Should have found the add-on in the list");
  });
}

function get(aId) {
  return gManagerWindow.document.getElementById(aId);
}

function test() {
  requestLongerTimeout(2);
  // Turn on searching for this test
  Services.prefs.setIntPref(PREF_SEARCH_MAXRESULTS, 15);
  Services.prefs.setCharPref(PREF_GETADDONS_GETSEARCHRESULTS, SEARCH_URL);
  Services.prefs.setCharPref(PREF_EM_HOTFIX_ID, "hotfix@tests.mozilla.org");

  waitForExplicitFinish();

  gProvider = new MockProvider();

  gProvider.createAddons([{
    id: "addon1@tests.mozilla.org",
    name: "Test add-on 1",
    version: "2.1",
    description: "Short description",
    fullDescription: "Longer description",
    type: "extension",
    iconURL: "chrome://foo/skin/icon.png",
    icon64URL: "chrome://foo/skin/icon64.png",
    contributionURL: "http://foo.com",
    contributionAmount: "$0.99",
    sourceURI: Services.io.newURI("http://example.com/foo", null, null),
    averageRating: 4,
    reviewCount: 5,
    reviewURL: "http://example.com/reviews",
    homepageURL: "http://example.com/addon1",
    applyBackgroundUpdates: AddonManager.AUTOUPDATE_ENABLE
  }, {
    id: "addon2@tests.mozilla.org",
    name: "Test add-on 2",
    version: "2.2",
    description: "Short description",
    creator: { name: "Mozilla", url: null },
    type: "extension",
    iconURL: "chrome://foo/skin/icon.png",
    contributionURL: "http://foo.com",
    contributionAmount: null,
    updateDate: gDate,
    permissions: 0,
    screenshots: [{
      url: "chrome://branding/content/about.png",
      width: 200,
      height: 150
    }],
  }, {
    id: "addon3@tests.mozilla.org",
    name: "Test add-on 3",
    description: "Short description",
    creator: { name: "Mozilla", url: "http://www.mozilla.org" },
    type: "extension",
    sourceURI: Services.io.newURI("http://example.com/foo", null, null),
    updateDate: gDate,
    reviewCount: 1,
    reviewURL: "http://example.com/reviews",
    applyBackgroundUpdates: AddonManager.AUTOUPDATE_DISABLE,
    isActive: false,
    isCompatible: false,
    appDisabled: true,
    permissions: AddonManager.PERM_CAN_ENABLE |
                 AddonManager.PERM_CAN_DISABLE |
                 AddonManager.PERM_CAN_UPGRADE,
    screenshots: [{
      url: "http://example.com/screenshot",
      width: 400,
      height: 300,
      thumbnailURL: "chrome://branding/content/icon64.png",
      thumbnailWidth: 160,
      thumbnailHeight: 120
    }],
  }, {
    id: "addon4@tests.mozilla.org",
    blocklistURL: "http://example.com/addon4@tests.mozilla.org",
    name: "Test add-on 4",
    _userDisabled: true,
    isActive: false,
    blocklistState: Ci.nsIBlocklistService.STATE_SOFTBLOCKED
  }, {
    id: "addon5@tests.mozilla.org",
    blocklistURL: "http://example.com/addon5@tests.mozilla.org",
    name: "Test add-on 5",
    isActive: false,
    blocklistState: Ci.nsIBlocklistService.STATE_BLOCKED,
    appDisabled: true
  }, {
    id: "addon6@tests.mozilla.org",
    blocklistURL: "http://example.com/addon6@tests.mozilla.org",
    name: "Test add-on 6",
    operationsRequiringRestart: AddonManager.OP_NEEDS_RESTART_NONE
  }, {
    id: "addon7@tests.mozilla.org",
    blocklistURL: "http://example.com/addon7@tests.mozilla.org",
    name: "Test add-on 7",
    _userDisabled: true,
    isActive: false
  }, {
    id: "addon8@tests.mozilla.org",
    blocklistURL: "http://example.com/addon8@tests.mozilla.org",
    name: "Test add-on 8",
    blocklistState: Ci.nsIBlocklistService.STATE_OUTDATED
  }, {
    id: "addon9@tests.mozilla.org",
    name: "Test add-on 9",
    signedState: AddonManager.SIGNEDSTATE_MISSING,
  }, {
    id: "addon10@tests.mozilla.org",
    name: "Test add-on 10",
    signedState: AddonManager.SIGNEDSTATE_MISSING,
    isActive: false,
    appDisabled: true,
    isCompatible: false,
  }, {
    id: "addon11@tests.mozilla.org",
    name: "Test add-on 11",
    signedState: AddonManager.SIGNEDSTATE_PRELIMINARY,
    foreignInstall: true,
    isActive: false,
    appDisabled: true,
    isCompatible: false,
  }, {
    id: "addon12@tests.mozilla.org",
    name: "Test add-on 12",
    signedState: AddonManager.SIGNEDSTATE_SIGNED,
    foreignInstall: true,
  }, {
    id: "hotfix@tests.mozilla.org",
    name: "Test hotfix 1",
  }]);

  open_manager(null, function(aWindow) {
    gManagerWindow = aWindow;
    gCategoryUtilities = new CategoryUtilities(gManagerWindow);

    run_next_test();
  });
}

function end_test() {
  Services.prefs.clearUserPref(PREF_EM_HOTFIX_ID);
  close_manager(gManagerWindow, function() {
    finish();
  });
}

// Opens and tests the details view for add-on 1
add_test(function() {
  open_details("addon1@tests.mozilla.org", "extension", function() {
    is(get("detail-name").textContent, "Test add-on 1", "Name should be correct");
    is_element_visible(get("detail-version"), "Version should not be hidden");
    is(get("detail-version").value, "2.1", "Version should be correct");
    is(get("detail-icon").src, "chrome://foo/skin/icon64.png", "Icon should be correct");
    is_element_hidden(get("detail-creator"), "Creator should be hidden");
    is_element_hidden(get("detail-screenshot-box"), "Screenshot should be hidden");
    is(get("detail-screenshot").width, "", "Screenshot dimensions should not be set");
    is(get("detail-screenshot").height, "", "Screenshot dimensions should not be set");
    is(get("detail-desc").textContent, "Short description", "Description should be correct");
    is(get("detail-fulldesc").textContent, "Longer description", "Full description should be correct");

    is_element_visible(get("detail-contributions"), "Contributions section should be visible");
    is_element_visible(get("detail-contrib-suggested"), "Contributions amount should be visible");
    ok(get("detail-contrib-suggested").value, "$0.99");

    is_element_visible(get("detail-updates-row"), "Updates should not be hidden");
    is_element_hidden(get("detail-dateUpdated"), "Update date should be hidden");

    is_element_visible(get("detail-rating-row"), "Rating row should not be hidden");
    is_element_visible(get("detail-rating"), "Rating should not be hidden");
    is(get("detail-rating").averageRating, 4, "Rating should be correct");
    is_element_visible(get("detail-reviews"), "Reviews should not be hidden");
    is(get("detail-reviews").href, "http://example.com/reviews", "Review URL should be correct");
    is(get("detail-reviews").value, "5 reviews", "Review text should be correct");

    is_element_visible(get("detail-homepage-row"), "Homepage should be visible");
    ok(get("detail-homepage").href, "http://example.com/addon1");
    is_element_hidden(get("detail-repository-row"), "Repository profile should not be visible");

    is_element_hidden(get("detail-size"), "Size should be hidden");

    is_element_hidden(get("detail-downloads"), "Downloads should be hidden");

    is_element_visible(get("detail-autoUpdate"), "Updates should not be hidden");
    ok(get("detail-autoUpdate").childNodes[1].selected, "Updates ahould be automatic");
    is_element_hidden(get("detail-findUpdates-btn"), "Check for updates should be hidden");
    EventUtils.synthesizeMouseAtCenter(get("detail-autoUpdate").lastChild, {}, gManagerWindow);
    ok(get("detail-autoUpdate").lastChild.selected, "Updates should be manual");
    is_element_visible(get("detail-findUpdates-btn"), "Check for updates should be visible");
    EventUtils.synthesizeMouseAtCenter(get("detail-autoUpdate").firstChild, {}, gManagerWindow);
    ok(get("detail-autoUpdate").firstChild.selected, "Updates should be automatic");
    is_element_hidden(get("detail-findUpdates-btn"), "Check for updates should be hidden");

    is_element_hidden(get("detail-prefs-btn"), "Preferences button should be hidden");
    is_element_hidden(get("detail-enable-btn"), "Enable button should be hidden");
    is_element_visible(get("detail-disable-btn"), "Disable button should be visible");
    is_element_visible(get("detail-uninstall-btn"), "Remove button should be visible");

    is_element_hidden(get("detail-warning"), "Warning message should be hidden");
    is_element_hidden(get("detail-warning-link"), "Warning link should be hidden");
    is_element_hidden(get("detail-error"), "Error message should be hidden");
    is_element_hidden(get("detail-pending"), "Pending message should be hidden");

    // Disable it
    EventUtils.synthesizeMouseAtCenter(get("detail-disable-btn"), {}, gManagerWindow);
    is_element_hidden(get("detail-prefs-btn"), "Preferences button should be hidden");
    is_element_visible(get("detail-enable-btn"), "Enable button should be visible");
    is_element_hidden(get("detail-disable-btn"), "Disable button should be hidden");
    is_element_visible(get("detail-uninstall-btn"), "Remove button should be visible");

    is_element_hidden(get("detail-warning"), "Warning message should be hidden");
    is_element_hidden(get("detail-warning-link"), "Warning link should be hidden");
    is_element_hidden(get("detail-error"), "Error message should be hidden");
    is_element_hidden(get("detail-error-link"), "Error link should be hidden");
    is_element_visible(get("detail-pending"), "Pending message should be visible");
    is(get("detail-pending").textContent, "Test add-on 1 will be disabled after you restart " + gApp + ".", "Pending message should be correct");

    // Reopen it
    open_details("addon1@tests.mozilla.org", "extension", function() {
      is_element_hidden(get("detail-prefs-btn"), "Preferences button should be hidden");
      is_element_visible(get("detail-enable-btn"), "Enable button should be visible");
      is_element_hidden(get("detail-disable-btn"), "Disable button should be hidden");
      is_element_visible(get("detail-uninstall-btn"), "Remove button should be visible");

      is_element_hidden(get("detail-warning"), "Warning message should be hidden");
      is_element_hidden(get("detail-warning-link"), "Warning link should be hidden");
      is_element_hidden(get("detail-error"), "Error message should be hidden");
      is_element_hidden(get("detail-error-link"), "Error link should be hidden");
      is_element_visible(get("detail-pending"), "Pending message should be visible");
      is(get("detail-pending").textContent, "Test add-on 1 will be disabled after you restart " + gApp + ".", "Pending message should be correct");

      // Undo disabling
      EventUtils.synthesizeMouseAtCenter(get("detail-undo-btn"), {}, gManagerWindow);
      is_element_hidden(get("detail-prefs-btn"), "Preferences button should be hidden");
      is_element_hidden(get("detail-enable-btn"), "Enable button should be hidden");
      is_element_visible(get("detail-disable-btn"), "Disable button should be visible");
      is_element_visible(get("detail-uninstall-btn"), "Remove button should be visible");

      is_element_hidden(get("detail-warning"), "Warning message should be hidden");
      is_element_hidden(get("detail-warning-link"), "Warning link should be hidden");
      is_element_hidden(get("detail-error"), "Error message should be hidden");
      is_element_hidden(get("detail-error-link"), "Error link should be hidden");
      is_element_hidden(get("detail-pending"), "Pending message should be hidden");

      run_next_test();
    });
  });
});

// Opens and tests the details view for add-on 2
add_test(function() {
  open_details("addon2@tests.mozilla.org", "extension", function() {
    is(get("detail-name").textContent, "Test add-on 2", "Name should be correct");
    is_element_visible(get("detail-version"), "Version should not be hidden");
    is(get("detail-version").value, "2.2", "Version should be correct");
    is(get("detail-icon").src, "chrome://foo/skin/icon.png", "Icon should be correct");

    is_element_visible(get("detail-creator"), "Creator should not be hidden");
    is_element_visible(get("detail-creator")._creatorName, "Creator name should not be hidden");
    is(get("detail-creator")._creatorName.value, "Mozilla", "Creator should be correct");
    is_element_hidden(get("detail-creator")._creatorLink, "Creator link should be hidden");

    is_element_visible(get("detail-screenshot-box"), "Screenshot should be visible");
    is(get("detail-screenshot").src, "chrome://branding/content/about.png", "Should be showing the full sized screenshot");
    is(get("detail-screenshot").width, 200, "Screenshot dimensions should be set");
    is(get("detail-screenshot").height, 150, "Screenshot dimensions should be set");
    is(get("detail-screenshot").hasAttribute("loading"), true, "Screenshot should have loading attribute");
    is(get("detail-desc").textContent, "Short description", "Description should be correct");
    is_element_hidden(get("detail-fulldesc"), "Full description should be hidden");

    is_element_visible(get("detail-contributions"), "Contributions section should be visible");
    is_element_hidden(get("detail-contrib-suggested"), "Contributions amount should be hidden");

    is_element_visible(get("detail-dateUpdated"), "Update date should not be hidden");
    is(get("detail-dateUpdated").value, formatDate(gDate), "Update date should be correct");

    is_element_hidden(get("detail-rating-row"), "Rating should be hidden");

    is_element_hidden(get("detail-homepage-row"), "Homepage should not be visible");
    is_element_hidden(get("detail-repository-row"), "Repository profile should not be visible");

    is_element_hidden(get("detail-size"), "Size should be hidden");

    is_element_hidden(get("detail-downloads"), "Downloads should be hidden");

    is_element_hidden(get("detail-updates-row"), "Updates should be hidden");

    is_element_hidden(get("detail-prefs-btn"), "Preferences button should be hidden");
    is_element_hidden(get("detail-enable-btn"), "Enable button should be hidden");
    is_element_hidden(get("detail-disable-btn"), "Disable button should be hidden");
    is_element_hidden(get("detail-uninstall-btn"), "Remove button should be hidden");

    is_element_hidden(get("detail-warning"), "Warning message should be hidden");
    is_element_hidden(get("detail-warning-link"), "Warning link should be hidden");
    is_element_hidden(get("detail-error"), "Error message should be hidden");
    is_element_hidden(get("detail-error-link"), "Error link should be hidden");
    is_element_hidden(get("detail-pending"), "Pending message should be hidden");

    get("detail-screenshot").addEventListener("load", function() {
      this.removeEventListener("load", arguments.callee, false);
      is(this.hasAttribute("loading"), false, "Screenshot should not have loading attribute");
      run_next_test();
    }, false);
  });
});

// Opens and tests the details view for add-on 3
add_test(function() {
  open_details("addon3@tests.mozilla.org", "extension", function() {
    is(get("detail-name").textContent, "Test add-on 3", "Name should be correct");
    is_element_hidden(get("detail-version"), "Version should be hidden");
    is(get("detail-icon").src, "", "Icon should be correct");

    is_element_visible(get("detail-creator"), "Creator should not be hidden");
    is_element_hidden(get("detail-creator")._creatorName, "Creator name should be hidden");
    is_element_visible(get("detail-creator")._creatorLink, "Creator link should not be hidden");
    is(get("detail-creator")._creatorLink.value, "Mozilla", "Creator link should be correct");
    is(get("detail-creator")._creatorLink.href, "http://www.mozilla.org", "Creator link href should be correct");

    is_element_visible(get("detail-screenshot-box"), "Screenshot should be visible");
    is(get("detail-screenshot").src, "chrome://branding/content/icon64.png", "Should be showing the thumbnail");
    is(get("detail-screenshot").width, 160, "Screenshot dimensions should be set");
    is(get("detail-screenshot").height, 120, "Screenshot dimensions should be set");
    is(get("detail-screenshot").hasAttribute("loading"), true, "Screenshot should have loading attribute");

    is_element_hidden(get("detail-contributions"), "Contributions section should be hidden");

    is_element_visible(get("detail-updates-row"), "Updates should not be hidden");
    is_element_visible(get("detail-dateUpdated"), "Update date should not be hidden");
    is(get("detail-dateUpdated").value, formatDate(gDate), "Update date should be correct");

    is_element_visible(get("detail-rating-row"), "Rating row should not be hidden");
    is_element_hidden(get("detail-rating"), "Rating should be hidden");
    is_element_visible(get("detail-reviews"), "Reviews should not be hidden");
    is(get("detail-reviews").href, "http://example.com/reviews", "Review URL should be correct");
    is(get("detail-reviews").value, "1 review", "Review text should be correct");

    is_element_hidden(get("detail-size"), "Size should be hidden");

    is_element_hidden(get("detail-downloads"), "Downloads should be hidden");

    is_element_visible(get("detail-autoUpdate"), "Updates should not be hidden");
    ok(get("detail-autoUpdate").lastChild.selected, "Updates should be manual");
    is_element_visible(get("detail-findUpdates-btn"), "Check for updates should be visible");
    EventUtils.synthesizeMouseAtCenter(get("detail-autoUpdate").childNodes[1], {}, gManagerWindow);
    ok(get("detail-autoUpdate").childNodes[1].selected, "Updates should be automatic");
    is_element_hidden(get("detail-findUpdates-btn"), "Check for updates should be hidden");
    EventUtils.synthesizeMouseAtCenter(get("detail-autoUpdate").lastChild, {}, gManagerWindow);
    ok(get("detail-autoUpdate").lastChild.selected, "Updates should be manual");
    is_element_visible(get("detail-findUpdates-btn"), "Check for updates should be visible");

    info("Setting " + PREF_AUTOUPDATE_DEFAULT + " to true");
    Services.prefs.setBoolPref(PREF_AUTOUPDATE_DEFAULT, true);
    EventUtils.synthesizeMouseAtCenter(get("detail-autoUpdate").firstChild, {}, gManagerWindow);
    ok(get("detail-autoUpdate").firstChild.selected, "Updates should be default");
    is_element_hidden(get("detail-findUpdates-btn"), "Check for updates should be hidden");

    info("Setting " + PREF_AUTOUPDATE_DEFAULT + " to false");
    Services.prefs.setBoolPref(PREF_AUTOUPDATE_DEFAULT, false);
    ok(get("detail-autoUpdate").firstChild.selected, "Updates should be default");
    is_element_visible(get("detail-findUpdates-btn"), "Check for updates should be visible");
    EventUtils.synthesizeMouseAtCenter(get("detail-autoUpdate").childNodes[1], {}, gManagerWindow);
    ok(get("detail-autoUpdate").childNodes[1].selected, "Updates should be automatic");
    is_element_hidden(get("detail-findUpdates-btn"), "Check for updates should be hidden");
    EventUtils.synthesizeMouseAtCenter(get("detail-autoUpdate").firstChild, {}, gManagerWindow);
    ok(get("detail-autoUpdate").firstChild.selected, "Updates should be default");
    is_element_visible(get("detail-findUpdates-btn"), "Check for updates should be visible");
    Services.prefs.clearUserPref(PREF_AUTOUPDATE_DEFAULT);

    is_element_hidden(get("detail-prefs-btn"), "Preferences button should be hidden");
    is_element_hidden(get("detail-enable-btn"), "Enable button should be hidden");
    is_element_hidden(get("detail-disable-btn"), "Disable button should be hidden");
    is_element_hidden(get("detail-uninstall-btn"), "Remove button should be hidden");

    is_element_visible(get("detail-warning"), "Warning message should be visible");
    is(get("detail-warning").textContent, "Test add-on 3 is incompatible with " + gApp + " " + gVersion + ".", "Warning message should be correct");
    is_element_hidden(get("detail-warning-link"), "Warning link should be hidden");
    is_element_hidden(get("detail-error"), "Error message should be hidden");
    is_element_hidden(get("detail-error-link"), "Error link should be hidden");
    is_element_hidden(get("detail-pending"), "Pending message should be hidden");

    get("detail-screenshot").addEventListener("load", function() {
      this.removeEventListener("load", arguments.callee, false);
      is(this.hasAttribute("loading"), false, "Screenshot should not have loading attribute");
      run_next_test();
    }, false);
  });
});

// Opens and tests the details view for add-on 4
add_test(function() {
  open_details("addon4@tests.mozilla.org", "extension", function() {
    is(get("detail-name").textContent, "Test add-on 4", "Name should be correct");

    is_element_hidden(get("detail-prefs-btn"), "Preferences button should be hidden");
    is_element_visible(get("detail-enable-btn"), "Enable button should be visible");
    is_element_hidden(get("detail-disable-btn"), "Disable button should be hidden");
    is_element_visible(get("detail-uninstall-btn"), "Remove button should be visible");

    is_element_visible(get("detail-warning"), "Warning message should be visible");
    is(get("detail-warning").textContent, "Test add-on 4 is known to cause security or stability issues.", "Warning message should be correct");
    is_element_visible(get("detail-warning-link"), "Warning link should be visible");
    is(get("detail-warning-link").value, "More Information", "Warning link text should be correct");
    is(get("detail-warning-link").href, "http://example.com/addon4@tests.mozilla.org", "Warning link should be correct");
    is_element_hidden(get("detail-error"), "Error message should be hidden");
    is_element_hidden(get("detail-error-link"), "Error link should be hidden");
    is_element_hidden(get("detail-pending"), "Pending message should be hidden");

    // Enable it
    EventUtils.synthesizeMouseAtCenter(get("detail-enable-btn"), {}, gManagerWindow);
    is_element_hidden(get("detail-prefs-btn"), "Preferences button should be hidden");
    is_element_hidden(get("detail-enable-btn"), "Enable button should be hidden");
    is_element_visible(get("detail-disable-btn"), "Disable button should be visible");
    is_element_visible(get("detail-uninstall-btn"), "Remove button should be visible");

    is_element_hidden(get("detail-warning"), "Warning message should be hidden");
    is_element_hidden(get("detail-warning-link"), "Warning link should be hidden");
    is_element_hidden(get("detail-error"), "Error message should be hidden");
    is_element_hidden(get("detail-error-link"), "Error link should be hidden");
    is_element_visible(get("detail-pending"), "Pending message should be visible");
    is(get("detail-pending").textContent, "Test add-on 4 will be enabled after you restart " + gApp + ".", "Pending message should be correct");

    // Reopen it
    open_details("addon4@tests.mozilla.org", "extension", function() {
      is_element_hidden(get("detail-prefs-btn"), "Preferences button should be hidden");
      is_element_hidden(get("detail-enable-btn"), "Enable button should be hidden");
      is_element_visible(get("detail-disable-btn"), "Disable button should be visible");
      is_element_visible(get("detail-uninstall-btn"), "Remove button should be visible");

      is_element_hidden(get("detail-warning"), "Warning message should be hidden");
      is_element_hidden(get("detail-warning-link"), "Warning link should be hidden");
      is_element_hidden(get("detail-error"), "Error message should be hidden");
      is_element_hidden(get("detail-error-link"), "Error link should be hidden");
      is_element_visible(get("detail-pending"), "Pending message should be visible");
      is(get("detail-pending").textContent, "Test add-on 4 will be enabled after you restart " + gApp + ".", "Pending message should be correct");

      // Undo enabling
      EventUtils.synthesizeMouseAtCenter(get("detail-undo-btn"), {}, gManagerWindow);
      is_element_hidden(get("detail-prefs-btn"), "Preferences button should be hidden");
      is_element_visible(get("detail-enable-btn"), "Enable button should be visible");
      is_element_hidden(get("detail-disable-btn"), "Disable button should be hidden");
      is_element_visible(get("detail-uninstall-btn"), "Remove button should be visible");

      is_element_visible(get("detail-warning"), "Warning message should be visible");
      is(get("detail-warning").textContent, "Test add-on 4 is known to cause security or stability issues.", "Warning message should be correct");
      is_element_visible(get("detail-warning-link"), "Warning link should be visible");
      is(get("detail-warning-link").value, "More Information", "Warning link text should be correct");
      is(get("detail-warning-link").href, "http://example.com/addon4@tests.mozilla.org", "Warning link should be correct");
      is_element_hidden(get("detail-error"), "Error message should be hidden");
      is_element_hidden(get("detail-error-link"), "Error link should be hidden");
      is_element_hidden(get("detail-pending"), "Pending message should be hidden");

      run_next_test();
    });
  });
});

// Opens and tests the details view for add-on 5
add_test(function() {
  open_details("addon5@tests.mozilla.org", "extension", function() {
    is(get("detail-name").textContent, "Test add-on 5", "Name should be correct");

    is_element_hidden(get("detail-prefs-btn"), "Preferences button should be hidden");
    is_element_hidden(get("detail-enable-btn"), "Enable button should be hidden");
    is_element_hidden(get("detail-disable-btn"), "Disable button should be hidden");
    is_element_visible(get("detail-uninstall-btn"), "Remove button should be visible");

    is_element_hidden(get("detail-warning"), "Warning message should be hidden");
    is_element_hidden(get("detail-warning-link"), "Warning link should be hidden");
    is_element_visible(get("detail-error"), "Error message should be visible");
    is(get("detail-error").textContent, "Test add-on 5 has been disabled due to security or stability issues.", "Error message should be correct");
    is_element_visible(get("detail-error-link"), "Error link should be visible");
    is(get("detail-error-link").value, "More Information", "Error link text should be correct");
    is(get("detail-error-link").href, "http://example.com/addon5@tests.mozilla.org", "Error link should be correct");
    is_element_hidden(get("detail-pending"), "Pending message should be hidden");

    run_next_test();
  });
});

// Opens and tests the details view for add-on 6
add_test(function() {
  open_details("addon6@tests.mozilla.org", "extension", function() {
    is(get("detail-name").textContent, "Test add-on 6", "Name should be correct");

    is_element_hidden(get("detail-prefs-btn"), "Preferences button should be hidden");
    is_element_hidden(get("detail-enable-btn"), "Enable button should be hidden");
    is_element_visible(get("detail-disable-btn"), "Disable button should be visible");
    is_element_visible(get("detail-uninstall-btn"), "Remove button should be visible");

    is_element_hidden(get("detail-warning"), "Warning message should be hidden");
    is_element_hidden(get("detail-warning-link"), "Warning link should be hidden");
    is_element_hidden(get("detail-error"), "Error message should be hidden");
    is_element_hidden(get("detail-error-link"), "Error link should be hidden");
    is_element_hidden(get("detail-pending"), "Pending message should be hidden");

    // Disable it
    EventUtils.synthesizeMouseAtCenter(get("detail-disable-btn"), {}, gManagerWindow);
    is_element_hidden(get("detail-prefs-btn"), "Preferences button should be hidden");
    is_element_visible(get("detail-enable-btn"), "Enable button should be visible");
    is_element_hidden(get("detail-disable-btn"), "Disable button should be hidden");
    is_element_visible(get("detail-uninstall-btn"), "Remove button should be visible");

    is_element_hidden(get("detail-warning"), "Warning message should be hidden");
    is_element_hidden(get("detail-warning-link"), "Warning link should be hidden");
    is_element_hidden(get("detail-error"), "Error message should be hidden");
    is_element_hidden(get("detail-error-link"), "Error link should be hidden");
    is_element_hidden(get("detail-pending"), "Pending message should be hidden");

    // Reopen it
    open_details("addon6@tests.mozilla.org", "extension", function() {
      is_element_hidden(get("detail-prefs-btn"), "Preferences button should be hidden");
      is_element_visible(get("detail-enable-btn"), "Enable button should be visible");
      is_element_hidden(get("detail-disable-btn"), "Disable button should be hidden");
      is_element_visible(get("detail-uninstall-btn"), "Remove button should be visible");

      is_element_hidden(get("detail-warning"), "Warning message should be hidden");
      is_element_hidden(get("detail-warning-link"), "Warning link should be hidden");
      is_element_hidden(get("detail-error"), "Error message should be hidden");
      is_element_hidden(get("detail-error-link"), "Error link should be hidden");
      is_element_hidden(get("detail-pending"), "Pending message should be visible");

      // Enable it
      EventUtils.synthesizeMouseAtCenter(get("detail-enable-btn"), {}, gManagerWindow);
      is_element_hidden(get("detail-prefs-btn"), "Preferences button should be hidden");
      is_element_hidden(get("detail-enable-btn"), "Enable button should be hidden");
      is_element_visible(get("detail-disable-btn"), "Disable button should be visible");
      is_element_visible(get("detail-uninstall-btn"), "Remove button should be visible");

      is_element_hidden(get("detail-warning"), "Warning message should be hidden");
      is_element_hidden(get("detail-warning-link"), "Warning link should be hidden");
      is_element_hidden(get("detail-error"), "Error message should be hidden");
      is_element_hidden(get("detail-error-link"), "Error link should be hidden");
      is_element_hidden(get("detail-pending"), "Pending message should be hidden");

      run_next_test();
    });
  });
});

// Opens and tests the details view for add-on 7
add_test(function() {
  open_details("addon7@tests.mozilla.org", "extension", function() {
    is(get("detail-name").textContent, "Test add-on 7", "Name should be correct");

    is_element_hidden(get("detail-prefs-btn"), "Preferences button should be hidden");
    is_element_visible(get("detail-enable-btn"), "Enable button should be visible");
    is_element_hidden(get("detail-disable-btn"), "Disable button should be hidden");
    is_element_visible(get("detail-uninstall-btn"), "Remove button should be visible");

    is_element_hidden(get("detail-warning"), "Warning message should be hidden");
    is_element_hidden(get("detail-warning-link"), "Warning link should be hidden");
    is_element_hidden(get("detail-error"), "Error message should be hidden");
    is_element_hidden(get("detail-error-link"), "Error link should be hidden");
    is_element_hidden(get("detail-pending"), "Pending message should be hidden");

    // Enable it
    EventUtils.synthesizeMouseAtCenter(get("detail-enable-btn"), {}, gManagerWindow);
    is_element_hidden(get("detail-prefs-btn"), "Preferences button should be hidden");
    is_element_hidden(get("detail-enable-btn"), "Enable button should be hidden");
    is_element_visible(get("detail-disable-btn"), "Disable button should be visible");
    is_element_visible(get("detail-uninstall-btn"), "Remove button should be visible");

    is_element_hidden(get("detail-warning"), "Warning message should be hidden");
    is_element_hidden(get("detail-warning-link"), "Warning link should be hidden");
    is_element_hidden(get("detail-error"), "Error message should be hidden");
    is_element_hidden(get("detail-error-link"), "Error link should be hidden");
    is_element_visible(get("detail-pending"), "Pending message should be visible");
    is(get("detail-pending").textContent, "Test add-on 7 will be enabled after you restart " + gApp + ".", "Pending message should be correct");

    // Reopen it
    open_details("addon7@tests.mozilla.org", "extension", function() {
      is_element_hidden(get("detail-prefs-btn"), "Preferences button should be hidden");
      is_element_hidden(get("detail-enable-btn"), "Enable button should be hidden");
      is_element_visible(get("detail-disable-btn"), "Disable button should be visible");
      is_element_visible(get("detail-uninstall-btn"), "Remove button should be visible");

      is_element_hidden(get("detail-warning"), "Warning message should be hidden");
      is_element_hidden(get("detail-warning-link"), "Warning link should be hidden");
      is_element_hidden(get("detail-error"), "Error message should be hidden");
      is_element_hidden(get("detail-error-link"), "Error link should be hidden");
      is_element_visible(get("detail-pending"), "Pending message should be visible");
      is(get("detail-pending").textContent, "Test add-on 7 will be enabled after you restart " + gApp + ".", "Pending message should be correct");

      // Undo enabling
      EventUtils.synthesizeMouseAtCenter(get("detail-undo-btn"), {}, gManagerWindow);
      is_element_hidden(get("detail-prefs-btn"), "Preferences button should be hidden");
      is_element_visible(get("detail-enable-btn"), "Enable button should be visible");
      is_element_hidden(get("detail-disable-btn"), "Disable button should be hidden");
      is_element_visible(get("detail-uninstall-btn"), "Remove button should be visible");

      is_element_hidden(get("detail-warning"), "Warning message should be hidden");
      is_element_hidden(get("detail-warning-link"), "Warning link should be hidden");
      is_element_hidden(get("detail-error"), "Error message should be hidden");
      is_element_hidden(get("detail-error-link"), "Error link should be hidden");
      is_element_hidden(get("detail-pending"), "Pending message should be hidden");

      run_next_test();
    });
  });
});

// Opens and tests the details view for add-on 8
add_test(function() {
  open_details("addon8@tests.mozilla.org", "extension", function() {
    is(get("detail-name").textContent, "Test add-on 8", "Name should be correct");

    is_element_hidden(get("detail-prefs-btn"), "Preferences button should be hidden");
    is_element_hidden(get("detail-enable-btn"), "Enable button should be hidden");
    is_element_visible(get("detail-disable-btn"), "Disable button should be visible");
    is_element_visible(get("detail-uninstall-btn"), "Remove button should be visible");

    is_element_visible(get("detail-warning"), "Warning message should be visible");
    is(get("detail-warning").textContent, "An important update is available for Test add-on 8.", "Warning message should be correct");
    is_element_visible(get("detail-warning-link"), "Warning link should be visible");
    is(get("detail-warning-link").value, "Update Now", "Warning link text should be correct");
    is(get("detail-warning-link").href, "http://example.com/addon8@tests.mozilla.org", "Warning link should be correct");
    is_element_hidden(get("detail-error"), "Error message should be hidden");
    is_element_hidden(get("detail-error-link"), "Error link should be hidden");
    is_element_hidden(get("detail-pending"), "Pending message should be hidden");

    // Disable it
    EventUtils.synthesizeMouseAtCenter(get("detail-disable-btn"), {}, gManagerWindow);
    is_element_hidden(get("detail-prefs-btn"), "Preferences button should be hidden");
    is_element_visible(get("detail-enable-btn"), "Enable button should be visible");
    is_element_hidden(get("detail-disable-btn"), "Disable button should be hidden");
    is_element_visible(get("detail-uninstall-btn"), "Remove button should be visible");

    is_element_hidden(get("detail-warning"), "Warning message should be hidden");
    is_element_hidden(get("detail-warning-link"), "Warning link should be hidden");
    is_element_hidden(get("detail-error"), "Error message should be hidden");
    is_element_hidden(get("detail-error-link"), "Error link should be hidden");
    is_element_visible(get("detail-pending"), "Pending message should be visible");
    is(get("detail-pending").textContent, "Test add-on 8 will be disabled after you restart " + gApp + ".", "Pending message should be correct");

    // Reopen it
    open_details("addon8@tests.mozilla.org", "extension", function() {
      is_element_hidden(get("detail-prefs-btn"), "Preferences button should be hidden");
      is_element_visible(get("detail-enable-btn"), "Enable button should be visible");
      is_element_hidden(get("detail-disable-btn"), "Disable button should be hidden");
      is_element_visible(get("detail-uninstall-btn"), "Remove button should be visible");

      is_element_hidden(get("detail-warning"), "Warning message should be hidden");
      is_element_hidden(get("detail-warning-link"), "Warning link should be hidden");
      is_element_hidden(get("detail-error"), "Error message should be hidden");
      is_element_hidden(get("detail-error-link"), "Error link should be hidden");
      is_element_visible(get("detail-pending"), "Pending message should be visible");
      is(get("detail-pending").textContent, "Test add-on 8 will be disabled after you restart " + gApp + ".", "Pending message should be correct");

      // Undo disabling
      EventUtils.synthesizeMouseAtCenter(get("detail-undo-btn"), {}, gManagerWindow);
      is_element_hidden(get("detail-prefs-btn"), "Preferences button should be hidden");
      is_element_hidden(get("detail-enable-btn"), "Enable button should be hidden");
      is_element_visible(get("detail-disable-btn"), "Disable button should be visible");
      is_element_visible(get("detail-uninstall-btn"), "Remove button should be visible");

      is_element_visible(get("detail-warning"), "Warning message should be visible");
      is(get("detail-warning").textContent, "An important update is available for Test add-on 8.", "Warning message should be correct");
      is_element_visible(get("detail-warning-link"), "Warning link should be visible");
      is(get("detail-warning-link").value, "Update Now", "Warning link text should be correct");
      is(get("detail-warning-link").href, "http://example.com/addon8@tests.mozilla.org", "Warning link should be correct");
      is_element_hidden(get("detail-error"), "Error message should be hidden");
      is_element_hidden(get("detail-error-link"), "Error link should be hidden");
      is_element_hidden(get("detail-pending"), "Pending message should be hidden");

      run_next_test();
    });
  });
});

// These tests are only appropriate when signing can be turned off
if (!REQUIRE_SIGNING) {
  // Opens and tests the details view for add-on 9
  add_test(function() {
    open_details("addon9@tests.mozilla.org", "extension", function() {
      is(get("detail-name").textContent, "Test add-on 9", "Name should be correct");

      is_element_hidden(get("detail-prefs-btn"), "Preferences button should be hidden");
      is_element_hidden(get("detail-enable-btn"), "Enable button should be hidden");
      is_element_visible(get("detail-disable-btn"), "Disable button should be visible");
      is_element_visible(get("detail-uninstall-btn"), "Remove button should be visible");

      is_element_hidden(get("detail-error"), "Error message should be hidden");
      is_element_hidden(get("detail-error-link"), "Error link should be hidden");
      is_element_visible(get("detail-warning"), "Error message should be visible");
      is(get("detail-warning").textContent, "Test add-on 9 could not be verified for use in " + gApp + ". Proceed with caution.", "Warning message should be correct");
      is_element_visible(get("detail-warning-link"), "Warning link should be visible");
      is(get("detail-warning-link").value, "More Information", "Warning link text should be correct");
      is(get("detail-warning-link").href, infoURL, "Warning link should be correct");
      is_element_hidden(get("detail-pending"), "Pending message should be hidden");

      run_next_test();
    });
  });
}

// Opens and tests the details view for add-on 9 with signing required
add_test(function() {
  close_manager(gManagerWindow, function() {
    Services.prefs.setBoolPref("xpinstall.signatures.required", true);
    open_manager(null, function(aWindow) {
      gManagerWindow = aWindow;
      gCategoryUtilities = new CategoryUtilities(gManagerWindow);

      open_details("addon9@tests.mozilla.org", "extension", function() {
        is(get("detail-name").textContent, "Test add-on 9", "Name should be correct");

        is_element_hidden(get("detail-prefs-btn"), "Preferences button should be hidden");
        is_element_hidden(get("detail-enable-btn"), "Enable button should be hidden");
        is_element_visible(get("detail-disable-btn"), "Disable button should be visible");
        is_element_visible(get("detail-uninstall-btn"), "Remove button should be visible");

        is_element_hidden(get("detail-warning"), "Warning message should be hidden");
        is_element_hidden(get("detail-warning-link"), "Warning link should be hidden");
        is_element_visible(get("detail-error"), "Error message should be visible");
        is(get("detail-error").textContent, "Test add-on 9 could not be verified for use in " + gApp + " and has been disabled.", "Error message should be correct");
        is_element_visible(get("detail-error-link"), "Error link should be visible");
        is(get("detail-error-link").value, "More Information", "Error link text should be correct");
        is(get("detail-error-link").href, infoURL, "Error link should be correct");

        close_manager(gManagerWindow, function() {
          Services.prefs.setBoolPref("xpinstall.signatures.required", false);
          open_manager(null, function(aWindow) {
            gManagerWindow = aWindow;
            gCategoryUtilities = new CategoryUtilities(gManagerWindow);

            run_next_test();
          });
        });
      });
    });
  });
});

// These tests are only appropriate when signing can be turned off
if (!REQUIRE_SIGNING) {
  // Opens and tests the details view for add-on 10
  add_test(function() {
    open_details("addon10@tests.mozilla.org", "extension", function() {
      is(get("detail-name").textContent, "Test add-on 10", "Name should be correct");

      is_element_hidden(get("detail-prefs-btn"), "Preferences button should be hidden");
      is_element_hidden(get("detail-enable-btn"), "Enable button should be hidden");
      is_element_hidden(get("detail-disable-btn"), "Disable button should be hidden");
      is_element_visible(get("detail-uninstall-btn"), "Remove button should be visible");

      is_element_visible(get("detail-warning"), "Warning message should be visible");
      is(get("detail-warning").textContent, "Test add-on 10 is incompatible with " + gApp + " " + gVersion + ".", "Warning message should be correct");
      is_element_hidden(get("detail-warning-link"), "Warning link should be hidden");
      is_element_hidden(get("detail-error"), "Error message should be hidden");
      is_element_hidden(get("detail-error-link"), "Error link should be hidden");
      is_element_hidden(get("detail-pending"), "Pending message should be hidden");

      run_next_test();
    });
  });
}

// Opens and tests the details view for add-on 10 with signing required
add_test(function() {
  close_manager(gManagerWindow, function() {
    Services.prefs.setBoolPref("xpinstall.signatures.required", true);
    open_manager(null, function(aWindow) {
      gManagerWindow = aWindow;
      gCategoryUtilities = new CategoryUtilities(gManagerWindow);

      open_details("addon10@tests.mozilla.org", "extension", function() {
        is(get("detail-name").textContent, "Test add-on 10", "Name should be correct");

        is_element_hidden(get("detail-prefs-btn"), "Preferences button should be hidden");
        is_element_hidden(get("detail-enable-btn"), "Enable button should be hidden");
        is_element_hidden(get("detail-disable-btn"), "Disable button should be hidden");
        is_element_visible(get("detail-uninstall-btn"), "Remove button should be visible");

        is_element_hidden(get("detail-warning"), "Warning message should be hidden");
        is_element_hidden(get("detail-warning-link"), "Warning link should be hidden");
        is_element_visible(get("detail-error"), "Error message should be visible");
        is(get("detail-error").textContent, "Test add-on 10 could not be verified for use in " + gApp + " and has been disabled.", "Error message should be correct");
        is_element_visible(get("detail-error-link"), "Error link should be visible");
        is(get("detail-error-link").value, "More Information", "Error link text should be correct");
        is(get("detail-error-link").href, infoURL, "Error link should be correct");

        close_manager(gManagerWindow, function() {
          Services.prefs.setBoolPref("xpinstall.signatures.required", false);
          open_manager(null, function(aWindow) {
            gManagerWindow = aWindow;
            gCategoryUtilities = new CategoryUtilities(gManagerWindow);

            run_next_test();
          });
        });
      });
    });
  });
});

// Opens and tests the details view for add-on 11
add_test(function() {
  open_details("addon11@tests.mozilla.org", "extension", function() {
    is(get("detail-name").textContent, "Test add-on 11", "Name should be correct");

    is_element_hidden(get("detail-prefs-btn"), "Preferences button should be hidden");
    is_element_hidden(get("detail-enable-btn"), "Enable button should be hidden");
    is_element_hidden(get("detail-disable-btn"), "Disable button should be hidden");
    is_element_visible(get("detail-uninstall-btn"), "Remove button should be visible");

    is_element_visible(get("detail-warning"), "Warning message should be visible");
    is(get("detail-warning").textContent, "Test add-on 11 is incompatible with " + gApp + " " + gVersion + ".", "Warning message should be correct");
    is_element_hidden(get("detail-warning-link"), "Warning link should be hidden");
    is_element_hidden(get("detail-error"), "Error message should be hidden");
    is_element_hidden(get("detail-error-link"), "Error link should be hidden");
    is_element_hidden(get("detail-pending"), "Pending message should be hidden");

    run_next_test();
  });
});

// Opens and tests the details view for add-on 11 with signing required
add_test(function() {
  close_manager(gManagerWindow, function() {
    Services.prefs.setBoolPref("xpinstall.signatures.required", true);
    open_manager(null, function(aWindow) {
      gManagerWindow = aWindow;
      gCategoryUtilities = new CategoryUtilities(gManagerWindow);

      open_details("addon11@tests.mozilla.org", "extension", function() {
        is(get("detail-name").textContent, "Test add-on 11", "Name should be correct");

        is_element_hidden(get("detail-prefs-btn"), "Preferences button should be hidden");
        is_element_hidden(get("detail-enable-btn"), "Enable button should be hidden");
        is_element_hidden(get("detail-disable-btn"), "Disable button should be hidden");
        is_element_visible(get("detail-uninstall-btn"), "Remove button should be visible");

        is_element_visible(get("detail-warning"), "Warning message should be visible");
        is(get("detail-warning").textContent, "Test add-on 11 is incompatible with " + gApp + " " + gVersion + ".", "Warning message should be correct");
        is_element_hidden(get("detail-warning-link"), "Warning link should be hidden");
        is_element_hidden(get("detail-error"), "Error message should be hidden");
        is_element_hidden(get("detail-error-link"), "Error link should be hidden");

        close_manager(gManagerWindow, function() {
          Services.prefs.setBoolPref("xpinstall.signatures.required", false);
          open_manager(null, function(aWindow) {
            gManagerWindow = aWindow;
            gCategoryUtilities = new CategoryUtilities(gManagerWindow);

            run_next_test();
          });
        });
      });
    });
  });
});

// Opens and tests the details view for add-on 12
add_test(function() {
  open_details("addon12@tests.mozilla.org", "extension", function() {
    is(get("detail-name").textContent, "Test add-on 12", "Name should be correct");

    is_element_hidden(get("detail-prefs-btn"), "Preferences button should be hidden");
    is_element_hidden(get("detail-enable-btn"), "Enable button should be hidden");
    is_element_visible(get("detail-disable-btn"), "Disable button should be visible");
    is_element_visible(get("detail-uninstall-btn"), "Remove button should be visible");

    is_element_hidden(get("detail-warning"), "Warning message should be hidden");
    is_element_hidden(get("detail-warning-link"), "Warning link should be hidden");
    is_element_hidden(get("detail-error"), "Error message should be hidden");
    is_element_hidden(get("detail-error-link"), "Error link should be hidden");
    is_element_hidden(get("detail-pending"), "Pending message should be hidden");

    run_next_test();
  });
});

// Opens and tests the details view for add-on 12 with signing required
add_test(function() {
  close_manager(gManagerWindow, function() {
    Services.prefs.setBoolPref("xpinstall.signatures.required", true);
    open_manager(null, function(aWindow) {
      gManagerWindow = aWindow;
      gCategoryUtilities = new CategoryUtilities(gManagerWindow);

      open_details("addon12@tests.mozilla.org", "extension", function() {
        is(get("detail-name").textContent, "Test add-on 12", "Name should be correct");

        is_element_hidden(get("detail-prefs-btn"), "Preferences button should be hidden");
        is_element_hidden(get("detail-enable-btn"), "Enable button should be hidden");
        is_element_visible(get("detail-disable-btn"), "Disable button should be visible");
        is_element_visible(get("detail-uninstall-btn"), "Remove button should be visible");

        is_element_hidden(get("detail-warning"), "Warning message should be hidden");
        is_element_hidden(get("detail-warning-link"), "Warning link should be hidden");
        is_element_hidden(get("detail-error"), "Error message should be hidden");
        is_element_hidden(get("detail-error-link"), "Error link should be hidden");

        close_manager(gManagerWindow, function() {
          Services.prefs.setBoolPref("xpinstall.signatures.required", false);
          open_manager(null, function(aWindow) {
            gManagerWindow = aWindow;
            gCategoryUtilities = new CategoryUtilities(gManagerWindow);

            run_next_test();
          });
        });
      });
    });
  });
});

// Opens and tests the details view for hotfix 1
add_test(function() {
  open_details("hotfix@tests.mozilla.org", "extension", function() {
    is(get("detail-name").textContent, "Test hotfix 1", "Name should be correct");

    is_element_hidden(get("detail-updates-row"), "Updates should be hidden");

    is_element_hidden(get("detail-prefs-btn"), "Preferences button should be hidden");
    is_element_hidden(get("detail-enable-btn"), "Enable button should be hidden");
    is_element_visible(get("detail-disable-btn"), "Disable button should be visible");
    is_element_visible(get("detail-uninstall-btn"), "Remove button should be visible");

    is_element_hidden(get("detail-warning"), "Warning message should be hidden");
    is_element_hidden(get("detail-warning-link"), "Warning link should be hidden");
    is_element_hidden(get("detail-pending"), "Pending message should be hidden");

    run_next_test();
  });
});

// Tests that upgrades with onExternalInstall apply immediately
add_test(function() {
  open_details("addon1@tests.mozilla.org", "extension", function() {
    gProvider.createAddons([{
      id: "addon1@tests.mozilla.org",
      name: "Test add-on replacement",
      version: "2.5",
      description: "Short description replacement",
      fullDescription: "Longer description replacement",
      type: "extension",
      iconURL: "chrome://foo/skin/icon.png",
      icon64URL: "chrome://foo/skin/icon264.png",
      sourceURI: Services.io.newURI("http://example.com/foo", null, null),
      averageRating: 2,
      optionsURL: "chrome://foo/content/options.xul",
      applyBackgroundUpdates: AddonManager.AUTOUPDATE_ENABLE,
      operationsRequiringRestart: AddonManager.OP_NEEDS_RESTART_NONE
    }]);

    is(get("detail-name").textContent, "Test add-on replacement", "Name should be correct");
    is_element_visible(get("detail-version"), "Version should not be hidden");
    is(get("detail-version").value, "2.5", "Version should be correct");
    is(get("detail-icon").src, "chrome://foo/skin/icon264.png", "Icon should be correct");
    is_element_hidden(get("detail-creator"), "Creator should be hidden");
    is_element_hidden(get("detail-screenshot-box"), "Screenshot should be hidden");
    is(get("detail-desc").textContent, "Short description replacement", "Description should be correct");
    is(get("detail-fulldesc").textContent, "Longer description replacement", "Full description should be correct");

    is_element_hidden(get("detail-contributions"), "Contributions section should be hidden");

    is_element_hidden(get("detail-dateUpdated"), "Update date should be hidden");

    is_element_visible(get("detail-rating-row"), "Rating row should not be hidden");
    is_element_visible(get("detail-rating"), "Rating should not be hidden");
    is(get("detail-rating").averageRating, 2, "Rating should be correct");
    is_element_hidden(get("detail-reviews"), "Reviews should be hidden");

    is_element_hidden(get("detail-homepage-row"), "Homepage should be hidden");

    is_element_hidden(get("detail-size"), "Size should be hidden");

    is_element_hidden(get("detail-downloads"), "Downloads should be hidden");

    is_element_visible(get("detail-prefs-btn"), "Preferences button should be visible");
    is_element_hidden(get("detail-enable-btn"), "Enable button should be hidden");
    is_element_visible(get("detail-disable-btn"), "Disable button should be visible");
    is_element_visible(get("detail-uninstall-btn"), "Remove button should be visible");

    is_element_hidden(get("detail-warning"), "Warning message should be hidden");
    is_element_hidden(get("detail-warning-link"), "Warning link should be hidden");
    is_element_hidden(get("detail-error"), "Error message should be hidden");
    is_element_hidden(get("detail-pending"), "Pending message should be hidden");

    run_next_test();
  });
});

// Check that onPropertyChanges for appDisabled updates the UI
add_test(function() {
  info("Checking that onPropertyChanges for appDisabled updates the UI");

  AddonManager.getAddonByID("addon1@tests.mozilla.org", function(aAddon) {
    aAddon.userDisabled = true;
    aAddon.isCompatible = true;
    aAddon.appDisabled = false;

    open_details("addon1@tests.mozilla.org", "extension", function() {
      is(get("detail-view").getAttribute("active"), "false", "Addon should not be marked as active");
      is_element_hidden(get("detail-warning"), "Warning message should not be visible");

      info("Making addon incompatible and appDisabled");
      aAddon.isCompatible = false;
      aAddon.appDisabled = true;

      is(get("detail-view").getAttribute("active"), "false", "Addon should not be marked as active");
      is_element_visible(get("detail-warning"), "Warning message should be visible");
      is(get("detail-warning").textContent, "Test add-on replacement is incompatible with " + gApp + " " + gVersion + ".", "Warning message should be correct");

      run_next_test();
    });
  });
});