'use strict';

/* jshint node:true */

var fs = require('fs');

module.exports = function (grunt) {
  // These are pairs [task, target] for which a copied tasks with an
  // additional filter option are created. Those tasks are then passed to the
  // watch task to be fired on file changes; the filter option makes sure
  // tasks are fired only on changed files, making them a lot faster.
  // Unfortunately, we can't just apply a filter to the basic configuration as
  // no files would be processed during initial runs.
  var filteredTasks = [
    ['jshint', 'main'],
    ['jshint', 'src'],
    ['jshint', 'tests'],
    ['jsonlint', 'all'],
  ];

  function filterNewFiles(src) {
    // Returns a function that tells if a file was recently modified;
    // it's used by jshint & defs tasks so that they run only on changed
    // files.
    var srcTime = fs.statSync(src).mtime.getTime();
    // Don't watch files changed before last 10 seconds.
    return srcTime > Date.now() - 10000;
  }

  // Load all grunt tasks matching the `grunt-*` pattern.
  require('load-grunt-tasks')(grunt);
  grunt.loadTasks('./build/tasks');


  grunt.initConfig({
    copy: require('./build/copy'),
    clean: require('./build/clean'),
    jshint: require('./build/lint/jshint'),
    jsonlint: require('./build/lint/jsonlint'),
    karma: require('./build/karma'),
    'merge-conflict': require('./build/lint/merge-conflict'),
    mochaTest: require('./build/mocha-test'),
    rollup: require('./build/rollup'),
    shell: require('./build/shell'),
    uglify: require('./build/uglify'),
    watch: require('./build/watch'),
  });

  // Add copies of watched tasks with an added filter option.
  filteredTasks.forEach(function (taskAndTarget) {
    var newTaskAndTarget = taskAndTarget.slice(0);
    newTaskAndTarget[newTaskAndTarget.length - 1] =
      newTaskAndTarget[newTaskAndTarget.length - 1] + 'Filtered';

    grunt.config(newTaskAndTarget, grunt.config(taskAndTarget));
    grunt.config(newTaskAndTarget.concat(['filter']), filterNewFiles);
  });

  grunt.registerTask('reference', ['shell:reference']);
  grunt.registerTask('perf', ['shell:perf']);

  grunt.registerTask('lint', [
    'jshint:main',
    'jshint:src',
    'jshint:tests',
    'jsonlint:all',
  ]);

  grunt.registerTask('test', [
    'mochaTest:dot'
  ]);

  grunt.registerTask('bundle', [
    'rollup',
  ]);

  grunt.registerTask('build', [
    'lint',
    'test',
    'bundle',
  ]);

  grunt.registerTask('web', [
    'lint',
    'test',
    'rollup:web',
    'rollup:bridge',
  ]);

  grunt.registerTask('gaia', [
    'lint',
    'test',
    'rollup:gaia',
    'rollup:gaiabuild',
    'rollup:bridge',
    'compat:gaia',
    'copy:gaia'
  ]);

  grunt.registerTask('release', [
    'lint',
    'test',
    'bundle',
    'compat',
    'uglify'
  ]);

  grunt.registerTask('default', [
    'web'
  ]);
};

@@ -2306,32 +2306,134 @@
 est:dot'%0A  %5D);%0A%0A
+  grunt.registerTask('test-browser', %5B%0A    'rollup:testing',%0A    'compat:testing',%0A    'karma'%0A  %5D);%0A%0A
   grunt.register

Add grunt test-browser