diff --git a/.gitignore b/.gitignore
index 3dd5867b..1bcc565b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,3 @@
node_modules
+bower_components
*.iml
diff --git a/Gruntfile.js b/Gruntfile.js
index c07692af..bf9f2fba 100644
--- a/Gruntfile.js
+++ b/Gruntfile.js
@@ -3,7 +3,7 @@ module.exports = function (grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
jshint: {
- files: ['Gruntfile.js', 'src/**/*.js', 'test/**/*.js'],
+ files: ['Gruntfile.js', 'src/**/*.js', 'spec/**/*.js'],
options: {
globals: {
console: true,
diff --git a/bower.json b/bower.json
index 5c515422..d34c5897 100644
--- a/bower.json
+++ b/bower.json
@@ -23,5 +23,11 @@
"bower_components",
"test",
"tests"
- ]
+ ],
+ "devDependencies": {
+ "js-imagediff": "~1.0.8",
+ "fixtures": "~1.5.3",
+ "jquery": "~2.1.3",
+ "bluebird": "~2.9.24"
+ }
}
diff --git a/demo/firefox/firefox.html b/demo/firefox/firefox.html
index 72a4fc58..663a3cc3 100644
--- a/demo/firefox/firefox.html
+++ b/demo/firefox/firefox.html
@@ -1,67 +1,74 @@
+
-
-
red
-
green
-
blue
+
+
+
+
+
-
-
-
-
-
+
diff --git a/karma.conf.js b/karma.conf.js
index f315a18b..21d51e43 100644
--- a/karma.conf.js
+++ b/karma.conf.js
@@ -2,12 +2,21 @@ module.exports = function (config) {
config.set({
basePath: '',
frameworks: ['mocha', 'chai'],
-
- files: [
+
+ files: [{
+ pattern: 'spec/resources/regression-simple.html',
+ included: false,
+ served: true
+ },
+
+ 'bower_components/jquery/dist/jquery.js',
+ 'bower_components/bluebird/js/browser/bluebird.js',
+ 'bower_components/js-imagediff/imagediff.js',
+
'src/domvas.js',
- 'test/**/*spec.js'
+ 'spec/**/*spec.js'
],
-
+
exclude: [],
preprocessors: {},
reporters: ['mocha'],
@@ -15,15 +24,7 @@ module.exports = function (config) {
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
- browsers: ['chrome-small'],
- customLaunchers: {
- 'chrome-small': {
- base: 'Chrome',
- flags: [
- '--window-size=300,200'
- ]
- }
- },
+ browsers: ['Chrome', 'Firefox'],
singleRun: true
});
};
diff --git a/spec/domvas.spec.js b/spec/domvas.spec.js
new file mode 100644
index 00000000..8b87c9f1
--- /dev/null
+++ b/spec/domvas.spec.js
@@ -0,0 +1,31 @@
+describe('domvas', function () {
+ 'use strict';
+
+ var assert = chai.assert;
+
+ it('should load', function () {
+ assert.ok(domvas);
+ });
+
+ it('should render simple css correctly', function (done) {
+ loadHtml('regression-simple.html').then(function (html) {
+ document.write(html);
+ var dom_node = $('#dom-node')[0];
+ console.log('hey! ' + dom_node);
+ done();
+ });
+ });
+
+ function loadHtml(path) {
+ return new Promise(function (resolve) {
+ var request = new XMLHttpRequest();
+ console.log('request ' + request);
+ request.open('GET', '/base/spec/resources/' + path, true);
+ request.responseType = 'text/html';
+ request.onload = function () {
+ if (this.status == 200) resolve(request.response.toString());
+ };
+ request.send();
+ });
+ }
+});
diff --git a/spec/resources/regression-simple.html b/spec/resources/regression-simple.html
new file mode 100644
index 00000000..b061dc24
--- /dev/null
+++ b/spec/resources/regression-simple.html
@@ -0,0 +1,49 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/domvas.js b/src/domvas.js
index 94e4f384..c74a039e 100644
--- a/src/domvas.js
+++ b/src/domvas.js
@@ -1,14 +1,14 @@
-(function (global) {
+(function(global) {
"use strict";
function copyCss(source, target) {
- var sourceStyle = global.window.getComputedStyle(source);
+ var sourceStyle = global.window.getComputedStyle(source);
if (sourceStyle.cssText) {
target.style.cssText = sourceStyle.cssText;
return;
}
-
+
for (var i = 0; i < sourceStyle.length; i++) {
var propertyName = sourceStyle[i];
target.style.setProperty(
@@ -28,7 +28,7 @@
copyCss(origElem, elem);
// collect all nodes within the element, copy the current style to the clone
- Array.prototype.forEach.call(children, function (child, i) {
+ Array.prototype.forEach.call(children, function(child, i) {
copyCss(origChildren[i], child);
});
@@ -39,7 +39,7 @@
function init() {
return {
- toImage: function (origElem, callback, width, height, left, top) {
+ toImage: function(origElem, callback, width, height, left, top) {
left = (left || 0);
top = (top || 0);
@@ -68,7 +68,7 @@
img.src = dataUri;
// when loaded, fire onload callback with actual image node
- img.onload = function () {
+ img.onload = function() {
if (callback) {
callback.call(img, img);
}
@@ -79,4 +79,3 @@
global.domvas = init();
})(this);
-
diff --git a/test/domvas.spec.js b/test/domvas.spec.js
deleted file mode 100644
index 0799865c..00000000
--- a/test/domvas.spec.js
+++ /dev/null
@@ -1,8 +0,0 @@
-describe('domvas', function () {
- 'use strict';
- var assert = chai.assert;
-
- it('should load', function () {
- assert.ok(domvas);
- })
-});