@@ -38,26 +38,92 @@ define([
3838 'intern/dojo/node!../../src/js/lib/helpers'
3939] , function ( registerSuite , assert , helpers ) {
4040
41- // Expected viewport dimensions vary based on browser
42- var expectedWidths = [ 980 , 1024 ] ,
43- expectedHeights = [ 636 , 644 , 670 , 673 , 684 , 695 , 705 , 706 , 712 ] ;
41+ var
42+ // Expected viewport dimensions vary based on browser
43+ expectedViewportWidths = [ 980 , 1024 ] ,
44+ expectedViewportHeights = [ 636 , 644 , 670 , 673 , 684 , 695 , 705 , 706 , 712 ] ,
45+
46+ // User fingerprint varies based on browser features
47+ expectedSignatures = [
48+ 90940656 , 3343029130 , 1101697779 , 3900377526 , 987357563 ,
49+ 2536308034 , 1421522027 , 4288521977 , 3773734853 , 2744319702 , 710620838 ] ;
4450
4551 registerSuite ( {
4652
4753 name : 'Detectors test' ,
4854
49- 'Get viewport' : function ( ) {
55+ 'Get viewport dimensions ' : function ( ) {
5056
5157 return this . remote
5258 . get ( require . toUrl ( 'tests/pages/detectors.html' ) )
5359 . waitForElementByCssSelector ( 'body.loaded' , 5000 )
54- . elementById ( 'viewport ' )
60+ . elementById ( 'detectViewport ' )
5561 . text ( )
5662 . then ( function ( text ) {
5763 var dimensions = text . split ( 'x' ) ;
58- assert . include ( expectedWidths , parseInt ( dimensions [ 0 ] ) , 'Viewport width is valid' ) ;
59- assert . include ( expectedHeights , parseInt ( dimensions [ 1 ] ) , 'Viewport height is valid' ) ;
64+ assert . include ( expectedViewportWidths , parseInt ( dimensions [ 0 ] ) , 'Viewport width is valid' ) ;
65+ assert . include ( expectedViewportHeights , parseInt ( dimensions [ 1 ] ) , 'Viewport height is valid' ) ;
66+ } ) ;
67+ } ,
68+
69+ 'Check localStorage availability' : function ( ) {
70+
71+ return this . remote
72+ . get ( require . toUrl ( 'tests/pages/detectors.html' ) )
73+ . waitForElementByCssSelector ( 'body.loaded' , 5000 )
74+ . elementById ( 'localStorageAccessible' )
75+ . text ( )
76+ . then ( function ( text ) {
77+ assert . strictEqual ( text , 'true' , 'Detect localStorage accessibility' ) ;
78+ } ) ;
79+ } ,
80+
81+ 'Check sessionStorage availability' : function ( ) {
82+
83+ return this . remote
84+ . get ( require . toUrl ( 'tests/pages/detectors.html' ) )
85+ . waitForElementByCssSelector ( 'body.loaded' , 5000 )
86+ . elementById ( 'hasSessionStorage' )
87+ . text ( )
88+ . then ( function ( text ) {
89+ assert . strictEqual ( text , 'true' , 'Detect sessionStorage' ) ;
90+ } ) ;
91+ } ,
92+
93+ 'Check whether cookies are enabled availability' : function ( ) {
94+
95+ return this . remote
96+ . get ( require . toUrl ( 'tests/pages/detectors.html' ) )
97+ . waitForElementByCssSelector ( 'body.loaded' , 5000 )
98+ . elementById ( 'hasCookies' )
99+ . text ( )
100+ . then ( function ( text ) {
101+ assert . equal ( text , '1' , 'Detect whether cookies can be set' ) ;
102+ } ) ;
103+ } ,
104+
105+ 'Detect timezone' : function ( ) {
106+
107+ return this . remote
108+ . get ( require . toUrl ( 'tests/pages/detectors.html' ) )
109+ . waitForElementByCssSelector ( 'body.loaded' , 5000 )
110+ . elementById ( 'detectTimezone' )
111+ . text ( )
112+ . then ( function ( text ) {
113+ assert . include ( [ 'UTC' , 'America/Los_Angeles' ] , text , 'Detect the timezone' ) ;
114+ } ) ;
115+ } ,
116+
117+ 'User fingerprinting' : function ( ) {
118+
119+ return this . remote
120+ . get ( require . toUrl ( 'tests/pages/detectors.html' ) )
121+ . waitForElementByCssSelector ( 'body.loaded' , 5000 )
122+ . elementById ( 'detectSignature' )
123+ . text ( )
124+ . then ( function ( text ) {
125+ assert . include ( expectedSignatures , parseInt ( text ) , 'Create a user fingerprint based on browser features' ) ;
60126 } ) ;
61127 }
62128 } ) ;
63- } ) ;
129+ } ) ;
0 commit comments