Sunteți pe pagina 1din 5

// Karma configuration

// Generated on Tue Jul 21 2015 22:34:30 GMT-0400 (EDT)

module.exports = function(config) {

config.set({

// base path that will be used to resolve all patterns (eg. files, exclude)

basePath: '',

coverageReporter: {

// specify a common output directory

dir: 'coverage',

reporters: [{

type: 'lcov',

subdir: '.'

}]

},

// frameworks to use

// available frameworks: https://npmjs.org/browse/keyword/karma-adapter

frameworks: ['jasmine'],

plugins: [

'karma-jasmine',

'karma-firefox-launcher',

'karma-mocha-reporter',

'karma-coverage'

],

// list of files / patterns to load in the browser


files: [

'push.js',

'push_tests.js'

],

// preprocess matching files before serving them to the browser

// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor

preprocessors: {

'push.js': ['coverage']

},

// test results reporter to use

// possible values: 'dots', 'progress'

// available reporters: https://npmjs.org/browse/keyword/karma-reporter

reporters: ['mocha', 'coverage'],

// web server port

port: 9876,

// enable / disable colors in the output (reporters and logs)

colors: true,

// level of logging

// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN ||


config.LOG_INFO || config.LOG_DEBUG

logLevel: config.LOG_INFO,
// enable / disable watching file and executing tests whenever any file changes

autoWatch: false,

// start these browsers

// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher

browsers: ['Firefox'],

// Continuous Integration mode

// if true, Karma captures browsers, runs the tests and exits

singleRun: true

});

};

var isFunction = function (obj) { return obj && {}.toString.call(obj) === '[object Function]'; },

runFunctionString = function(funcStr) {

if (funcStr.trim().length > 0) {

eval('var func = ' + funcStr);

if (isFunction(func))

func();

};

self.addEventListener('message', function(event) {

self.client = event.source;

});
self.onnotificationclose = function (event) {

runFunctionString(event.notification.data.onClose);

/* Tell Push to execute close callback */

self.client.postMessage(JSON.stringify({

id: event.notification.data.id,

action: 'close'

}));

};

self.onnotificationclick = function (event) {

var link, origin, href;

runFunctionString(event.notification.data.onClick);

if (typeof event.notification.data.link !== 'undefined' && event.notification.data.link !== null)


{

origin = event.notification.data.origin;

link = event.notification.data.link;

href = origin.substring(0, origin.indexOf('/', 8)) + '/';

event.notification.close();

// This looks to see if the current is already open and focuses if it is

event.waitUntil(clients.matchAll({

type: "window"

}).then(function (clientList) {

var client, full_url;

for (var i = 0; i < clientList.length; i++) {


client = clientList[i];

full_url = href + link;

if (full_url[full_url.length - 1] !== '/' && client.url[client.url.length - 1] == '/')

full_url += '/';

if ((client.url == full_url) && ('focus' in client))

return client.focus();

if (clients.openWindow)

return clients.openWindow('/' + link);

}));

};

S-ar putea să vă placă și