@@ -510,6 +510,288 @@ add_task(async function test_graph_display() {
510
510
BrowserTestUtils . removeTab ( tab ) ;
511
511
} ) ;
512
512
513
+ // Ensure that the number of suspicious fingerprinter is aggregated into the
514
+ // fingerprinter category on about:protection page.
515
+ add_task ( async function test_suspicious_fingerprinter ( ) {
516
+ // This creates the schema.
517
+ await TrackingDBService . saveEvents ( JSON . stringify ( { } ) ) ;
518
+ let db = await Sqlite . openConnection ( { path : DB_PATH } ) ;
519
+
520
+ // Inserting data for today. It won't contain a fingerprinter entry but only
521
+ // a suspicious fingerprinter entry.
522
+ let date = new Date ( ) . toISOString ( ) ;
523
+ await db . execute ( SQL . insertCustomTimeEvent , {
524
+ type : TrackingDBService . TRACKERS_ID ,
525
+ count : 1 ,
526
+ timestamp : date ,
527
+ } ) ;
528
+ await db . execute ( SQL . insertCustomTimeEvent , {
529
+ type : TrackingDBService . CRYPTOMINERS_ID ,
530
+ count : 2 ,
531
+ timestamp : date ,
532
+ } ) ;
533
+ await db . execute ( SQL . insertCustomTimeEvent , {
534
+ type : TrackingDBService . SUSPICIOUS_FINGERPRINTERS_ID ,
535
+ count : 2 ,
536
+ timestamp : date ,
537
+ } ) ;
538
+ await db . execute ( SQL . insertCustomTimeEvent , {
539
+ type : TrackingDBService . TRACKING_COOKIES_ID ,
540
+ count : 4 ,
541
+ timestamp : date ,
542
+ } ) ;
543
+ await db . execute ( SQL . insertCustomTimeEvent , {
544
+ type : TrackingDBService . SOCIAL_ID ,
545
+ count : 1 ,
546
+ timestamp : date ,
547
+ } ) ;
548
+
549
+ // Inserting data for 1 day age. It contains both a fingerprinter entry and
550
+ // a suspicious fingerprinter entry.
551
+ date = new Date ( Date . now ( ) - 1 * 24 * 60 * 60 * 1000 ) . toISOString ( ) ;
552
+ await db . execute ( SQL . insertCustomTimeEvent , {
553
+ type : TrackingDBService . TRACKERS_ID ,
554
+ count : 1 ,
555
+ timestamp : date ,
556
+ } ) ;
557
+ await db . execute ( SQL . insertCustomTimeEvent , {
558
+ type : TrackingDBService . CRYPTOMINERS_ID ,
559
+ count : 2 ,
560
+ timestamp : date ,
561
+ } ) ;
562
+ await db . execute ( SQL . insertCustomTimeEvent , {
563
+ type : TrackingDBService . FINGERPRINTERS_ID ,
564
+ count : 1 ,
565
+ timestamp : date ,
566
+ } ) ;
567
+ await db . execute ( SQL . insertCustomTimeEvent , {
568
+ type : TrackingDBService . SUSPICIOUS_FINGERPRINTERS_ID ,
569
+ count : 1 ,
570
+ timestamp : date ,
571
+ } ) ;
572
+ await db . execute ( SQL . insertCustomTimeEvent , {
573
+ type : TrackingDBService . TRACKING_COOKIES_ID ,
574
+ count : 4 ,
575
+ timestamp : date ,
576
+ } ) ;
577
+ await db . execute ( SQL . insertCustomTimeEvent , {
578
+ type : TrackingDBService . SOCIAL_ID ,
579
+ count : 1 ,
580
+ timestamp : date ,
581
+ } ) ;
582
+
583
+ let tab = await BrowserTestUtils . openNewForegroundTab ( {
584
+ url : "about:protections" ,
585
+ gBrowser,
586
+ } ) ;
587
+ await SpecialPowers . spawn ( tab . linkedBrowser , [ ] , async function ( ) {
588
+ const DATA_TYPES = [
589
+ "cryptominer" ,
590
+ "fingerprinter" ,
591
+ "tracker" ,
592
+ "cookie" ,
593
+ "social" ,
594
+ ] ;
595
+ let allBars = null ;
596
+ await ContentTaskUtils . waitForMutationCondition (
597
+ content . document . body ,
598
+ { childList : true , subtree : true } ,
599
+ ( ) => {
600
+ allBars = content . document . querySelectorAll ( ".graph-bar" ) ;
601
+ return ! ! allBars . length ;
602
+ }
603
+ ) ;
604
+ info ( "The graph has been built" ) ;
605
+
606
+ Assert . equal ( allBars . length , 7 , "7 bars have been found on the graph" ) ;
607
+
608
+ // Verify today's data. The fingerprinter category should take 20%.
609
+ Assert . equal (
610
+ allBars [ 6 ] . querySelectorAll ( ".inner-bar" ) . length ,
611
+ DATA_TYPES . length ,
612
+ "today has all of the data types shown"
613
+ ) ;
614
+ Assert . equal (
615
+ allBars [ 6 ] . querySelector ( ".tracker-bar" ) . style . height ,
616
+ "10%" ,
617
+ "trackers take 10%"
618
+ ) ;
619
+ Assert . equal (
620
+ allBars [ 6 ] . querySelector ( ".cryptominer-bar" ) . style . height ,
621
+ "20%" ,
622
+ "cryptominers take 20%"
623
+ ) ;
624
+ Assert . equal (
625
+ allBars [ 6 ] . querySelector ( ".fingerprinter-bar" ) . style . height ,
626
+ "20%" ,
627
+ "fingerprinters take 20%"
628
+ ) ;
629
+ Assert . equal (
630
+ allBars [ 6 ] . querySelector ( ".cookie-bar" ) . style . height ,
631
+ "40%" ,
632
+ "cross site tracking cookies take 40%"
633
+ ) ;
634
+ Assert . equal (
635
+ allBars [ 6 ] . querySelector ( ".social-bar" ) . style . height ,
636
+ "10%" ,
637
+ "social trackers take 10%"
638
+ ) ;
639
+
640
+ // Verify one day age data. The fingerprinter category should take 20%.
641
+ Assert . equal (
642
+ allBars [ 5 ] . querySelectorAll ( ".inner-bar" ) . length ,
643
+ DATA_TYPES . length ,
644
+ "today has all of the data types shown"
645
+ ) ;
646
+ Assert . equal (
647
+ allBars [ 5 ] . querySelector ( ".tracker-bar" ) . style . height ,
648
+ "10%" ,
649
+ "trackers take 10%"
650
+ ) ;
651
+ Assert . equal (
652
+ allBars [ 5 ] . querySelector ( ".cryptominer-bar" ) . style . height ,
653
+ "20%" ,
654
+ "cryptominers take 20%"
655
+ ) ;
656
+ Assert . equal (
657
+ allBars [ 5 ] . querySelector ( ".fingerprinter-bar" ) . style . height ,
658
+ "20%" ,
659
+ "fingerprinters take 20%"
660
+ ) ;
661
+ Assert . equal (
662
+ allBars [ 5 ] . querySelector ( ".cookie-bar" ) . style . height ,
663
+ "40%" ,
664
+ "cross site tracking cookies take 40%"
665
+ ) ;
666
+ Assert . equal (
667
+ allBars [ 5 ] . querySelector ( ".social-bar" ) . style . height ,
668
+ "10%" ,
669
+ "social trackers take 10%"
670
+ ) ;
671
+ } ) ;
672
+
673
+ // Use the TrackingDBService API to delete the data.
674
+ await TrackingDBService . clearAll ( ) ;
675
+ // Make sure the data was deleted.
676
+ let rows = await db . execute ( SQL . selectAll ) ;
677
+ is ( rows . length , 0 , "length is 0" ) ;
678
+ await db . close ( ) ;
679
+ BrowserTestUtils . removeTab ( tab ) ;
680
+ } ) ;
681
+
682
+ // Ensure that the number of suspicious fingerprinter is displayed even if the
683
+ // fingerprinter blocking is disabled.
684
+ add_task ( async function test_suspicious_fingerprinter_without_fp_blocking ( ) {
685
+ // Disable fingerprinter blocking
686
+ Services . prefs . setBoolPref (
687
+ "privacy.trackingprotection.fingerprinting.enabled" ,
688
+ false
689
+ ) ;
690
+
691
+ // This creates the schema.
692
+ await TrackingDBService . saveEvents ( JSON . stringify ( { } ) ) ;
693
+ let db = await Sqlite . openConnection ( { path : DB_PATH } ) ;
694
+
695
+ // Inserting data for today. It won't contain a fingerprinter entry but only
696
+ // a suspicious fingerprinter entry.
697
+ let date = new Date ( ) . toISOString ( ) ;
698
+ await db . execute ( SQL . insertCustomTimeEvent , {
699
+ type : TrackingDBService . TRACKERS_ID ,
700
+ count : 1 ,
701
+ timestamp : date ,
702
+ } ) ;
703
+ await db . execute ( SQL . insertCustomTimeEvent , {
704
+ type : TrackingDBService . CRYPTOMINERS_ID ,
705
+ count : 2 ,
706
+ timestamp : date ,
707
+ } ) ;
708
+ await db . execute ( SQL . insertCustomTimeEvent , {
709
+ type : TrackingDBService . SUSPICIOUS_FINGERPRINTERS_ID ,
710
+ count : 2 ,
711
+ timestamp : date ,
712
+ } ) ;
713
+ await db . execute ( SQL . insertCustomTimeEvent , {
714
+ type : TrackingDBService . TRACKING_COOKIES_ID ,
715
+ count : 4 ,
716
+ timestamp : date ,
717
+ } ) ;
718
+ await db . execute ( SQL . insertCustomTimeEvent , {
719
+ type : TrackingDBService . SOCIAL_ID ,
720
+ count : 1 ,
721
+ timestamp : date ,
722
+ } ) ;
723
+
724
+ let tab = await BrowserTestUtils . openNewForegroundTab ( {
725
+ url : "about:protections" ,
726
+ gBrowser,
727
+ } ) ;
728
+ await SpecialPowers . spawn ( tab . linkedBrowser , [ ] , async function ( ) {
729
+ const DATA_TYPES = [
730
+ "cryptominer" ,
731
+ "fingerprinter" ,
732
+ "tracker" ,
733
+ "cookie" ,
734
+ "social" ,
735
+ ] ;
736
+ let allBars = null ;
737
+ await ContentTaskUtils . waitForMutationCondition (
738
+ content . document . body ,
739
+ { childList : true , subtree : true } ,
740
+ ( ) => {
741
+ allBars = content . document . querySelectorAll ( ".graph-bar" ) ;
742
+ return ! ! allBars . length ;
743
+ }
744
+ ) ;
745
+ info ( "The graph has been built" ) ;
746
+
747
+ Assert . equal ( allBars . length , 7 , "7 bars have been found on the graph" ) ;
748
+
749
+ // Verify today's data. The fingerprinter category should take 20%.
750
+ Assert . equal (
751
+ allBars [ 6 ] . querySelectorAll ( ".inner-bar" ) . length ,
752
+ DATA_TYPES . length ,
753
+ "today has all of the data types shown"
754
+ ) ;
755
+ Assert . equal (
756
+ allBars [ 6 ] . querySelector ( ".tracker-bar" ) . style . height ,
757
+ "10%" ,
758
+ "trackers take 10%"
759
+ ) ;
760
+ Assert . equal (
761
+ allBars [ 6 ] . querySelector ( ".cryptominer-bar" ) . style . height ,
762
+ "20%" ,
763
+ "cryptominers take 20%"
764
+ ) ;
765
+ Assert . equal (
766
+ allBars [ 6 ] . querySelector ( ".fingerprinter-bar" ) . style . height ,
767
+ "20%" ,
768
+ "fingerprinters take 20%"
769
+ ) ;
770
+ Assert . equal (
771
+ allBars [ 6 ] . querySelector ( ".cookie-bar" ) . style . height ,
772
+ "40%" ,
773
+ "cross site tracking cookies take 40%"
774
+ ) ;
775
+ Assert . equal (
776
+ allBars [ 6 ] . querySelector ( ".social-bar" ) . style . height ,
777
+ "10%" ,
778
+ "social trackers take 10%"
779
+ ) ;
780
+ } ) ;
781
+
782
+ // Use the TrackingDBService API to delete the data.
783
+ await TrackingDBService . clearAll ( ) ;
784
+ // Make sure the data was deleted.
785
+ let rows = await db . execute ( SQL . selectAll ) ;
786
+ is ( rows . length , 0 , "length is 0" ) ;
787
+ await db . close ( ) ;
788
+ BrowserTestUtils . removeTab ( tab ) ;
789
+
790
+ Services . prefs . clearUserPref (
791
+ "privacy.trackingprotection.fingerprinting.enabled"
792
+ ) ;
793
+ } ) ;
794
+
513
795
// Ensure that each type of tracker is hidden from the graph if there are no recorded
514
796
// trackers of that type and the user has chosen to not block that type.
515
797
add_task ( async function test_etp_custom_settings ( ) {
@@ -600,6 +882,7 @@ add_task(async function test_etp_custom_settings() {
600
882
"privacy.trackingprotection.fingerprinting.enabled" ,
601
883
false
602
884
) ;
885
+ Services . prefs . setBoolPref ( "privacy.fingerprintingProtection" , false ) ;
603
886
tab = await BrowserTestUtils . openNewForegroundTab ( {
604
887
url : "about:protections" ,
605
888
gBrowser,
@@ -645,6 +928,7 @@ add_task(async function test_etp_custom_settings() {
645
928
Services . prefs . clearUserPref (
646
929
"privacy.trackingprotection.fingerprinting.enabled"
647
930
) ;
931
+ Services . prefs . clearUserPref ( "privacy.fingerprintingProtection" ) ;
648
932
Services . prefs . clearUserPref (
649
933
"privacy.trackingprotection.cryptomining.enabled"
650
934
) ;
0 commit comments