scratch – Diff between revs 58 and 125
?pathlinks?
Rev 58 | Rev 125 | |||
---|---|---|---|---|
Line 29... | Line 29... | |||
29 | expect(fp2.options.swfPath).toEqual("flash/compiled/FontList.swf"); |
29 | expect(fp2.options.swfPath).toEqual("flash/compiled/FontList.swf"); |
|
30 | expect(fp2.options.excludeUserAgent).toBe(true); |
30 | expect(fp2.options.excludeUserAgent).toBe(true); |
|
31 | }); |
31 | }); |
|
Line 32... | Line 32... | |||
32 | |
32 | |
|
33 | describe("sortPluginsFor", function () { |
33 | describe("sortPluginsFor", function () { |
|
34 | it("has default value", function (){ |
34 | it("has default value", function () { |
|
35 | var fp2 = new Fingerprint2(); |
35 | var fp2 = new Fingerprint2(); |
|
36 | expect(fp2.options.sortPluginsFor).toEqual([/palemoon/i]); |
36 | expect(fp2.options.sortPluginsFor).toEqual([/palemoon/i]); |
|
Line 37... | Line 37... | |||
37 | }); |
37 | }); |
|
Line 51... | Line 51... | |||
51 | |
51 | |
|
52 | describe("get", function () { |
52 | describe("get", function () { |
|
53 | describe("default options", function () { |
53 | describe("default options", function () { |
|
54 | it("calculates fingerprint", function (done) { |
54 | it("calculates fingerprint", function (done) { |
|
55 | var fp2 = new Fingerprint2(); |
55 | var fp2 = new Fingerprint2(); |
|
56 | fp2.get(function(result){ |
56 | fp2.get(function (result) { |
|
57 | expect(result).toMatch(/^[0-9a-f]{32}$/i); |
57 | expect(result).toMatch(/^[0-9a-f]{32}$/i); |
|
58 | done(); |
58 | done(); |
|
59 | }); |
59 | }); |
|
Line 60... | Line 60... | |||
60 | }); |
60 | }); |
|
61 | |
61 | |
|
62 | it("does not try calling flash font detection", function (done) { |
62 | it("does not try calling flash font detection", function (done) { |
|
63 | var fp2 = new Fingerprint2(); |
63 | var fp2 = new Fingerprint2(); |
|
64 | spyOn(fp2, "flashFontsKey"); |
64 | spyOn(fp2, "flashFontsKey"); |
|
65 | fp2.get(function(result) { |
65 | fp2.get(function (result) { |
|
66 | expect(fp2.flashFontsKey).not.toHaveBeenCalled(); |
66 | expect(fp2.flashFontsKey).not.toHaveBeenCalled(); |
|
67 | done(); |
67 | done(); |
|
68 | }); |
68 | }); |
|
Line 69... | Line 69... | |||
69 | }); |
69 | }); |
|
70 | }); |
70 | }); |
|
71 | |
71 | |
|
72 | describe("non-default options", function () { |
72 | describe("non-default options", function () { |
|
73 | it("does not use userAgent when excluded", function (done) { |
73 | it("does not use userAgent when excluded", function (done) { |
|
74 | var fp2 = new Fingerprint2({excludeUserAgent: true}); |
74 | var fp2 = new Fingerprint2({excludeUserAgent: true}); |
|
75 | spyOn(fp2, "getUserAgent"); |
75 | spyOn(fp2, "getUserAgent"); |
|
76 | fp2.get(function(result) { |
76 | fp2.get(function (result) { |
|
77 | expect(fp2.getUserAgent).not.toHaveBeenCalled(); |
77 | expect(fp2.getUserAgent).not.toHaveBeenCalled(); |
|
Line 78... | Line 78... | |||
78 | done(); |
78 | done(); |
|
79 | }); |
79 | }); |
|
80 | }); |
80 | }); |
|
81 | |
81 | |
|
82 | it("does not use pixelRatio when excluded", function (done) { |
82 | it("does not use pixelRatio when excluded", function (done) { |
|
83 | var fp2 = new Fingerprint2({excludePixelRatio: true}); |
83 | var fp2 = new Fingerprint2({excludePixelRatio: true}); |
|
84 | spyOn(fp2, "getPixelRatio"); |
84 | spyOn(fp2, "getPixelRatio"); |
|
85 | fp2.get(function(result) { |
85 | fp2.get(function (result) { |
|
Line 86... | Line 86... | |||
86 | expect(fp2.getPixelRatio).not.toHaveBeenCalled(); |
86 | expect(fp2.getPixelRatio).not.toHaveBeenCalled(); |
|
87 | done(); |
87 | done(); |
|
88 | }); |
88 | }); |
|
89 | }); |
89 | }); |
|
90 | |
90 | |
|
91 | it("does not use screen resolution when excluded", function (done) { |
91 | it("does not use screen resolution when excluded", function (done) { |
|
92 | var fp2 = new Fingerprint2({excludeScreenResolution: true}); |
92 | var fp2 = new Fingerprint2({excludeScreenResolution: true}); |
|
93 | spyOn(fp2, "getScreenResolution"); |
93 | spyOn(fp2, "getScreenResolution"); |
|
Line 94... | Line 94... | |||
94 | fp2.get(function(result) { |
94 | fp2.get(function (result) { |
|
95 | expect(fp2.getScreenResolution).not.toHaveBeenCalled(); |
95 | expect(fp2.getScreenResolution).not.toHaveBeenCalled(); |
|
96 | done(); |
96 | done(); |
|
97 | }); |
97 | }); |
|
98 | }); |
98 | }); |
|
99 | |
99 | |
|
100 | it("does not use available screen resolution when excluded", function (done) { |
100 | it("does not use available screen resolution when excluded", function (done) { |
|
101 | var fp2 = new Fingerprint2({excludeAvailableScreenResolution: true}); |
101 | var fp2 = new Fingerprint2({excludeAvailableScreenResolution: true}); |
|
Line 102... | Line 102... | |||
102 | spyOn(fp2, "getAvailableScreenResolution"); |
102 | spyOn(fp2, "getAvailableScreenResolution"); |
|
103 | fp2.get(function(result) { |
103 | fp2.get(function (result) { |
|
104 | expect(fp2.getAvailableScreenResolution).not.toHaveBeenCalled(); |
104 | expect(fp2.getAvailableScreenResolution).not.toHaveBeenCalled(); |
|
105 | done(); |
105 | done(); |
|
106 | }); |
106 | }); |
|
107 | }); |
107 | }); |
|
108 | |
108 | |
|
109 | it("does not use plugins info when excluded", function (done) { |
109 | it("does not use plugins info when excluded", function (done) { |
|
Line 110... | Line 110... | |||
110 | var fp2 = new Fingerprint2({excludePlugins: true}); |
110 | var fp2 = new Fingerprint2({excludePlugins: true}); |
|
111 | spyOn(fp2, "getRegularPlugins"); |
111 | spyOn(fp2, "getRegularPlugins"); |
|
112 | fp2.get(function(result) { |
112 | fp2.get(function (result) { |
|
113 | expect(fp2.getRegularPlugins).not.toHaveBeenCalled(); |
113 | expect(fp2.getRegularPlugins).not.toHaveBeenCalled(); |
|
114 | done(); |
114 | done(); |
|
115 | }); |
115 | }); |
|
116 | }); |
116 | }); |
|
117 | |
117 | |
|
Line 118... | Line 118... | |||
118 | it("does not use IE plugins info when excluded", function (done) { |
118 | it("does not use IE plugins info when excluded", function (done) { |
|
Line 119... | Line 119... | |||
119 | var fp2 = new Fingerprint2({excludeIEPlugins: true}); |
119 | var fp2 = new Fingerprint2({excludeIEPlugins: true}); |
|
120 | spyOn(fp2, "getIEPlugins"); |
120 | spyOn(fp2, "getIEPlugins"); |
|
121 | fp2.get(function(result) { |
121 | fp2.get(function (result) { |
|
122 | expect(fp2.getIEPlugins).not.toHaveBeenCalled(); |
122 | expect(fp2.getIEPlugins).not.toHaveBeenCalled(); |
|
123 | done(); |
123 | done(); |
|
124 | }); |
124 | }); |
|
125 | }); |
125 | }); |
|
126 | |
126 | |
|
Line 127... | Line 127... | |||
127 | }); |
127 | }); |
|
128 | |
128 | |
|
129 | describe("returns components", function () { |
129 | describe("returns components", function () { |
|
130 | it("does it return components as a second argument to callback", function (done) { |
130 | it("does it return components as a second argument to callback", function (done) { |
|
131 | var fp2 = new Fingerprint2(); |
131 | var fp2 = new Fingerprint2(); |
|
132 | fp2.get(function(result, components) { |
132 | fp2.get(function (result, components) { |
|
133 | expect(components).not.toBeNull(); |
133 | expect(components).not.toBeNull(); |
|
Line 134... | Line 134... | |||
134 | done(); |
134 | done(); |
|
135 | }); |
135 | }); |
|
136 | }); |
136 | }); |
|
137 | |
137 | |
|
138 | it("checks if returned components is array", function (done) { |
138 | it("checks if returned components is array", function (done) { |
|
139 | var fp2 = new Fingerprint2(); |
139 | var fp2 = new Fingerprint2(); |
|
140 | fp2.get(function(result, components) { |
140 | fp2.get(function (result, components) { |
|
141 | expect(components).toBeArrayOfObjects(); |
141 | expect(components).toBeArrayOfObjects(); |
|
142 | done(); |
142 | done(); |
|
143 | }); |
143 | }); |
|
144 | }); |
144 | }); |
|
Line 145... | Line 145... | |||
145 | |
145 | |
|
146 | it("checks if js_fonts component is array", function (done) { |
146 | it("checks if js_fonts component is array", function (done) { |
|
147 | var fp2 = new Fingerprint2(); |
147 | var fp2 = new Fingerprint2(); |
|
148 | fp2.get(function(result, components) { |
148 | fp2.get(function (result, components) { |
|
149 | for(var x = 0; x < components.length; x++) { |
149 | for (var x = 0; x < components.length; x++) { |
|
150 | if(components[x].key == "js_fonts") { |
150 | if (components[x].key == "js_fonts") { |
|
151 | expect(components[x].value).toBeArray(); |
151 | expect(components[x].value).toBeArray(); |
|
152 | } |
152 | } |
|
Line 195... | Line 195... | |||
195 | }); |
195 | }); |
|
Line 196... | Line 196... | |||
196 | |
196 | |
|
197 | describe("userDefinedFonts option", function () { |
197 | describe("userDefinedFonts option", function () { |
|
198 | it("concatinates existing fonts with user-defined", function (done) { |
198 | it("concatinates existing fonts with user-defined", function (done) { |
|
199 | var fontList = [ |
199 | var fontList = [ |
|
- | 200 | "Andale Mono", "Arial", "Arial Black", "Arial Hebrew", "Arial MT", "Arial Narrow", "Arial Rounded MT Bold", |
||
200 | "Andale Mono", "Arial", "Arial Black", "Arial Hebrew", "Arial MT", "Arial Narrow", "Arial Rounded MT Bold", "Arial Unicode MS", |
201 | "Arial Unicode MS", |
|
201 | "Bitstream Vera Sans Mono", "Book Antiqua", "Bookman Old Style", |
202 | "Bitstream Vera Sans Mono", "Book Antiqua", "Bookman Old Style", |
|
- | 203 | "Calibri", "Cambria", "Cambria Math", "Century", "Century Gothic", "Century Schoolbook", "Comic Sans", |
||
202 | "Calibri", "Cambria", "Cambria Math", "Century", "Century Gothic", "Century Schoolbook", "Comic Sans", "Comic Sans MS", "Consolas", "Courier", "Courier New", |
204 | "Comic Sans MS", "Consolas", "Courier", "Courier New", |
|
203 | "Garamond", "Geneva", "Georgia", |
205 | "Garamond", "Geneva", "Georgia", |
|
204 | "Helvetica", "Helvetica Neue", |
206 | "Helvetica", "Helvetica Neue", |
|
205 | "Impact", |
207 | "Impact", |
|
- | 208 | "Lucida Bright", "Lucida Calligraphy", "Lucida Console", "Lucida Fax", "LUCIDA GRANDE", "Lucida Handwriting", |
||
206 | "Lucida Bright", "Lucida Calligraphy", "Lucida Console", "Lucida Fax", "LUCIDA GRANDE", "Lucida Handwriting", "Lucida Sans", "Lucida Sans Typewriter", "Lucida Sans Unicode", |
209 | "Lucida Sans", "Lucida Sans Typewriter", "Lucida Sans Unicode", |
|
- | 210 | "Microsoft Sans Serif", "Monaco", "Monotype Corsiva", "MS Gothic", "MS Outlook", "MS PGothic", |
||
207 | "Microsoft Sans Serif", "Monaco", "Monotype Corsiva", "MS Gothic", "MS Outlook", "MS PGothic", "MS Reference Sans Serif", "MS Sans Serif", "MS Serif", "MYRIAD", "MYRIAD PRO", |
211 | "MS Reference Sans Serif", "MS Sans Serif", "MS Serif", "MYRIAD", "MYRIAD PRO", |
|
208 | "Palatino", "Palatino Linotype", |
212 | "Palatino", "Palatino Linotype", |
|
209 | "Segoe Print", "Segoe Script", "Segoe UI", "Segoe UI Light", "Segoe UI Semibold", "Segoe UI Symbol", |
213 | "Segoe Print", "Segoe Script", "Segoe UI", "Segoe UI Light", "Segoe UI Semibold", "Segoe UI Symbol", |
|
210 | "Tahoma", "Times", "Times New Roman", "Times New Roman PS", "Trebuchet MS", |
214 | "Tahoma", "Times", "Times New Roman", "Times New Roman PS", "Trebuchet MS", |
|
211 | "Verdana", "Wingdings", "Wingdings 2", "Wingdings 3" |
215 | "Verdana", "Wingdings", "Wingdings 2", "Wingdings 3" |
|
Line 212... | Line 216... | |||
212 | ]; |
216 | ]; |
|
213 | |
217 | |
|
214 | expect(fontList.length).toEqual(65); |
218 | expect(fontList.length).toEqual(65); |
|
215 | var userDefinedFonts = []; |
219 | var userDefinedFonts = []; |
|
Line 216... | Line -... | |||
216 | fontList.concat(userDefinedFonts); |
- | ||
217 | expect(fontList.length).toEqual(65); |
220 | fontList.concat(userDefinedFonts); |
|
218 | |
221 | expect(fontList.length).toEqual(65); |
|
219 | |
222 | |
|
220 | userDefinedFonts = ["Adria Grotesk", "Butler", "Nimbus Mono"]; |
223 | userDefinedFonts = ["Adria Grotesk", "Butler", "Nimbus Mono"]; |
|
221 | expect(userDefinedFonts.length).toEqual(3); |
224 | expect(userDefinedFonts.length).toEqual(3); |
|
222 | fontList = fontList.concat(userDefinedFonts); |
225 | fontList = fontList.concat(userDefinedFonts); |
|
223 | expect(fontList.length).toEqual(65 + 3); |
226 | expect(fontList.length).toEqual(65 + 3); |
|
- | 227 | done(); |
||
- | 228 | }); |
||
- | 229 | }); |
||
- | 230 | describe("customFunction option", function () { |
||
- | 231 | |
||
- | 232 | it("concatinates the current keys with the customFunction output", function (done) { |
||
- | 233 | function customFunction () { |
||
- | 234 | return "RANDOM_STRING"; |
||
- | 235 | } |
||
- | 236 | var spy = jasmine.createSpy('customFunction', customFunction).and.callThrough(); |
||
- | 237 | var fp = new Fingerprint2({ |
||
- | 238 | "customFunction": spy |
||
- | 239 | }); |
||
- | 240 | fp.get(function (result, keys) { |
||
- | 241 | expect(spy).toHaveBeenCalled(); |
||
- | 242 | done() |
||
224 | done(); |
243 | }); |
|
225 | }); |
244 | }); |