- Fix: Avoid errors occurring in Chrome now for `supportsGoodTextCharPos`

- Linting: Avoid Jamilih file in doc linting
- Testing: Add testcafe (ESLint plugin/rules, accessibility test
  (failing), ui test beginnings (passing))
- Docs: Add "Testing" prefix to contributing file
- npm: Bump to 3.0.0-rc.3
master
Brett Zamir 2018-09-30 12:05:50 +08:00
parent 1a214ae444
commit 71b2b33e41
19 changed files with 2474 additions and 35 deletions

View File

@ -1,9 +1,9 @@
{
"extends": ["standard", "plugin:qunit/recommended"],
"extends": ["standard", "plugin:qunit/recommended", "plugin:testcafe/recommended"],
"parserOptions": {
"sourceType": "module"
},
"plugins": ["qunit"],
"plugins": ["qunit", "testcafe"],
"env": {
"node": false,
"browser": true

View File

@ -1,4 +1,4 @@
# ?
# 3.0.0-rc.3
- Security fix/Breaking change (Imagelib): Only allow origins within
`imgLibs` to be accepted for `message` listener
@ -26,6 +26,7 @@
- Fix: Avoid error if `URL` is not defined (export)
- Fix: Ensure repeated selection of same file overwrites with that
file's contents (fix #289)
- Fix: Avoid errors occurring in Chrome now for `supportsGoodTextCharPos`
- Fix (jPicker): Avoid setting `Math.precision` pseudo-global
- Fix (jPicker): Precision argument had not been passed in previously
- Fix (image import): Put src after onload to avoid missing event;
@ -54,6 +55,8 @@
but hoping for in-code flagging)
- Linting (LGTM): Flag origin-checked item as safe
- Linting (ESLint): Consistent spacing; new "standard"
- Testing: Add testcafe (ESLint plugin/rules, accessibility test
(failing), ui test beginnings (passing))
- Docs: Contributing file
- Docs (JSDoc): Missing return value
- Update (Imagelib): Remove extra (and more outdated) jQuery copy

View File

@ -89,6 +89,7 @@ incorporating SVGEdit.
## Recent news
- 2018-09-30 Published 3.0.0-rc.3 with security and other fixes
- 2018-07-31 Published 3.0.0-rc.2 with misc. fixes
- 2018-07-19 Published 3.0.0-rc.1 allowing for extensions and locales to be
expressed as modules

15
dist/index-es.js vendored
View File

@ -2666,7 +2666,7 @@ var supportsPathInsertItemBefore_ = function () {
} catch (err) {}
return false;
}(); // text character positioning (for IE9)
}(); // text character positioning (for IE9 and now Chrome)
var supportsGoodTextCharPos_ = function () {
@ -2678,9 +2678,16 @@ var supportsGoodTextCharPos_ = function () {
var text = document.createElementNS(NS.SVG, 'text');
text.textContent = 'a';
svgcontent.append(text);
var pos = text.getStartPositionOfChar(0).x;
svgroot.remove();
return pos === 0;
try {
// Chrome now fails here
var pos = text.getStartPositionOfChar(0).x;
return pos === 0;
} catch (err) {
return false;
} finally {
svgroot.remove();
}
}();
var supportsPathBBox_ = function () {

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

15
dist/index-umd.js vendored
View File

@ -2672,7 +2672,7 @@
} catch (err) {}
return false;
}(); // text character positioning (for IE9)
}(); // text character positioning (for IE9 and now Chrome)
var supportsGoodTextCharPos_ = function () {
@ -2684,9 +2684,16 @@
var text = document.createElementNS(NS.SVG, 'text');
text.textContent = 'a';
svgcontent.append(text);
var pos = text.getStartPositionOfChar(0).x;
svgroot.remove();
return pos === 0;
try {
// Chrome now fails here
var pos = text.getStartPositionOfChar(0).x;
return pos === 0;
} catch (err) {
return false;
} finally {
svgroot.remove();
}
}();
var supportsPathBBox_ = function () {

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -2474,7 +2474,7 @@
} catch (err) {}
return false;
}(); // text character positioning (for IE9)
}(); // text character positioning (for IE9 and now Chrome)
var supportsGoodTextCharPos_ = function () {
@ -2486,9 +2486,16 @@
var text = document.createElementNS(NS.SVG, 'text');
text.textContent = 'a';
svgcontent.append(text);
var pos = text.getStartPositionOfChar(0).x;
svgroot.remove();
return pos === 0;
try {
// Chrome now fails here
var pos = text.getStartPositionOfChar(0).x;
return pos === 0;
} catch (err) {
return false;
} finally {
svgroot.remove();
}
}();
var supportsPathBBox_ = function () {

View File

@ -12,6 +12,7 @@
- `Enhancement: `
- `Refactoring: `
- `Linting (<type>):` - Linting by type, e.g., "ESLint"
- `Testing:`
- `Docs: `
- `Update: ` - e.g., if updating a bundled library
- `Build: `

View File

@ -71,7 +71,7 @@ try {
return false;
}());
// text character positioning (for IE9)
// text character positioning (for IE9 and now Chrome)
const supportsGoodTextCharPos_ = (function () {
const svgroot = document.createElementNS(NS.SVG, 'svg');
const svgcontent = document.createElementNS(NS.SVG, 'svg');
@ -81,9 +81,14 @@ svgroot.append(svgcontent);
const text = document.createElementNS(NS.SVG, 'text');
text.textContent = 'a';
svgcontent.append(text);
const pos = text.getStartPositionOfChar(0).x;
svgroot.remove();
return (pos === 0);
try { // Chrome now fails here
const pos = text.getStartPositionOfChar(0).x;
return (pos === 0);
} catch (err) {
return false;
} finally {
svgroot.remove();
}
}());
const supportsPathBBox_ = (function () {

View File

@ -2669,7 +2669,7 @@
} catch (err) {}
return false;
}(); // text character positioning (for IE9)
}(); // text character positioning (for IE9 and now Chrome)
var supportsGoodTextCharPos_ = function () {
@ -2681,9 +2681,16 @@
var text = document.createElementNS(NS.SVG, 'text');
text.textContent = 'a';
svgcontent.append(text);
var pos = text.getStartPositionOfChar(0).x;
svgroot.remove();
return pos === 0;
try {
// Chrome now fails here
var pos = text.getStartPositionOfChar(0).x;
return pos === 0;
} catch (err) {
return false;
} finally {
svgroot.remove();
}
}();
var supportsPathBBox_ = function () {

View File

@ -50,6 +50,7 @@ console.log(`${output}\nTotal failures found: ${total}.\n`);
function reduceFalseMatches (file, res) {
switch (file) {
case 'editor/external/jamilih/jml-es.js':
case 'editor/xdomain-svgedit-config-iife.js': // Ignore
res.line = [];
break;

2328
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
{
"name": "svgedit",
"version": "3.0.0-rc.2",
"version": "3.0.0-rc.3",
"description": "Powerful SVG-Editor for your browser ",
"main": "dist/index-umd.js",
"module": "dist/index-es.js",
@ -25,6 +25,7 @@
"start": "echo \"Open file to http://localhost:8000/test/all_tests.html\" && static -p 8000",
"test-no-build": "npm run eslint && npm run build-html && npm run build-config && opn http://localhost:8000/test/all_tests.html && static -p 8000",
"test-prep": "npm run eslint && npm run build-html && npm run rollup && npm run build-config",
"ui-tests": "testcafe chrome test/ui-tests/**/*.js",
"test": "npm run test-prep && opn http://localhost:8000/test/all_tests.html && static -p 8000"
},
"repository": {
@ -56,6 +57,7 @@
"@babel/core": "^7.1.2",
"@babel/polyfill": "^7.0.0",
"@babel/preset-env": "^7.1.0",
"axe-testcafe": "^1.1.0",
"babel-plugin-transform-object-rest-spread": "^7.0.0-beta.3",
"eslint": "5.6.1",
"eslint-config-standard": "12.0.0",
@ -64,6 +66,7 @@
"eslint-plugin-promise": "4.0.1",
"eslint-plugin-qunit": "^4.0.0",
"eslint-plugin-standard": "4.0.0",
"eslint-plugin-testcafe": "^0.2.1",
"find-in-files": "^0.5.0",
"imageoptim-cli": "^2.0.3",
"jamilih": "^0.42.0",
@ -84,6 +87,7 @@
"rollup-plugin-re": "^1.0.7",
"rollup-plugin-terser": "^3.0.0",
"sinon": "^6.3.4",
"sinon-test": "^2.3.0"
"sinon-test": "^2.3.0",
"testcafe": "^0.22.0"
}
}

View File

@ -2669,7 +2669,7 @@
} catch (err) {}
return false;
}(); // text character positioning (for IE9)
}(); // text character positioning (for IE9 and now Chrome)
var supportsGoodTextCharPos_ = function () {
@ -2681,9 +2681,16 @@
var text = document.createElementNS(NS.SVG, 'text');
text.textContent = 'a';
svgcontent.append(text);
var pos = text.getStartPositionOfChar(0).x;
svgroot.remove();
return pos === 0;
try {
// Chrome now fails here
var pos = text.getStartPositionOfChar(0).x;
return pos === 0;
} catch (err) {
return false;
} finally {
svgroot.remove();
}
}();
var supportsPathBBox_ = function () {

View File

@ -0,0 +1,43 @@
// https://github.com/DevExpress/testcafe
// https://devexpress.github.io/testcafe/documentation/test-api/
// https://github.com/helen-dikareva/axe-testcafe
import axeCheck from 'axe-testcafe';
fixture`TestCafe Axe accessibility tests (Editor - no parameters)`
.page`http://localhost:8000/editor/svg-editor.html`;
test('Editor - no parameters', async t => {
await axeCheck(t); // , axeContent, axeOptions: https://github.com/dequelabs/axe-core/blob/develop/doc/API.md#api-name-axerun
});
fixture`TestCafe Axe accessibility tests (Editor - with all extensions)`
.page`http://localhost:8000/editor/svg-editor.html?extensions=ext-arrows.js,ext-closepath.js,ext-foreignobject.js,ext-helloworld.js,ext-mathjax.js,ext-php_savefile.js,ext-server_moinsave.js,ext-server_opensave.js,ext-webappfind.js,ext-xdomain-messaging.js`;
test('Editor ES - with all extensions', async t => {
await axeCheck(t); // , axeContent, axeOptions: https://github.com/dequelabs/axe-core/blob/develop/doc/API.md#api-name-axerun
});
/* eslint-disable qunit/no-commented-tests */
// Waiting for https://github.com/DevExpress/testcafe-hammerhead/issues/1725 (also https://github.com/DevExpress/testcafe/issues/2734 )
/**
fixture`TestCafe Axe accessibility tests (Editor ES - no parameters)`
.page`http://localhost:8000/editor/svg-editor-es.html`;
test('Editor ES - no parameters', async t => {
await axeCheck(t); // , axeContent, axeOptions: https://github.com/dequelabs/axe-core/blob/develop/doc/API.md#api-name-axerun
});
fixture`TestCafe Axe accessibility tests (Editor ES - with all extensions)`
.page`http://localhost:8000/editor/svg-editor-es.html?extensions=ext-arrows.js,ext-closepath.js,ext-foreignobject.js,ext-helloworld.js,ext-mathjax.js,ext-php_savefile.js,ext-server_moinsave.js,ext-server_opensave.js,ext-webappfind.js,ext-xdomain-messaging.js`;
test('Editor ES - with all extensions', async t => {
await axeCheck(t); // , axeContent, axeOptions: https://github.com/dequelabs/axe-core/blob/develop/doc/API.md#api-name-axerun
});
fixture`TestCafe Axe accessibility tests (Embedded - no parameters)`
.page`http://localhost:8000/editor/embedapi.html`;
test('Embedded - no parameters', async t => {
await axeCheck(t); // , axeContent, axeOptions: https://github.com/dequelabs/axe-core/blob/develop/doc/API.md#api-name-axerun
});
*/

22
test/ui-tests/ui.js Normal file
View File

@ -0,0 +1,22 @@
// https://github.com/DevExpress/testcafe
// https://devexpress.github.io/testcafe/documentation/test-api/
// https://github.com/helen-dikareva/axe-testcafe
import {Selector} from 'testcafe';
fixture`TestCafe UI tests`
.page`http://localhost:8000/editor/svg-editor.html`;
test('Editor - No parameters: Export button', async t => {
await t
.click('#dialog_buttons > input[type=button][value=OK]')
.click('#main_icon')
.expect(Selector('#tool_export')).ok('Has open button');
});
test('Editor - No parameters: Export button clicking', async t => {
await t
.click('#dialog_buttons > input[type=button][value=OK]')
.click('#main_icon')
.click('#tool_export')
.expect(Selector('#dialog_content select')).ok('Export dialog opens');
});