Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- describe('testing exclude options', function () {
- function camelCase(text){
- return text.split(/[\W_]/g).map(function(word,index){
- return word.charAt(0).toUpperCase() + word.slice(1)
- }).join('')
- }
- var checks = [
- 'user_agent',
- 'language',
- 'color_depth',
- 'color_depth',
- 'device_memory',
- 'hardware_concurrency',
- ['resolution', 'excludeScreenResolution'],
- ['available_resolution', 'excludeAvailableScreenResolution'],
- 'timezone_offset',
- 'timezone',
- 'session_storage',
- 'local_storage',
- ['indexed_db', 'excludeIndexedDB'],
- 'cpu_class',
- ['navigator_platform', 'excludePlatform'],
- ['regular_plugins', 'excludePlugins'],
- 'canvas',
- ['webgl', 'excludeWebGL'],
- ['webgl_vendor', 'excludeWebGLVendorAndRenderer'],
- ['adblock', 'excludeAdBlock'],
- 'has_lied_languages',
- 'has_lied_resolution',
- 'has_lied_os',
- 'has_lied_browser',
- 'touch_support',
- 'js_fonts',
- ['audio_fp', 'excludeAudio'],
- 'enumerate_devices',
- 'add_behavior',
- 'open_database',
- ];
- it('empty components when exluding everything', function(done){
- var options = {};
- for(var i = 0; i < checks.length; ++i) {
- var exclude_key = checks[i] instanceof Array ? checks[i][1] : "exclude" + camelCase(checks[i]);
- options[exclude_key] = true;
- }
- var fp2 = new Fingerprint2(options)
- fp2.get(function(result, components){
- expect(components.length).toEqual(0)
- done()
- })
- })
- it('components available when NOT exluded', function(done){
- var fp2 = new Fingerprint2()
- fp2.get(function(result, components){
- expect(function() {
- for(var i = 0; i < checks.length; ++i) {
- var key = checks[i] instanceof Array ? checks[i][0] : checks[i];
- if(key == 'enumerate_devices' && !fp2.isEnumerateDevicesSupported())
- continue
- if(key == 'session_storage' && !fp2.hasSessionStorage())
- continue
- if(key == 'local_storage' && !fp2.hasLocalStorage())
- continue
- if(key == 'indexed_db' && !fp2.hasIndexedDB())
- continue
- if(key == 'add_behavior' && !(document.body && document.body.addBehavior))
- continue
- if(key == 'open_database' && !window.openDatabase)
- continue
- if(key == 'canvas' && !fp2.isCanvasSupported())
- continue
- if((key == 'webgl' || key == 'webgl_vendor') && !fp2.isWebGlSupported())
- continue
- if(key == 'regular_plugins' && fp2.isIE())
- key = 'ie_plugins'
- getComponent(components, key)
- }
- }).not.toThrow()
- done()
- })
- })
- })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement