ci: Improve CI pipeline (#1790)

This commit is contained in:
Niklas von Hertzen 2019-04-06 23:07:52 -07:00 committed by GitHub
parent 24823d0491
commit c45ef099fe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 2358 additions and 1023 deletions

1
.gitignore vendored
View File

@ -1,4 +1,5 @@
/dist /dist
/tmp
/build /build
/nbproject/ /nbproject/
image.jpg image.jpg

View File

@ -5,6 +5,7 @@ scripts/
src/ src/
tests/ tests/
www/ www/
tmp/
.github/ .github/
*.iml *.iml
.babelrc .babelrc
@ -13,6 +14,7 @@ www/
.npmignore .npmignore
.eslintrc .eslintrc
.travis.yml .travis.yml
azure-pipelines.yml
karma.js karma.js
karma.conf.js karma.conf.js
webpack.config.js webpack.config.js

View File

@ -1,18 +1,15 @@
language: node_js language: node_js
node_js: node_js:
- '7' - '10'
stages:
- test
- release
env: env:
global: global:
- secure: eW41gIqOizwO4pTgWnAAbW75AP7F+CK9qfSed/fSh4sJ9HWMIY1YRIaY8gjr+6jV/f7XVHcXuym6ZxgINYSkVKbF1JKxBJNLOXtSgNbVHSic58pYFvUjwxIBI9aPig9uux1+DbnpWqXFDTcACJSevQZE0xwmjdrSkDLgB0G34v8= - secure: eW41gIqOizwO4pTgWnAAbW75AP7F+CK9qfSed/fSh4sJ9HWMIY1YRIaY8gjr+6jV/f7XVHcXuym6ZxgINYSkVKbF1JKxBJNLOXtSgNbVHSic58pYFvUjwxIBI9aPig9uux1+DbnpWqXFDTcACJSevQZE0xwmjdrSkDLgB0G34v8=
- secure: Y2Av+Gd3z9uQEB36GwdOOuGka0hx0/HeitASEo59z934O8RxnmN9eNTXS7dDT3XtKtwxIyLTOEpS7qlRdWahH28hr/dS4xJj6ao58C+1xMcDs6NAPGmDxUlcJWpcGEsnjmXjQCc3fBioSTdpIBrK/gdvgpNh77UKG74Sk7Z+YGk= - secure: Y2Av+Gd3z9uQEB36GwdOOuGka0hx0/HeitASEo59z934O8RxnmN9eNTXS7dDT3XtKtwxIyLTOEpS7qlRdWahH28hr/dS4xJj6ao58C+1xMcDs6NAPGmDxUlcJWpcGEsnjmXjQCc3fBioSTdpIBrK/gdvgpNh77UKG74Sk7Z+YGk=
addons:
chrome: stable
firefox: latest
dist: trusty dist: trusty
sudo: true sudo: true
before_script:
- export DISPLAY=:99.0
- sh -e /etc/init.d/xvfb start
notifications: notifications:
webhooks: webhooks:
urls: urls:
@ -20,21 +17,50 @@ notifications:
on_success: always on_success: always
on_failure: always on_failure: always
on_start: false on_start: false
install:
- npm ci
cache: npm
jobs:
include:
- stage: test
name: "Browser test - Internet Explorer 11"
os: windows
filter_secrets: false
if: type = push AND repo=niklasvh/html2canvas
script: script:
- npm run build - npm run build
- cd www && npm install && npm run build && cd .. - dir "c:\"
- npm test - dir "c:\Program Files"
- dir "c:\Program Files\internet explorer"
- dir "c:\Program Files (x86)"
- dir "c:\Program Files (x86)\internet explorer"
- "c:\Program Files (x86)\internet explorer\iexplore.exe" http://blog.hertzen.com/
- TARGET_BROWSER=IE_11 IE_BIN="c:\Program Files (x86)\Internet Explorer\iexplore.exe" npm run karma
- stage: test
name: "Build docs"
script:
- npm run build && cd www && npm install && npm run build && cd ..
- stage: release
name: "Deploy docs"
script: skip
if: type = push AND branch=master AND repo=niklasvh/html2canvas
deploy: deploy:
- provider: npm provider: pages
email: niklasvh@gmail.com
api_key:
secure: G/Szpr8q4/D6hp+H/Z9yyluUXtHAwf7LLa1Y07X59/Enlj1h7V5fQ7AW4/iAVM3XbIsrCPWR3dJU9g/ZxpxFg4OovIHVpS2Jr/mahtPYWdHR3pWuSmMW8QD+Twnq2VAFwSgg5Oumq3QxhX3YbCOnZox6+6Uviqk8FO7Z5B0RwW4=
skip_cleanup: true skip_cleanup: true
local_dir: www/public
target_branch: gh-pages
fqdn: html2canvas.hertzen.com
github_token:
secure: "PowO/Jat660k3gHcjgI6DlJz15RM7pLUu11UPsLCtYJ8ZwodppE6Keg0DfVkSFSIZttZor+UssDwP/WOEqfZNLqmXbcj3Gec4xolohet/GOe0KJKKuF/HgggbcxumopxMX6sMVePlMBpkLpHh7tgEAEHBWTlzC1c1a7Xa48fZ7k="
on: on:
tags: true
branch: master branch: master
repo: niklasvh/html2canvas repo: niklasvh/html2canvas
- provider: releases - stage: release
name: "GitHub release"
script: skip
if: type = push AND tag IS present AND branch=master AND repo=niklasvh/html2canvas
deploy:
provider: releases
api_key: api_key:
secure: "PowO/Jat660k3gHcjgI6DlJz15RM7pLUu11UPsLCtYJ8ZwodppE6Keg0DfVkSFSIZttZor+UssDwP/WOEqfZNLqmXbcj3Gec4xolohet/GOe0KJKKuF/HgggbcxumopxMX6sMVePlMBpkLpHh7tgEAEHBWTlzC1c1a7Xa48fZ7k=" secure: "PowO/Jat660k3gHcjgI6DlJz15RM7pLUu11UPsLCtYJ8ZwodppE6Keg0DfVkSFSIZttZor+UssDwP/WOEqfZNLqmXbcj3Gec4xolohet/GOe0KJKKuF/HgggbcxumopxMX6sMVePlMBpkLpHh7tgEAEHBWTlzC1c1a7Xa48fZ7k="
file: file:
@ -45,13 +71,18 @@ deploy:
tags: true tags: true
branch: master branch: master
repo: niklasvh/html2canvas repo: niklasvh/html2canvas
- provider: pages - stage: release
name: "npm release"
script: skip
if: type = push AND tag IS present AND branch=master AND repo=niklasvh/html2canvas
deploy:
provider: npm
email: niklasvh@gmail.com
api_key:
secure: G/Szpr8q4/D6hp+H/Z9yyluUXtHAwf7LLa1Y07X59/Enlj1h7V5fQ7AW4/iAVM3XbIsrCPWR3dJU9g/ZxpxFg4OovIHVpS2Jr/mahtPYWdHR3pWuSmMW8QD+Twnq2VAFwSgg5Oumq3QxhX3YbCOnZox6+6Uviqk8FO7Z5B0RwW4=
skip_cleanup: true skip_cleanup: true
local_dir: www/public
target_branch: gh-pages
fqdn: html2canvas.hertzen.com
github_token:
secure: "PowO/Jat660k3gHcjgI6DlJz15RM7pLUu11UPsLCtYJ8ZwodppE6Keg0DfVkSFSIZttZor+UssDwP/WOEqfZNLqmXbcj3Gec4xolohet/GOe0KJKKuF/HgggbcxumopxMX6sMVePlMBpkLpHh7tgEAEHBWTlzC1c1a7Xa48fZ7k="
on: on:
tags: true
branch: master branch: master
repo: niklasvh/html2canvas repo: niklasvh/html2canvas
script: skip

View File

@ -4,7 +4,7 @@ html2canvas
[Homepage](https://html2canvas.hertzen.com) | [Downloads](https://github.com/niklasvh/html2canvas/releases) | [Questions](http://stackoverflow.com/questions/tagged/html2canvas?sort=newest) | [Donate](https://www.gittip.com/niklasvh/) [Homepage](https://html2canvas.hertzen.com) | [Downloads](https://github.com/niklasvh/html2canvas/releases) | [Questions](http://stackoverflow.com/questions/tagged/html2canvas?sort=newest) | [Donate](https://www.gittip.com/niklasvh/)
[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/niklasvh/html2canvas?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge) [![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/niklasvh/html2canvas?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
[![Build Status](https://travis-ci.org/niklasvh/html2canvas.svg)](https://travis-ci.org/niklasvh/html2canvas) [![Build Status](https://dev.azure.com/niklasvh/html2canvas/_apis/build/status/niklasvh.html2canvas?branchName=master)](https://dev.azure.com/niklasvh/html2canvas/_build/latest?definitionId=1&branchName=master)
[![NPM Downloads](https://img.shields.io/npm/dm/html2canvas.svg)](https://www.npmjs.org/package/html2canvas) [![NPM Downloads](https://img.shields.io/npm/dm/html2canvas.svg)](https://www.npmjs.org/package/html2canvas)
[![NPM Version](https://img.shields.io/npm/v/html2canvas.svg)](https://www.npmjs.org/package/html2canvas) [![NPM Version](https://img.shields.io/npm/v/html2canvas.svg)](https://www.npmjs.org/package/html2canvas)

296
azure-pipelines.yml Normal file
View File

@ -0,0 +1,296 @@
trigger:
- master
jobs:
- job: Build
displayName: Build
pool:
vmImage: 'Ubuntu-16.04'
steps:
- task: NodeTool@0
inputs:
versionSpec: '10.x'
displayName: 'Install Node.js'
- task: Npm@0
inputs:
command: install
- script: npm run build
displayName: Build
- task: PublishBuildArtifacts@1
inputs:
PathtoPublish: 'dist'
artifactName: dist
- task: PublishBuildArtifacts@1
inputs:
PathtoPublish: 'build'
artifactName: build
- job: Test
displayName: Tests
pool:
vmImage: 'Ubuntu-16.04'
steps:
- task: NodeTool@0
inputs:
versionSpec: '10.x'
displayName: 'Install Node.js'
- task: Npm@0
inputs:
command: install
- script: npm run build
displayName: Build
- script: npm run lint
displayName: Lint
- script: npm run flow
displayName: Flow
- script: npm run test:node
displayName: Unit tests
- job: Build_docs
displayName: Build docs
pool:
vmImage: 'Ubuntu-16.04'
steps:
- task: NodeTool@0
inputs:
versionSpec: '10.x'
displayName: 'Install Node.js'
- task: Npm@0
inputs:
command: install
- script: npm run build && cd www && npm install && npm run build && cd ..
displayName: Build docs
- task: PublishBuildArtifacts@1
inputs:
PathtoPublish: 'www/public'
artifactName: docs
- job: Browser_Tests_Linux_Firefox_Stable
displayName: Linux Firefox Stable
pool:
vmImage: 'Ubuntu-16.04'
variables:
TARGET_BROWSER: Firefox_Stable
dependsOn: Build
condition: succeeded()
steps:
- task: NodeTool@0
inputs:
versionSpec: '10.x'
displayName: 'Install Node.js'
- task: Npm@0
inputs:
command: install
- task: DownloadBuildArtifacts@0
displayName: 'Download library'
inputs:
artifactName: dist
downloadPath: $(System.DefaultWorkingDirectory)
- task: DownloadBuildArtifacts@0
displayName: 'Download testrunner'
inputs:
artifactName: build
downloadPath: $(System.DefaultWorkingDirectory)
- script: Xvfb :99 &
displayName: 'Start Xvfb'
- script: DISPLAY=:99 npm run karma
displayName: 'Run Firefox tests - Firefox Stable'
- task: PublishTestResults@2
condition: succeededOrFailed()
inputs:
testRunner: JUnit
testResultsFiles: 'tmp/junit/*.xml'
- task: PublishBuildArtifacts@1
condition: succeededOrFailed()
inputs:
PathtoPublish: 'tmp/reftests'
artifactName: ReftestResults
- job: Browser_Tests_Linux_Chrome_Stable
displayName: Linux Chrome Stable
pool:
vmImage: 'Ubuntu-16.04'
variables:
TARGET_BROWSER: Chrome_Stable
dependsOn: Build
condition: succeeded()
steps:
- task: NodeTool@0
inputs:
versionSpec: '10.x'
displayName: 'Install Node.js'
- task: Npm@0
inputs:
command: install
- task: DownloadBuildArtifacts@0
displayName: 'Download library'
inputs:
artifactName: dist
downloadPath: $(System.DefaultWorkingDirectory)
- task: DownloadBuildArtifacts@0
displayName: 'Download testrunner'
inputs:
artifactName: build
downloadPath: $(System.DefaultWorkingDirectory)
- script: Xvfb :99 &
displayName: 'Start Xvfb'
- script: DISPLAY=:99 npm run karma
displayName: 'Run Chrome tests - Chrome Stable'
- task: PublishTestResults@2
condition: succeededOrFailed()
inputs:
testRunner: JUnit
testResultsFiles: 'tmp/junit/*.xml'
- task: PublishBuildArtifacts@1
condition: succeededOrFailed()
inputs:
PathtoPublish: 'tmp/reftests'
artifactName: ReftestResults
- job: Browser_Tests_OSX_Safari_Stable
displayName: OSX Safari Stable
pool:
vmImage: 'macOS-10.13'
variables:
TARGET_BROWSER: Safari_Stable
dependsOn: Build
condition: succeeded()
steps:
- task: NodeTool@0
inputs:
versionSpec: '10.x'
displayName: 'Install Node.js'
- task: Npm@0
inputs:
command: install
- task: DownloadBuildArtifacts@0
displayName: 'Download library'
inputs:
artifactName: dist
downloadPath: $(System.DefaultWorkingDirectory)
- task: DownloadBuildArtifacts@0
displayName: 'Download testrunner'
inputs:
artifactName: build
downloadPath: $(System.DefaultWorkingDirectory)
- script: npm run karma
displayName: 'Run Safari tests - Safari Stable'
- task: PublishTestResults@2
condition: succeededOrFailed()
inputs:
testRunner: JUnit
testResultsFiles: 'tmp/junit/*.xml'
- task: PublishBuildArtifacts@1
condition: succeededOrFailed()
inputs:
PathtoPublish: 'tmp/reftests'
artifactName: ReftestResults
- job: Browser_Tests_Windows_IE9
displayName: Windows Internet Explorer 9 (Emulated)
pool:
vmImage: 'vs2017-win2016'
variables:
TARGET_BROWSER: IE_9
dependsOn: Build
condition: succeeded()
steps:
- task: NodeTool@0
inputs:
versionSpec: '10.x'
displayName: 'Install Node.js'
- task: Npm@0
inputs:
command: install
- task: DownloadBuildArtifacts@0
displayName: 'Download library'
inputs:
artifactName: dist
downloadPath: $(System.DefaultWorkingDirectory)
- task: DownloadBuildArtifacts@0
displayName: 'Download testrunner'
inputs:
artifactName: build
downloadPath: $(System.DefaultWorkingDirectory)
- script: npm run karma
displayName: 'Run Internet Explorer tests - IE 9'
- task: PublishTestResults@2
condition: succeededOrFailed()
inputs:
testRunner: JUnit
testResultsFiles: 'tmp/junit/*.xml'
- task: PublishBuildArtifacts@1
condition: succeededOrFailed()
inputs:
PathtoPublish: 'tmp/reftests'
artifactName: ReftestResults
- job: Browser_Tests_Windows_IE10
displayName: Windows Internet Explorer 10 (Emulated)
pool:
vmImage: 'vs2017-win2016'
variables:
TARGET_BROWSER: IE_10
dependsOn: Build
condition: succeeded()
steps:
- task: NodeTool@0
inputs:
versionSpec: '10.x'
displayName: 'Install Node.js'
- task: Npm@0
inputs:
command: install
- task: DownloadBuildArtifacts@0
displayName: 'Download library'
inputs:
artifactName: dist
downloadPath: $(System.DefaultWorkingDirectory)
- task: DownloadBuildArtifacts@0
displayName: 'Download testrunner'
inputs:
artifactName: build
downloadPath: $(System.DefaultWorkingDirectory)
- script: npm run karma
displayName: 'Run Internet Explorer tests - IE 10'
- task: PublishTestResults@2
condition: succeededOrFailed()
inputs:
testRunner: JUnit
testResultsFiles: 'tmp/junit/*.xml'
- task: PublishBuildArtifacts@1
condition: succeededOrFailed()
inputs:
PathtoPublish: 'tmp/reftests'
artifactName: ReftestResults
- job: Browser_Tests_Windows_IE11
displayName: Windows Internet Explorer 11
pool:
vmImage: 'vs2017-win2016'
variables:
TARGET_BROWSER: IE_11
dependsOn: Build
condition: succeeded()
steps:
- task: NodeTool@0
inputs:
versionSpec: '10.x'
displayName: 'Install Node.js'
- task: Npm@0
inputs:
command: install
- task: DownloadBuildArtifacts@0
displayName: 'Download library'
inputs:
artifactName: dist
downloadPath: $(System.DefaultWorkingDirectory)
- task: DownloadBuildArtifacts@0
displayName: 'Download testrunner'
inputs:
artifactName: build
downloadPath: $(System.DefaultWorkingDirectory)
- script: npm run karma
displayName: 'Run Internet Explorer tests - IE 11'
- task: PublishTestResults@2
condition: succeededOrFailed()
inputs:
testRunner: JUnit
testResultsFiles: 'tmp/junit/*.xml'
- task: PublishBuildArtifacts@1
condition: succeededOrFailed()
inputs:
PathtoPublish: 'tmp/reftests'
artifactName: ReftestResults

View File

@ -1,82 +1,101 @@
// Karma configuration // Karma configuration
// Generated on Sat Aug 05 2017 23:42:26 GMT+0800 (Malay Peninsula Standard Time) // Generated on Sat Aug 05 2017 23:42:26 GMT+0800 (Malay Peninsula Standard Time)
const path = require('path');
const port = 9876; const port = 9876;
module.exports = function(config) { module.exports = function(config) {
const slLaunchers = (!process.env.SAUCE_USERNAME || !process.env.SAUCE_ACCESS_KEY) ? {} : { const launchers = {
sl_beta_chrome: { SauceLabs_IE9: {
base: 'SauceLabs',
browserName: 'chrome',
platform: 'Windows 10',
version: 'beta'
},
sl_ie9: {
base: 'SauceLabs', base: 'SauceLabs',
browserName: 'internet explorer', browserName: 'internet explorer',
version: '9.0', version: '9.0',
platform: 'Windows 7' platform: 'Windows 7'
}, },
sl_ie10: { SauceLabs_IE10: {
base: 'SauceLabs', base: 'SauceLabs',
browserName: 'internet explorer', browserName: 'internet explorer',
version: '10.0', version: '10.0',
platform: 'Windows 7' platform: 'Windows 7'
}, },
sl_ie11: { SauceLabs_IE11: {
base: 'SauceLabs', base: 'SauceLabs',
browserName: 'internet explorer', browserName: 'internet explorer',
version: '11.0', version: '11.0',
platform: 'Windows 7' platform: 'Windows 7'
}, },
sl_edge_15: { SauceLabs_Edge18: {
base: 'SauceLabs', base: 'SauceLabs',
browserName: 'MicrosoftEdge', browserName: 'MicrosoftEdge',
version: '15.15063', version: '18.17763',
platform: 'Windows 10' platform: 'Windows 10'
}, },
sl_edge_14: { SauceLabs_Android4: {
base: 'SauceLabs',
browserName: 'MicrosoftEdge',
version: '14.14393',
platform: 'Windows 10'
},
sl_safari: {
base: 'SauceLabs',
browserName: 'safari',
version: '10.1',
platform: 'macOS 10.12'
},
'sl_android_4.4': {
base: 'SauceLabs', base: 'SauceLabs',
browserName: 'Browser', browserName: 'Browser',
platform: 'Android', platform: 'Android',
version: '4.4', version: '4.4',
device: 'Android Emulator', device: 'Android Emulator',
}, },
'sl_ios_10.3_safari': { SauceLabs_iOS10_3: {
base: 'SauceLabs', base: 'SauceLabs',
browserName: 'Safari', browserName: 'Safari',
platform: 'iOS', platform: 'iOS',
version: '10.3', version: '10.3',
device: 'iPhone 7 Plus Simulator' device: 'iPhone 7 Plus Simulator'
}, },
'sl_ios_9.3_safari': { SauceLabs_iOS9_3: {
base: 'SauceLabs', base: 'SauceLabs',
browserName: 'Safari', browserName: 'Safari',
platform: 'iOS', platform: 'iOS',
version: '9.3', version: '9.3',
device: 'iPhone 6 Plus Simulator' device: 'iPhone 6 Plus Simulator'
},
IE_9: {
base: 'IE',
'x-ua-compatible': 'IE=EmulateIE9',
flags: ['-extoff']
},
IE_10: {
base: 'IE',
'x-ua-compatible': 'IE=EmulateIE10',
flags: ['-extoff']
},
IE_11: {
base: 'IE',
flags: ['-extoff']
},
Safari_Stable: {
base: 'Safari'
},
Chrome_Stable: {
base: 'Chrome'
},
Firefox_Stable: {
base: 'Firefox'
} }
}; };
const customLaunchers = Object.assign({}, slLaunchers, { const ciLauncher = launchers[process.env.TARGET_BROWSER];
const customLaunchers = ciLauncher ? {target_browser: ciLauncher} : {
stable_chrome: { stable_chrome: {
base: 'Chrome' base: 'Chrome'
}, },
stable_firefox: { stable_firefox: {
base: 'Firefox' base: 'Firefox'
} }
};
const injectTypedArrayPolyfills = function(files) {
files.unshift({
pattern: path.resolve(__dirname, './node_modules/js-polyfills/typedarray.js'),
included: true,
served: true,
watched: false
}); });
};
injectTypedArrayPolyfills.$inject = ['config.files'];
config.set({ config.set({
@ -86,17 +105,22 @@ module.exports = function(config) {
// frameworks to use // frameworks to use
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter // available frameworks: https://npmjs.org/browse/keyword/karma-adapter
frameworks: ['mocha'], frameworks: ['mocha', 'inline-mocha-fix'],
// list of files / patterns to load in the browser // list of files / patterns to load in the browser
files: [ files: [
'build/testrunner.js', 'build/testrunner.js',
{ pattern: './tests/**/*', 'watched': true, 'included': false, 'served': true}, { pattern: './tests/**/*', 'watched': true, 'included': false, 'served': true},
{ pattern: './dist/**/*', 'watched': true, 'included': false, 'served': true}, { pattern: './dist/**/*', 'watched': true, 'included': false, 'served': true},
{ pattern: './node_modules/**/*', 'watched': true, 'included': false, 'served': true} { pattern: './node_modules/**/*', 'watched': true, 'included': false, 'served': true},
], ],
plugins: [
'karma-*',
{
'framework:inline-mocha-fix': ['factory', injectTypedArrayPolyfills]
}
],
// list of files to exclude // list of files to exclude
exclude: [ exclude: [
@ -112,7 +136,11 @@ module.exports = function(config) {
// test results reporter to use // test results reporter to use
// possible values: 'dots', 'progress' // possible values: 'dots', 'progress'
// available reporters: https://npmjs.org/browse/keyword/karma-reporter // available reporters: https://npmjs.org/browse/keyword/karma-reporter
reporters: ['progress', 'saucelabs'], reporters: ['dots', 'junit'],
junitReporter: {
outputDir: 'tmp/junit/'
},
// web server port // web server port
port, port,

View File

@ -14,6 +14,12 @@ const bodyParser = require('body-parser');
const cors = require('cors'); const cors = require('cors');
const filenamifyUrl = require('filenamify-url'); const filenamifyUrl = require('filenamify-url');
const mkdirp = require('mkdirp');
const screenshotFolder = './tmp/reftests';
mkdirp.sync(path.resolve(__dirname, screenshotFolder));
const CORS_PORT = 8081; const CORS_PORT = 8081;
const corsApp = express(); const corsApp = express();
corsApp.use('/proxy', proxy()); corsApp.use('/proxy', proxy());
@ -59,9 +65,9 @@ const writeScreenshot = (buffer, body) => {
const filename = `${filenamifyUrl( const filename = `${filenamifyUrl(
body.test.replace(/^\/tests\/reftests\//, '').replace(/\.html$/, ''), body.test.replace(/^\/tests\/reftests\//, '').replace(/\.html$/, ''),
{replacement: '-'} {replacement: '-'}
)}!${body.platform.name}-${body.platform.version}.png`; )}!${[process.env.TARGET_BROWSER, body.platform.name, body.platform.version].join('-')}.png`;
fs.writeFileSync(path.resolve(__dirname, './tests/results/', filename), buffer); fs.writeFileSync(path.resolve(__dirname, screenshotFolder, filename), buffer);
}; };
app.post('/screenshot', (req, res) => { app.post('/screenshot', (req, res) => {

2747
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -40,20 +40,23 @@
"eslint": "4.2.0", "eslint": "4.2.0",
"eslint-plugin-flowtype": "2.35.0", "eslint-plugin-flowtype": "2.35.0",
"eslint-plugin-prettier": "2.1.2", "eslint-plugin-prettier": "2.1.2",
"express": "4.15.4", "express": "^4.16.4",
"filenamify-url": "1.0.0", "filenamify-url": "1.0.0",
"flow-bin": "0.56.0", "flow-bin": "0.56.0",
"glob": "7.1.2", "glob": "7.1.2",
"html2canvas-proxy": "1.0.1", "html2canvas-proxy": "1.0.1",
"jquery": "3.2.1", "jquery": "3.2.1",
"karma": "1.7.0", "js-polyfills": "^0.1.42",
"karma-chrome-launcher": "2.2.0", "karma": "^4.0.1",
"karma-edge-launcher": "0.4.1", "karma-chrome-launcher": "^2.2.0",
"karma-firefox-launcher": "1.0.1", "karma-edge-launcher": "^0.4.2",
"karma-ie-launcher": "1.0.0", "karma-firefox-launcher": "^1.1.0",
"karma-mocha": "1.3.0", "karma-ie-launcher": "^1.0.0",
"karma-sauce-launcher": "1.1.0", "karma-junit-reporter": "^1.2.0",
"mocha": "5.2.0", "karma-mocha": "^1.3.0",
"karma-safari-launcher": "^1.0.0",
"karma-sauce-launcher": "^2.0.2",
"mocha": "^6.0.2",
"platform": "1.3.4", "platform": "1.3.4",
"prettier": "1.5.3", "prettier": "1.5.3",
"promise-polyfill": "6.0.2", "promise-polyfill": "6.0.2",

View File

@ -0,0 +1,2 @@
[Safari]/tests/reftests/acid2.html
[Safari]/tests/reftests/background/encoded.html

View File

@ -75,7 +75,7 @@ const assertPath = (result, expected, desc) => {
.filter(test => { .filter(test => {
return ( return (
!Array.isArray(reftests.ignoredTests[test]) || !Array.isArray(reftests.ignoredTests[test]) ||
reftests.ignoredTests[test].indexOf(query.browser) === -1 reftests.ignoredTests[test].indexOf(platform.name) === -1
); );
}) })
.forEach(url => { .forEach(url => {
@ -342,9 +342,6 @@ const assertPath = (result, expected, desc) => {
} }
if (window.__karma__) { if (window.__karma__) {
const MAX_CHUNK_SIZE = 75000;
const sendScreenshot = (tries, body, server) => {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
const xhr = const xhr =
'withCredentials' in new XMLHttpRequest() 'withCredentials' in new XMLHttpRequest()
@ -365,56 +362,17 @@ const assertPath = (result, expected, desc) => {
}; };
xhr.onerror = reject; xhr.onerror = reject;
xhr.open('POST', server, true); xhr.open('POST', 'http://localhost:8000/screenshot', true);
xhr.send(body); xhr.send(JSON.stringify({
}).catch(e => {
if (tries > 0) {
// Older edge browsers and some safari browsers have issues sending large xhr through saucetunnel
const data = canvas.toDataURL();
const totalCount = Math.ceil(
data.length / MAX_CHUNK_SIZE
);
return Promise.all(
Array.apply(
null,
Array(totalCount)
).map((x, part) =>
sendScreenshot(
0,
JSON.stringify({
screenshot: data.substr(
part * MAX_CHUNK_SIZE,
MAX_CHUNK_SIZE
),
part,
totalCount,
test: url,
platform: {
name: platform.name,
version: platform.version
}
}),
'http://localhost:8000/screenshot/chunk'
)
)
);
}
return Promise.reject(e);
});
};
return sendScreenshot(
1,
JSON.stringify({
screenshot: canvas.toDataURL(), screenshot: canvas.toDataURL(),
test: url, test: url,
platform: { platform: {
name: platform.name, name: platform.name,
version: platform.version version: platform.version
} }
}), }));
'http://localhost:8000/screenshot' });
);
} }
}); });
}); });

1
www/static/CNAME Normal file
View File

@ -0,0 +1 @@
html2canvas.hertzen.com