2014-02-10 02:11:25 +01:00
|
|
|
module("tinymce.html.Schema");
|
|
|
|
|
|
|
|
test('Valid elements global rule', function() {
|
|
|
|
expect(1);
|
|
|
|
|
|
|
|
var schema = new tinymce.html.Schema({valid_elements: '@[id|style],img[src|-style]'});
|
|
|
|
deepEqual(schema.getElementRule('img'), {"attributes": {"id": {}, "src": {}}, "attributesOrder": ["id", "src"]});
|
|
|
|
});
|
|
|
|
|
|
|
|
test('Whildcard element rule', function() {
|
2014-03-24 06:59:45 +01:00
|
|
|
var schema;
|
|
|
|
|
2014-02-10 02:11:25 +01:00
|
|
|
expect(17);
|
|
|
|
|
2014-03-24 06:59:45 +01:00
|
|
|
schema = new tinymce.html.Schema({valid_elements: '*[id|class]'});
|
2014-02-10 02:11:25 +01:00
|
|
|
deepEqual(schema.getElementRule('b').attributes, {"id": {}, "class": {} });
|
|
|
|
deepEqual(schema.getElementRule('b').attributesOrder, ["id", "class"]);
|
|
|
|
|
2014-03-24 06:59:45 +01:00
|
|
|
schema = new tinymce.html.Schema({valid_elements: 'b*[id|class]'});
|
2014-02-10 02:11:25 +01:00
|
|
|
deepEqual(schema.getElementRule('b').attributes, {"id": {}, "class": {} });
|
|
|
|
deepEqual(schema.getElementRule('b').attributesOrder, ["id", "class"]);
|
|
|
|
deepEqual(schema.getElementRule('body').attributes, {"id": {}, "class": {} });
|
|
|
|
deepEqual(schema.getElementRule('body').attributesOrder, ["id", "class"]);
|
|
|
|
equal(schema.getElementRule('img'), undefined);
|
|
|
|
|
2014-03-24 06:59:45 +01:00
|
|
|
schema = new tinymce.html.Schema({valid_elements: 'b?[id|class]'});
|
2014-02-10 02:11:25 +01:00
|
|
|
deepEqual(schema.getElementRule('b').attributes, {"id": {}, "class": {} });
|
|
|
|
deepEqual(schema.getElementRule('b').attributesOrder, ["id", "class"]);
|
|
|
|
deepEqual(schema.getElementRule('bx').attributes, {"id": {}, "class": {} });
|
|
|
|
deepEqual(schema.getElementRule('bx').attributesOrder, ["id", "class"]);
|
|
|
|
equal(schema.getElementRule('body'), undefined);
|
|
|
|
|
2014-03-24 06:59:45 +01:00
|
|
|
schema = new tinymce.html.Schema({valid_elements: 'b+[id|class]'});
|
2014-02-10 02:11:25 +01:00
|
|
|
deepEqual(schema.getElementRule('body').attributes, {"id": {}, "class": {} });
|
|
|
|
deepEqual(schema.getElementRule('body').attributesOrder, ["id", "class"]);
|
|
|
|
deepEqual(schema.getElementRule('bx').attributes, {"id": {}, "class": {} });
|
|
|
|
deepEqual(schema.getElementRule('bx').attributesOrder, ["id", "class"]);
|
|
|
|
equal(schema.getElementRule('b'), undefined);
|
|
|
|
});
|
|
|
|
|
|
|
|
test('Whildcard attribute rule', function() {
|
2014-03-24 06:59:45 +01:00
|
|
|
var schema;
|
|
|
|
|
2014-02-10 02:11:25 +01:00
|
|
|
expect(13);
|
|
|
|
|
2014-03-24 06:59:45 +01:00
|
|
|
schema = new tinymce.html.Schema({valid_elements: 'b[id|class|*]'});
|
2014-02-10 02:11:25 +01:00
|
|
|
deepEqual(schema.getElementRule('b').attributes, {"id": {}, "class": {} });
|
|
|
|
deepEqual(schema.getElementRule('b').attributesOrder, ["id", "class"]);
|
|
|
|
ok(schema.getElementRule('b').attributePatterns[0].pattern.test('x'));
|
|
|
|
|
2014-03-24 06:59:45 +01:00
|
|
|
schema = new tinymce.html.Schema({valid_elements: 'b[id|class|x?]'});
|
2014-02-10 02:11:25 +01:00
|
|
|
deepEqual(schema.getElementRule('b').attributes, {"id": {}, "class": {} });
|
|
|
|
deepEqual(schema.getElementRule('b').attributesOrder, ["id", "class"]);
|
|
|
|
ok(schema.getElementRule('b').attributePatterns[0].pattern.test('xy'));
|
|
|
|
ok(!schema.getElementRule('b').attributePatterns[0].pattern.test('xba'));
|
|
|
|
ok(!schema.getElementRule('b').attributePatterns[0].pattern.test('a'));
|
|
|
|
|
2014-03-24 06:59:45 +01:00
|
|
|
schema = new tinymce.html.Schema({valid_elements: 'b[id|class|x+]'});
|
2014-02-10 02:11:25 +01:00
|
|
|
deepEqual(schema.getElementRule('b').attributes, {"id": {}, "class": {} });
|
|
|
|
deepEqual(schema.getElementRule('b').attributesOrder, ["id", "class"]);
|
|
|
|
ok(!schema.getElementRule('b').attributePatterns[0].pattern.test('x'));
|
|
|
|
ok(schema.getElementRule('b').attributePatterns[0].pattern.test('xb'));
|
|
|
|
ok(schema.getElementRule('b').attributePatterns[0].pattern.test('xba'));
|
|
|
|
});
|
|
|
|
|
|
|
|
test('Valid attributes and attribute order', function() {
|
2014-03-24 06:59:45 +01:00
|
|
|
var schema;
|
|
|
|
|
2014-02-10 02:11:25 +01:00
|
|
|
expect(3);
|
|
|
|
|
2014-03-24 06:59:45 +01:00
|
|
|
schema = new tinymce.html.Schema({valid_elements: 'div,a[href|title],b[title]'});
|
2014-02-10 02:11:25 +01:00
|
|
|
deepEqual(schema.getElementRule('div'), {"attributes": {}, "attributesOrder": []});
|
|
|
|
deepEqual(schema.getElementRule('a'), {"attributes": {"href": {}, "title": {}}, "attributesOrder": ["href", "title"]});
|
|
|
|
deepEqual(schema.getElementRule('b'), {"attributes": {"title": {}}, "attributesOrder": ["title"]});
|
|
|
|
});
|
|
|
|
|
|
|
|
test('Required any attributes', function() {
|
2014-03-24 06:59:45 +01:00
|
|
|
var schema;
|
|
|
|
|
2014-02-10 02:11:25 +01:00
|
|
|
expect(1);
|
|
|
|
|
2014-03-24 06:59:45 +01:00
|
|
|
schema = new tinymce.html.Schema({valid_elements: 'a![id|style|href]'});
|
2014-02-10 02:11:25 +01:00
|
|
|
deepEqual(schema.getElementRule('a'), {"attributes": {"href": {}, "id": {}, "style": {}}, "attributesOrder": ["id", "style", "href"], "removeEmptyAttrs": true});
|
|
|
|
});
|
|
|
|
|
|
|
|
test('Required attributes', function() {
|
2014-03-24 06:59:45 +01:00
|
|
|
var schema;
|
|
|
|
|
2014-02-10 02:11:25 +01:00
|
|
|
expect(1);
|
|
|
|
|
2014-03-24 06:59:45 +01:00
|
|
|
schema = new tinymce.html.Schema({valid_elements: 'a[!href|!name]'});
|
2014-02-10 02:11:25 +01:00
|
|
|
deepEqual(schema.getElementRule('a'), {"attributes": {"href": {"required": true}, "name": {"required": true}}, "attributesOrder": ["href", "name"], "attributesRequired": ["href", "name"]});
|
|
|
|
});
|
|
|
|
|
|
|
|
test('Default attribute values', function() {
|
2014-03-24 06:59:45 +01:00
|
|
|
var schema;
|
|
|
|
|
2014-02-10 02:11:25 +01:00
|
|
|
expect(1);
|
|
|
|
|
2014-03-24 06:59:45 +01:00
|
|
|
schema = new tinymce.html.Schema({valid_elements: 'img[border=0]'});
|
2014-02-10 02:11:25 +01:00
|
|
|
deepEqual(schema.getElementRule('img'), {"attributes": {"border": {"defaultValue": "0"}}, "attributesOrder": ["border"], "attributesDefault": [{"name": "border", "value": "0"}]});
|
|
|
|
});
|
|
|
|
|
|
|
|
test('Forced attribute values', function() {
|
2014-03-24 06:59:45 +01:00
|
|
|
var schema;
|
|
|
|
|
2014-02-10 02:11:25 +01:00
|
|
|
expect(1);
|
|
|
|
|
2014-03-24 06:59:45 +01:00
|
|
|
schema = new tinymce.html.Schema({valid_elements: 'img[border:0]'});
|
2014-02-10 02:11:25 +01:00
|
|
|
deepEqual(schema.getElementRule('img'), {"attributes": {"border": {"forcedValue": "0"}}, "attributesOrder": ["border"], "attributesForced": [{"name": "border", "value": "0"}]});
|
|
|
|
});
|
|
|
|
|
|
|
|
test('Required attribute values', function() {
|
2014-03-24 06:59:45 +01:00
|
|
|
var schema;
|
|
|
|
|
2014-02-10 02:11:25 +01:00
|
|
|
expect(1);
|
|
|
|
|
2014-03-24 06:59:45 +01:00
|
|
|
schema = new tinymce.html.Schema({valid_elements: 'span[dir<ltr?rtl]'});
|
2014-02-10 02:11:25 +01:00
|
|
|
deepEqual(schema.getElementRule('span'), {"attributes": {"dir": {"validValues": {"rtl": {}, "ltr": {}}}}, "attributesOrder": ["dir"]});
|
|
|
|
});
|
|
|
|
|
|
|
|
test('Remove empty elements', function() {
|
2014-03-24 06:59:45 +01:00
|
|
|
var schema;
|
|
|
|
|
2014-02-10 02:11:25 +01:00
|
|
|
expect(2);
|
|
|
|
|
2014-03-24 06:59:45 +01:00
|
|
|
schema = new tinymce.html.Schema({valid_elements: '-span'});
|
2014-02-10 02:11:25 +01:00
|
|
|
deepEqual(schema.getElementRule('span'), {"attributes": {}, "attributesOrder": [], "removeEmpty": true});
|
|
|
|
|
2014-03-24 06:59:45 +01:00
|
|
|
schema = new tinymce.html.Schema({valid_elements: '#span'});
|
2014-02-10 02:11:25 +01:00
|
|
|
deepEqual(schema.getElementRule('span'), {"attributes": {}, "attributesOrder": [], "paddEmpty": true});
|
|
|
|
});
|
|
|
|
|
|
|
|
test('addValidElements', function() {
|
2014-03-24 06:59:45 +01:00
|
|
|
var schema;
|
|
|
|
|
2014-02-10 02:11:25 +01:00
|
|
|
expect(1);
|
|
|
|
|
2014-03-24 06:59:45 +01:00
|
|
|
schema = new tinymce.html.Schema({valid_elements: '@[id|style],img[src|-style]'});
|
2014-02-10 02:11:25 +01:00
|
|
|
schema.addValidElements('b[class]');
|
|
|
|
deepEqual(schema.getElementRule('b'), {"attributes": {"id": {}, "style": {}, "class": {}}, "attributesOrder": ["id", "style", "class"]});
|
|
|
|
});
|
|
|
|
|
|
|
|
test('setValidElements', function() {
|
2014-03-24 06:59:45 +01:00
|
|
|
var schema;
|
|
|
|
|
2014-02-10 02:11:25 +01:00
|
|
|
expect(3);
|
|
|
|
|
2014-03-24 06:59:45 +01:00
|
|
|
schema = new tinymce.html.Schema({valid_elements: '@[id|style],img[src|-style]'});
|
2014-02-10 02:11:25 +01:00
|
|
|
schema.setValidElements('b[class]');
|
|
|
|
equal(schema.getElementRule('img'), undefined);
|
|
|
|
deepEqual(schema.getElementRule('b'), {"attributes": {"class": {}}, "attributesOrder": ["class"]});
|
|
|
|
|
2014-03-24 06:59:45 +01:00
|
|
|
schema = new tinymce.html.Schema({valid_elements: 'img[src]'});
|
2014-02-10 02:11:25 +01:00
|
|
|
schema.setValidElements('@[id|style],img[src]');
|
|
|
|
deepEqual(schema.getElementRule('img'), {"attributes": {"id": {}, "style": {}, "src": {}}, "attributesOrder": ["id", "style", "src"]});
|
|
|
|
});
|
|
|
|
|
|
|
|
test('getBoolAttrs', function() {
|
2014-03-24 06:59:45 +01:00
|
|
|
var schema;
|
|
|
|
|
2014-02-10 02:11:25 +01:00
|
|
|
expect(1);
|
|
|
|
|
2014-03-24 06:59:45 +01:00
|
|
|
schema = new tinymce.html.Schema();
|
2015-07-22 23:11:44 +02:00
|
|
|
deepEqual(schema.getBoolAttrs(), {
|
2014-02-10 02:11:25 +01:00
|
|
|
"CONTROLS": {}, "LOOP": {}, "AUTOPLAY": {}, "SELECTED": {}, "READONLY": {}, "NOWRAP": {},
|
|
|
|
"NOSHADE": {}, "NORESIZE": {}, "NOHREF": {}, "MULTIPLE": {}, "ISMAP": {}, "DISABLED": {}, "DEFER": {},
|
|
|
|
"DECLARE": {}, "COMPACT": {}, "CHECKED": {},
|
2015-07-22 23:11:44 +02:00
|
|
|
"controls": {}, "loop": {}, "autoplay": {}, "selected": {}, "readonly": {}, "nowrap": {},
|
|
|
|
"noshade": {}, "noresize": {}, "nohref": {}, "multiple": {}, "ismap": {}, "disabled": {}, "defer": {},
|
2016-01-20 05:17:22 +01:00
|
|
|
"declare": {}, "compact": {}, "checked": {}
|
2014-02-10 02:11:25 +01:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
test('getBlockElements', function() {
|
2014-03-24 06:59:45 +01:00
|
|
|
var schema;
|
|
|
|
|
2014-02-10 02:11:25 +01:00
|
|
|
expect(1);
|
|
|
|
|
2014-03-24 06:59:45 +01:00
|
|
|
schema = new tinymce.html.Schema();
|
2014-02-10 02:11:25 +01:00
|
|
|
deepEqual(schema.getBlockElements(), {
|
2014-03-04 02:56:57 +01:00
|
|
|
ASIDE: {}, HGROUP: {}, SECTION: {}, ARTICLE: {}, FOOTER: {}, HEADER: {},
|
2016-01-20 05:17:22 +01:00
|
|
|
ISINDEX: {}, MENU: {}, NOSCRIPT: {}, FIELDSET: {}, FIGCAPTION: {}, DIR: {}, DD: {}, DT: {},
|
2014-02-10 02:11:25 +01:00
|
|
|
DL: {}, CENTER: {}, BLOCKQUOTE: {}, CAPTION: {}, UL: {}, OL: {}, LI: {},
|
|
|
|
TD: {}, TR: {}, TH: {}, TFOOT: {}, THEAD: {}, TBODY: {}, TABLE: {}, FORM: {},
|
|
|
|
PRE: {}, ADDRESS: {}, DIV: {}, P: {}, HR: {}, H6: {}, H5: {}, H4: {}, H3: {},
|
|
|
|
H2: {}, H1: {}, NAV: {}, FIGURE: {}, DATALIST: {}, OPTGROUP: {}, OPTION: {}, SELECT: {},
|
2014-03-04 02:56:57 +01:00
|
|
|
aside: {}, hgroup: {}, section: {}, article: {}, footer: {}, header: {},
|
2014-02-10 02:11:25 +01:00
|
|
|
isindex: {}, menu: {}, noscript: {}, fieldset: {}, dir: {}, dd: {}, dt: {}, dl: {}, center: {},
|
|
|
|
blockquote: {}, caption: {}, ul: {}, ol: {}, li: {}, td: {}, tr: {}, th: {}, tfoot: {}, thead: {},
|
|
|
|
tbody: {}, table: {}, form: {}, pre: {}, address: {}, div: {}, p: {}, hr: {}, h6: {},
|
2016-01-20 05:17:22 +01:00
|
|
|
h5: {}, h4: {}, h3: {}, h2: {}, h1: {}, nav: {}, figure: {}, figcaption: {}, datalist: {}, optgroup: {},
|
2014-02-10 02:11:25 +01:00
|
|
|
option: {}, select: {}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
test('getShortEndedElements', function() {
|
2014-03-24 06:59:45 +01:00
|
|
|
var schema;
|
|
|
|
|
2014-02-10 02:11:25 +01:00
|
|
|
expect(1);
|
|
|
|
|
2014-03-24 06:59:45 +01:00
|
|
|
schema = new tinymce.html.Schema();
|
2014-02-10 02:11:25 +01:00
|
|
|
deepEqual(schema.getShortEndedElements(), {
|
|
|
|
"EMBED": {}, "PARAM": {}, "META": {}, "LINK": {}, "ISINDEX": {},
|
|
|
|
"INPUT": {}, "IMG": {}, "HR": {}, "FRAME": {}, "COL": {}, "BR": {},
|
|
|
|
"BASEFONT": {}, "BASE": {}, "AREA": {}, "SOURCE" : {}, "WBR" : {}, "TRACK" : {},
|
|
|
|
"embed": {}, "param": {}, "meta": {}, "link": {}, "isindex": {},
|
|
|
|
"input": {}, "img": {}, "hr": {}, "frame": {}, "col": {}, "br": {},
|
|
|
|
"basefont": {}, "base": {}, "area": {}, "source" : {}, "wbr" : {}, "track" : {}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
test('getNonEmptyElements', function() {
|
2014-03-24 06:59:45 +01:00
|
|
|
var schema;
|
|
|
|
|
2014-02-10 02:11:25 +01:00
|
|
|
expect(1);
|
|
|
|
|
2014-03-24 06:59:45 +01:00
|
|
|
schema = new tinymce.html.Schema();
|
2014-02-10 02:11:25 +01:00
|
|
|
deepEqual(schema.getNonEmptyElements(), {
|
|
|
|
"EMBED": {}, "PARAM": {}, "META": {}, "LINK": {}, "ISINDEX": {},
|
|
|
|
"INPUT": {}, "IMG": {}, "HR": {}, "FRAME": {}, "COL": {}, "BR": {},
|
|
|
|
"BASEFONT": {}, "BASE": {}, "AREA": {}, "SOURCE" : {},
|
|
|
|
"TD": {}, "TH": {}, "IFRAME": {}, "VIDEO": {}, "AUDIO": {}, "OBJECT": {}, "WBR": {}, "TRACK" : {}, "SCRIPT" : {},
|
|
|
|
"embed": {}, "param": {}, "meta": {}, "link": {}, "isindex": {},
|
|
|
|
"input": {}, "img": {}, "hr": {}, "frame": {}, "col": {}, "br": {},
|
|
|
|
"basefont": {}, "base": {}, "area": {}, "source" : {},
|
2014-07-17 02:58:41 +02:00
|
|
|
"td": {}, "th": {}, "iframe": {}, "video": {}, "audio": {}, "object": {}, "wbr" : {}, "track" : {}, "script" : {}
|
2014-02-10 02:11:25 +01:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
test('getWhiteSpaceElements', function() {
|
2014-03-24 06:59:45 +01:00
|
|
|
var schema;
|
|
|
|
|
2014-02-10 02:11:25 +01:00
|
|
|
expect(1);
|
|
|
|
|
2014-03-24 06:59:45 +01:00
|
|
|
schema = new tinymce.html.Schema();
|
2014-02-10 02:11:25 +01:00
|
|
|
deepEqual(schema.getWhiteSpaceElements(), {
|
|
|
|
"IFRAME": {}, "NOSCRIPT": {}, "OBJECT": {}, "PRE": {},
|
|
|
|
"SCRIPT": {}, "STYLE": {}, "TEXTAREA": {}, "VIDEO": {}, "AUDIO": {},
|
|
|
|
"iframe": {}, "noscript": {}, "object": {}, "pre": {},
|
|
|
|
"script": {}, "style": {}, "textarea": {}, "video": {}, "audio": {}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
test('getTextBlockElements', function() {
|
2014-03-24 06:59:45 +01:00
|
|
|
var schema;
|
|
|
|
|
2014-02-10 02:11:25 +01:00
|
|
|
expect(1);
|
|
|
|
|
2014-03-24 06:59:45 +01:00
|
|
|
schema = new tinymce.html.Schema();
|
2014-02-10 02:11:25 +01:00
|
|
|
deepEqual(schema.getTextBlockElements(), {
|
|
|
|
"ADDRESS": {}, "ARTICLE": {}, "ASIDE": {}, "BLOCKQUOTE": {}, "CENTER": {}, "DIR": {}, "DIV": {}, "FIELDSET": {}, "FIGURE": {}, "FOOTER": {}, "FORM": {},
|
|
|
|
"H1": {}, "H2": {}, "H3": {}, "H4": {}, "H5": {}, "H6": {}, "HEADER": {}, "HGROUP": {}, "NAV": {}, "P": {}, "PRE": {}, "SECTION": {},
|
|
|
|
"address": {}, "article": {}, "aside": {}, "blockquote": {}, "center": {}, "dir": {}, "div": {}, "fieldset": {}, "figure": {}, "footer": {}, "form": {},
|
|
|
|
"h1": {}, "h2": {}, "h3": {}, "h4": {}, "h5": {}, "h6": {}, "header": {}, "hgroup": {}, "nav": {}, "p": {}, "pre": {}, "section": {}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2014-06-18 01:49:00 +02:00
|
|
|
test('getTextInlineElements', function() {
|
|
|
|
var schema;
|
|
|
|
|
|
|
|
expect(1);
|
|
|
|
|
|
|
|
schema = new tinymce.html.Schema();
|
|
|
|
deepEqual(schema.getTextInlineElements(), {
|
|
|
|
"B": {}, "CITE": {}, "CODE": {}, "DFN": {}, "EM": {}, "FONT": {}, "I": {}, "MARK": {}, "Q": {},
|
|
|
|
"SAMP": {}, "SPAN": {}, "STRIKE": {}, "STRONG": {}, "SUB": {}, "SUP": {}, "U": {}, "VAR": {},
|
|
|
|
"b": {}, "cite": {}, "code": {}, "dfn": {}, "em": {}, "font": {}, "i": {}, "mark": {}, "q": {},
|
|
|
|
"samp": {}, "span": {}, "strike": {}, "strong": {}, "sub": {}, "sup": {}, "u": {}, "var": {}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2014-02-10 02:11:25 +01:00
|
|
|
test('isValidChild', function() {
|
2014-03-24 06:59:45 +01:00
|
|
|
var schema;
|
|
|
|
|
2014-02-10 02:11:25 +01:00
|
|
|
expect(4);
|
|
|
|
|
2014-03-24 06:59:45 +01:00
|
|
|
schema = new tinymce.html.Schema();
|
2014-02-10 02:11:25 +01:00
|
|
|
ok(schema.isValidChild('body', 'p'));
|
|
|
|
ok(schema.isValidChild('p', 'img'));
|
|
|
|
ok(!schema.isValidChild('body', 'body'));
|
|
|
|
ok(!schema.isValidChild('p', 'body'));
|
|
|
|
});
|
|
|
|
|
|
|
|
test('getElementRule', function() {
|
2014-03-24 06:59:45 +01:00
|
|
|
var schema;
|
|
|
|
|
2014-02-10 02:11:25 +01:00
|
|
|
expect(3);
|
|
|
|
|
2014-03-24 06:59:45 +01:00
|
|
|
schema = new tinymce.html.Schema();
|
2014-02-10 02:11:25 +01:00
|
|
|
ok(schema.getElementRule('b'));
|
|
|
|
ok(!schema.getElementRule('bx'));
|
|
|
|
ok(!schema.getElementRule(null));
|
|
|
|
});
|
|
|
|
|
|
|
|
test('addCustomElements', function() {
|
2014-03-24 06:59:45 +01:00
|
|
|
var schema;
|
|
|
|
|
2014-02-10 02:11:25 +01:00
|
|
|
expect(5);
|
|
|
|
|
2014-03-24 06:59:45 +01:00
|
|
|
schema = new tinymce.html.Schema({valid_elements:'inline,block'});
|
2014-02-10 02:11:25 +01:00
|
|
|
schema.addCustomElements('~inline,block');
|
|
|
|
ok(schema.getElementRule('inline'));
|
|
|
|
ok(schema.getElementRule('block'));
|
|
|
|
ok(schema.isValidChild('body', 'block'));
|
|
|
|
ok(schema.isValidChild('block', 'inline'));
|
|
|
|
ok(schema.isValidChild('p', 'inline'));
|
|
|
|
});
|
|
|
|
|
|
|
|
test('addValidChildren', function() {
|
2014-03-24 06:59:45 +01:00
|
|
|
var schema;
|
|
|
|
|
2014-02-10 02:11:25 +01:00
|
|
|
expect(7);
|
|
|
|
|
2014-03-24 06:59:45 +01:00
|
|
|
schema = new tinymce.html.Schema();
|
2014-02-10 02:11:25 +01:00
|
|
|
ok(schema.isValidChild('body', 'p'));
|
|
|
|
ok(!schema.isValidChild('body', 'body'));
|
|
|
|
ok(!schema.isValidChild('body', 'html'));
|
|
|
|
schema.addValidChildren('+body[body|html]');
|
|
|
|
ok(schema.isValidChild('body', 'body'));
|
|
|
|
ok(schema.isValidChild('body', 'html'));
|
|
|
|
|
2014-03-24 06:59:45 +01:00
|
|
|
schema = new tinymce.html.Schema();
|
2014-02-10 02:11:25 +01:00
|
|
|
ok(schema.isValidChild('body', 'p'));
|
|
|
|
schema.addValidChildren('-body[p]');
|
|
|
|
ok(!schema.isValidChild('body', 'p'));
|
|
|
|
});
|
|
|
|
|
|
|
|
test('addCustomElements/getCustomElements', function() {
|
2014-03-24 06:59:45 +01:00
|
|
|
var schema;
|
|
|
|
|
2014-02-10 02:11:25 +01:00
|
|
|
expect(4);
|
|
|
|
|
2014-03-24 06:59:45 +01:00
|
|
|
schema = new tinymce.html.Schema();
|
2014-02-10 02:11:25 +01:00
|
|
|
schema.addCustomElements('~inline,block');
|
2014-03-24 06:59:45 +01:00
|
|
|
ok(schema.getBlockElements().block);
|
|
|
|
ok(!schema.getBlockElements().inline);
|
|
|
|
ok(schema.getCustomElements().inline);
|
|
|
|
ok(schema.getCustomElements().block);
|
2014-02-10 02:11:25 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
test('whitespaceElements', function() {
|
2014-03-24 06:59:45 +01:00
|
|
|
var schema;
|
|
|
|
|
2014-02-10 02:11:25 +01:00
|
|
|
expect(3);
|
|
|
|
|
2014-03-24 06:59:45 +01:00
|
|
|
schema = new tinymce.html.Schema({whitespace_elements : 'pre,p'});
|
|
|
|
ok(schema.getWhiteSpaceElements().pre);
|
|
|
|
ok(!schema.getWhiteSpaceElements().span);
|
2014-02-10 02:11:25 +01:00
|
|
|
|
2014-03-24 06:59:45 +01:00
|
|
|
schema = new tinymce.html.Schema({whitespace_elements : 'code'});
|
|
|
|
ok(schema.getWhiteSpaceElements().code);
|
2014-02-10 02:11:25 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
test('selfClosingElements', function() {
|
2014-03-24 06:59:45 +01:00
|
|
|
var schema;
|
|
|
|
|
2014-02-10 02:11:25 +01:00
|
|
|
expect(3);
|
|
|
|
|
2014-03-24 06:59:45 +01:00
|
|
|
schema = new tinymce.html.Schema({self_closing_elements : 'pre,p'});
|
|
|
|
ok(schema.getSelfClosingElements().pre);
|
|
|
|
ok(schema.getSelfClosingElements().p);
|
|
|
|
ok(!schema.getSelfClosingElements().li);
|
2014-02-10 02:11:25 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
test('shortEndedElements', function() {
|
2014-03-24 06:59:45 +01:00
|
|
|
var schema;
|
|
|
|
|
2014-02-10 02:11:25 +01:00
|
|
|
expect(3);
|
|
|
|
|
2014-03-24 06:59:45 +01:00
|
|
|
schema = new tinymce.html.Schema({short_ended_elements : 'pre,p'});
|
|
|
|
ok(schema.getShortEndedElements().pre);
|
|
|
|
ok(schema.getShortEndedElements().p);
|
|
|
|
ok(!schema.getShortEndedElements().img);
|
2014-02-10 02:11:25 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
test('booleanAttributes', function() {
|
2014-03-24 06:59:45 +01:00
|
|
|
var schema;
|
|
|
|
|
2014-02-10 02:11:25 +01:00
|
|
|
expect(3);
|
|
|
|
|
2014-03-24 06:59:45 +01:00
|
|
|
schema = new tinymce.html.Schema({boolean_attributes : 'href,alt'});
|
|
|
|
ok(schema.getBoolAttrs().href);
|
|
|
|
ok(schema.getBoolAttrs().alt);
|
|
|
|
ok(!schema.getBoolAttrs().checked);
|
2014-02-10 02:11:25 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
test('nonEmptyElements', function() {
|
2014-03-24 06:59:45 +01:00
|
|
|
var schema;
|
|
|
|
|
2014-02-10 02:11:25 +01:00
|
|
|
expect(3);
|
|
|
|
|
2014-03-24 06:59:45 +01:00
|
|
|
schema = new tinymce.html.Schema({non_empty_elements : 'pre,p'});
|
|
|
|
ok(schema.getNonEmptyElements().pre);
|
|
|
|
ok(schema.getNonEmptyElements().p);
|
|
|
|
ok(!schema.getNonEmptyElements().img);
|
2014-02-10 02:11:25 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
test('blockElements', function() {
|
2014-03-24 06:59:45 +01:00
|
|
|
var schema;
|
|
|
|
|
2014-02-10 02:11:25 +01:00
|
|
|
expect(3);
|
|
|
|
|
2014-03-24 06:59:45 +01:00
|
|
|
schema = new tinymce.html.Schema({block_elements : 'pre,p'});
|
|
|
|
ok(schema.getBlockElements().pre);
|
|
|
|
ok(schema.getBlockElements().p);
|
|
|
|
ok(!schema.getBlockElements().h1);
|
2014-02-10 02:11:25 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
test('isValid', function() {
|
2014-03-24 06:59:45 +01:00
|
|
|
var schema;
|
|
|
|
|
|
|
|
schema = new tinymce.html.Schema({valid_elements : 'a[href],i[*]'});
|
2014-02-10 02:11:25 +01:00
|
|
|
|
|
|
|
ok(schema.isValid('a'));
|
|
|
|
ok(schema.isValid('a', 'href'));
|
|
|
|
ok(!schema.isValid('b'));
|
|
|
|
ok(!schema.isValid('b', 'href'));
|
|
|
|
ok(!schema.isValid('a', 'id'));
|
|
|
|
ok(schema.isValid('i'));
|
|
|
|
ok(schema.isValid('i', 'id'));
|
|
|
|
});
|
2014-03-24 06:59:45 +01:00
|
|
|
|
2014-06-18 01:49:00 +02:00
|
|
|
test('validStyles', function() {
|
|
|
|
var schema;
|
|
|
|
|
|
|
|
schema = new tinymce.html.Schema({valid_styles: 'color,font-size'});
|
|
|
|
deepEqual(schema.getValidStyles(), {
|
|
|
|
"*": [
|
|
|
|
"color",
|
|
|
|
"font-size"
|
|
|
|
]
|
|
|
|
});
|
|
|
|
|
|
|
|
schema = new tinymce.html.Schema({valid_styles: 'color font-size'});
|
|
|
|
deepEqual(schema.getValidStyles(), {
|
|
|
|
"*": [
|
|
|
|
"color",
|
|
|
|
"font-size"
|
|
|
|
]
|
|
|
|
});
|
|
|
|
|
|
|
|
schema = new tinymce.html.Schema({
|
|
|
|
valid_styles: {
|
|
|
|
'*': 'color font-size',
|
|
|
|
'a': 'background font-family'
|
|
|
|
}
|
|
|
|
});
|
|
|
|
deepEqual(schema.getValidStyles(), {
|
|
|
|
"*": [
|
|
|
|
"color",
|
|
|
|
"font-size"
|
|
|
|
],
|
|
|
|
|
|
|
|
"a": [
|
|
|
|
"background",
|
|
|
|
"font-family"
|
2015-03-10 20:19:56 +01:00
|
|
|
],
|
|
|
|
|
|
|
|
"A": [
|
|
|
|
"background",
|
|
|
|
"font-family"
|
2014-06-18 01:49:00 +02:00
|
|
|
]
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
test('invalidStyles', function() {
|
|
|
|
var schema;
|
|
|
|
|
|
|
|
schema = new tinymce.html.Schema({invalid_styles: 'color,font-size'});
|
|
|
|
deepEqual(schema.getInvalidStyles(), {
|
|
|
|
'*': {
|
|
|
|
'color': {},
|
|
|
|
'font-size': {}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
schema = new tinymce.html.Schema({invalid_styles: 'color font-size'});
|
|
|
|
deepEqual(schema.getInvalidStyles(), {
|
|
|
|
'*': {
|
|
|
|
'color': {},
|
|
|
|
'font-size': {}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
schema = new tinymce.html.Schema({
|
|
|
|
invalid_styles: {
|
|
|
|
'*': 'color font-size',
|
|
|
|
'a': 'background font-family'
|
|
|
|
}
|
|
|
|
});
|
|
|
|
deepEqual(schema.getInvalidStyles(), {
|
|
|
|
'*': {
|
|
|
|
'color': {},
|
|
|
|
'font-size': {}
|
|
|
|
},
|
|
|
|
|
|
|
|
'a': {
|
|
|
|
'background': {},
|
|
|
|
'font-family': {}
|
2015-03-10 20:19:56 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
'A': {
|
|
|
|
'background': {},
|
|
|
|
'font-family': {}
|
2014-06-18 01:49:00 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
test('validClasses', function() {
|
|
|
|
var schema;
|
|
|
|
|
|
|
|
schema = new tinymce.html.Schema({valid_classes: 'classA,classB'});
|
|
|
|
deepEqual(schema.getValidClasses(), {
|
|
|
|
'*': {
|
|
|
|
'classA': {},
|
|
|
|
'classB': {}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
schema = new tinymce.html.Schema({valid_classes: 'classA classB'});
|
|
|
|
deepEqual(schema.getValidClasses(), {
|
|
|
|
'*': {
|
|
|
|
'classA': {},
|
|
|
|
'classB': {}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
schema = new tinymce.html.Schema({
|
|
|
|
valid_classes: {
|
|
|
|
'*': 'classA classB',
|
|
|
|
'a': 'classC classD'
|
|
|
|
}
|
|
|
|
});
|
|
|
|
deepEqual(schema.getValidClasses(), {
|
|
|
|
'*': {
|
|
|
|
'classA': {},
|
|
|
|
'classB': {}
|
|
|
|
},
|
|
|
|
|
|
|
|
'a': {
|
|
|
|
'classC': {},
|
|
|
|
'classD': {}
|
2015-03-10 20:19:56 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
'A': {
|
|
|
|
'classC': {},
|
|
|
|
'classD': {}
|
2014-06-18 01:49:00 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|