From 4d0197ae923e4dbfdd3dc4c07bff0e9957e8a23d Mon Sep 17 00:00:00 2001 From: Yvonne Yip Date: Thu, 20 Jun 2013 14:49:39 -0700 Subject: [PATCH 1/7] test: update karma config file --- conf/karma.conf.js | 164 ++++++++++++++++++++++----------------------- conf/mocha.conf.js | 5 +- 2 files changed, 83 insertions(+), 86 deletions(-) diff --git a/conf/karma.conf.js b/conf/karma.conf.js index b1895d1..8636a0e 100644 --- a/conf/karma.conf.js +++ b/conf/karma.conf.js @@ -1,86 +1,80 @@ -// Sample Karma configuration file, that contain pretty much all the available options -// It's used for running client tests on Travis (http://travis-ci.org/#!/karma-runner/karma) -// Most of the options can be overriden by cli arguments (see karma --help) -// -// For all available config options and default values, see: -// https://github.com/karma-runner/karma/blob/stable/lib/config.js#L54 - - -// base path, that will be used to resolve files and exclude -basePath = '../'; - -// list of files / patterns to load in the browser -files = [ - 'conf/mocha.conf.js', - 'node_modules/chai/chai.js', - 'test/*.js', - 'custom-elements.js', - {pattern: 'src/*', included: false}, - {pattern: 'tools/**/*.js', included: false} -]; - -// list of files to exclude -exclude = []; - -frameworks = ['mocha']; - -// use dots reporter, as travis terminal does not support escaping sequences -// possible values: 'dots', 'progress', 'junit', 'teamcity' -// CLI --reporters progress -reporters = ['progress']; - -// web server port -// CLI --port 9876 -port = 9876; - -// cli runner port -// CLI --runner-port 9100 -runnerPort = 9100; - -// enable / disable colors in the output (reporters and logs) -// CLI --colors --no-colors -colors = true; - -// level of logging -// possible values: LOG_DISABLE || LOG_ERROR || LOG_WARN || LOG_INFO || LOG_DEBUG -// CLI --log-level debug -logLevel = LOG_INFO; - -// enable / disable watching file and executing tests whenever any file changes -// CLI --auto-watch --no-auto-watch -autoWatch = true; - -// Start these browsers, currently available: -// - Chrome -// - ChromeCanary -// - Firefox -// - Opera -// - Safari (only Mac) -// - PhantomJS -// - IE (only Windows) -// CLI --browsers Chrome,Firefox,Safari -browsers = ['ChromeCanary']; - -// If browser does not capture in given timeout [ms], kill it -// CLI --capture-timeout 5000 -captureTimeout = 50000; - -// Auto run tests on start (when browsers are captured) and exit -// CLI --single-run --no-single-run -singleRun = true; - -// report which specs are slower than 500ms -// CLI --report-slower-than 500 -reportSlowerThan = 500; - -// compile coffee scripts -preprocessors = { +module.exports = function(karma) { + karma.configure({ + // base path, that will be used to resolve files and exclude + basePath: '../', + + // list of files / patterns to load in the browser + files: [ + 'tools/test/mocha-htmltest.js', + 'conf/mocha.conf.js', + 'node_modules/chai/chai.js', + 'custom-elements.js', + 'test/js/*.js', + {pattern: 'src/*', included: false}, + {pattern: 'test/html/*.html', included: false}, + {pattern: 'tools/**/*.js', included: false} + ], + + // list of files to exclude + exclude: [], + + frameworks: ['mocha'], + + // use dots reporter, as travis terminal does not support escaping sequences + // possible values: 'dots', 'progress', 'junit', 'teamcity' + // CLI --reporters progress + reporters: ['progress'], + + // web server port + // CLI --port 9876 + port: 9876, + + // cli runner port + // CLI --runner-port 9100 + runnerPort: 9100, + + // enable / disable colors in the output (reporters and logs) + // CLI --colors --no-colors + colors: true, + + // level of logging + // possible values: LOG_DISABLE || LOG_ERROR || LOG_WARN || LOG_INFO || LOG_DEBUG + // CLI --log-level debug + logLevel: karma.LOG_INFO, + + // enable / disable watching file and executing tests whenever any file changes + // CLI --auto-watch --no-auto-watch + autoWatch: true, + + // Start these browsers, currently available: + // - Chrome + // - ChromeCanary + // - Firefox + // - Opera + // - Safari (only Mac) + // - PhantomJS + // - IE (only Windows) + // CLI --browsers Chrome,Firefox,Safari + browsers: ['ChromeCanary'], + + // If browser does not capture in given timeout [ms], kill it + // CLI --capture-timeout 5000 + captureTimeout: 50000, + + // Auto run tests on start (when browsers are captured) and exit + // CLI --single-run --no-single-run + singleRun: true, + + // report which specs are slower than 500ms + // CLI --report-slower-than 500 + reportSlowerThan: 500, + + plugins: [ + 'karma-mocha', + 'karma-chrome-launcher', + 'karma-firefox-launcher', + 'karma-script-launcher', + 'karma-crbot-reporter' + ] + }); }; - -plugins = [ - 'karma-mocha', - 'karma-chrome-launcher', - 'karma-firefox-launcher', - 'karma-script-launcher', - 'karma-crbot-reporter' -] diff --git a/conf/mocha.conf.js b/conf/mocha.conf.js index 77468a5..ec309d3 100644 --- a/conf/mocha.conf.js +++ b/conf/mocha.conf.js @@ -1 +1,4 @@ -mocha.setup({ui:'tdd'}); +mocha.setup({ + ui:'tdd', + htmlbase: '/base/test/' +}); From 1ddca5e72edd64c523bac7cebbd586f0ebd6bfcb Mon Sep 17 00:00:00 2001 From: Yvonne Yip Date: Thu, 20 Jun 2013 14:50:06 -0700 Subject: [PATCH 2/7] add npm-debug.log to .gitignore --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 48f6001..a0e1fd4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,5 @@ /node_modules - +npm-debug.log /custom-elements.min.js /custom-elements.min.source-map.js /docs From 6f82b964060ae2d28e228ba7cd87e42f685382e4 Mon Sep 17 00:00:00 2001 From: Yvonne Yip Date: Thu, 20 Jun 2013 15:00:57 -0700 Subject: [PATCH 3/7] test: use main grunt-karma package --- gruntfile.js | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gruntfile.js b/gruntfile.js index 599801a..2b594d3 100644 --- a/gruntfile.js +++ b/gruntfile.js @@ -90,7 +90,7 @@ module.exports = function(grunt) { // plugins grunt.loadNpmTasks('grunt-contrib-uglify'); grunt.loadNpmTasks('grunt-contrib-yuidoc'); - grunt.loadNpmTasks('grunt-karma-0.9.1'); + grunt.loadNpmTasks('grunt-karma'); // tasks grunt.registerTask('default', ['uglify']); diff --git a/package.json b/package.json index 1159124..064ff41 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ "grunt": "*", "grunt-contrib-uglify": "*", "grunt-contrib-yuidoc": "~0.4.0", - "grunt-karma-0.9.1": "~0.4.3", + "grunt-karma": "~0.5.0", "karma-mocha": "*", "karma-script-launcher": "*", "karma-crbot-reporter": "*" From cc9621cfe5bf9dfe5ab8fcc296df92e29daddad5 Mon Sep 17 00:00:00 2001 From: Eric Bidelman Date: Thu, 27 Jun 2013 12:58:18 -0700 Subject: [PATCH 4/7] Date.now() is faster than new Date().getTime() http://jsperf.com/gettime-vs-now-0 --- src/boot.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/boot.js b/src/boot.js index 393aca1..1079a0b 100644 --- a/src/boot.js +++ b/src/boot.js @@ -18,7 +18,7 @@ function bootstrap() { // synchronous upgrades CustomElements.ready = true; // capture blunt profiling data - CustomElements.readyTime = new Date().getTime(); + CustomElements.readyTime = Date.now(); if (window.HTMLImports) { CustomElements.elapsed = CustomElements.readyTime - HTMLImports.readyTime; } From bdc3139c9c0ac04dd748668d05a10625df889b3f Mon Sep 17 00:00:00 2001 From: Arron Schaar Date: Fri, 28 Jun 2013 15:35:14 -0700 Subject: [PATCH 5/7] made script execution more specific to javascript --- src/HTMLElementElement.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/HTMLElementElement.js b/src/HTMLElementElement.js index 4765397..3247f6f 100644 --- a/src/HTMLElementElement.js +++ b/src/HTMLElementElement.js @@ -5,7 +5,7 @@ */ (function(){ - + var HTMLElementElement = function(inElement) { inElement.register = HTMLElementElement.prototype.register; parseElementElement(inElement); @@ -49,7 +49,7 @@ function parseElementElement(inElement) { // install options inElement.options = options; // locate user script - var script = inElement.querySelector('script,scripts'); + var script = inElement.querySelector('script:not([type]),script[type="text/javascript"],scripts'); if (script) { // execute user script in 'inElement' context executeComponentScript(script.textContent, inElement, options.name); @@ -63,7 +63,7 @@ function parseElementElement(inElement) { window[refName] = ctor; } } - + // each property in inDictionary takes a value // from the matching attribute in inElement, if any function takeAttributes(inElement, inDictionary) { @@ -81,7 +81,7 @@ function executeComponentScript(inScript, inContext, inName) { context = inContext; // source location var owner = context.ownerDocument; - var url = (owner._URL || owner.URL || owner.impl + var url = (owner._URL || owner.URL || owner.impl && (owner.impl._URL || owner.impl.URL)); // ensure the component has a unique source map so it can be debugged // if the name matches the filename part of the owning document's url, From 84c7f8746868eaf0e406316444778516a12c98b5 Mon Sep 17 00:00:00 2001 From: Daniel Freedman Date: Wed, 3 Jul 2013 17:24:16 -0700 Subject: [PATCH 6/7] use build manifest --- build.json | 10 ++++++++++ gruntfile.js | 14 +++----------- 2 files changed, 13 insertions(+), 11 deletions(-) create mode 100644 build.json diff --git a/build.json b/build.json new file mode 100644 index 0000000..87f6893 --- /dev/null +++ b/build.json @@ -0,0 +1,10 @@ +[ + "src/sidetable.js", + "MutationObservers/MutationObserver.js", + "src/CustomElements.js", + "src/MutationObserver.js", + "src/Observer.js", + "src/HTMLElementElement.js", + "src/Parser.js", + "src/boot.js" +] diff --git a/gruntfile.js b/gruntfile.js index 2b594d3..2e84ca5 100644 --- a/gruntfile.js +++ b/gruntfile.js @@ -12,14 +12,7 @@ module.exports = function(grunt) { if (os.type() === 'Windows_NT') { browsers.push('IE'); } - CustomElements = [ - 'src/sidetable.js', - 'MutationObservers/MutationObserver.js', - 'src/CustomElements.js', - 'src/HTMLElementElement.js', - 'src/Parser.js', - 'src/boot.js' - ]; + CustomElements = grunt.file.readJSON('build.json'); // karma setup var browsers; (function() { @@ -58,11 +51,10 @@ module.exports = function(grunt) { }, uglify: { CustomElements: { - /* options: { - sourceMap: 'custom-elements.min.source-map.js' + // sourceMap: 'custom-elements.min.source-map.js' + banner: grunt.file.read('LICENSE'); }, - */ files: { 'custom-elements.min.js': CustomElements } From ac5a5aba2296d758580063bce5fe8feb59bcc54a Mon Sep 17 00:00:00 2001 From: Daniel Freedman Date: Wed, 3 Jul 2013 17:39:44 -0700 Subject: [PATCH 7/7] fix hanging semicolon --- gruntfile.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gruntfile.js b/gruntfile.js index 2e84ca5..58b710a 100644 --- a/gruntfile.js +++ b/gruntfile.js @@ -53,7 +53,7 @@ module.exports = function(grunt) { CustomElements: { options: { // sourceMap: 'custom-elements.min.source-map.js' - banner: grunt.file.read('LICENSE'); + banner: grunt.file.read('LICENSE') }, files: { 'custom-elements.min.js': CustomElements