Fixes #33782 for 4.3.

git-svn-id: https://develop.svn.wordpress.org/branches/4.3@34029 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Andrew Ozz 2015-09-10 23:56:25 +00:00
parent 3a7c781c87
commit dcb9873834
27 changed files with 1085 additions and 588 deletions

View File

@ -381,16 +381,18 @@ tinymce.PluginManager.add('charmap', function(editor) {
});
}
editor.addCommand('mceShowCharmap', showDialog);
editor.addButton('charmap', {
icon: 'charmap',
tooltip: 'Special character',
onclick: showDialog
cmd: 'mceShowCharmap'
});
editor.addMenuItem('charmap', {
icon: 'charmap',
text: 'Special character',
onclick: showDialog,
cmd: 'mceShowCharmap',
context: 'insert'
});
});

File diff suppressed because one or more lines are too long

View File

@ -350,7 +350,8 @@ tinymce.PluginManager.add('lists', function(editor) {
}
return true;
} else {
}
if (ulParent.nodeName == 'LI') {
ul = ulParent;
newBlock = createNewTextBlock(li, 'LI');
@ -366,9 +367,6 @@ tinymce.PluginManager.add('lists', function(editor) {
return true;
}
return false;
}
function indent(li) {
var sibling, newList;

View File

@ -14,11 +14,11 @@
tinymce.PluginManager.add('media', function(editor, url) {
var urlPatterns = [
{regex: /youtu\.be\/([\w\-.]+)/, type: 'iframe', w: 425, h: 350, url: '//www.youtube.com/embed/$1'},
{regex: /youtube\.com(.+)v=([^&]+)/, type: 'iframe', w: 425, h: 350, url: '//www.youtube.com/embed/$2'},
{regex: /vimeo\.com\/([0-9]+)/, type: 'iframe', w: 425, h: 350, url: '//player.vimeo.com/video/$1?title=0&byline=0&portrait=0&color=8dc7dc'},
{regex: /vimeo\.com\/(.*)\/([0-9]+)/, type: "iframe", w: 425, h: 350, url: "//player.vimeo.com/video/$2?title=0&byline=0"},
{regex: /maps\.google\.([a-z]{2,3})\/maps\/(.+)msid=(.+)/, type: 'iframe', w: 425, h: 350, url: '//maps.google.com/maps/ms?msid=$2&output=embed"'}
{regex: /youtu\.be\/([\w\-.]+)/, type: 'iframe', w: 425, h: 350, url: '//www.youtube.com/embed/$1', allowFullscreen: true},
{regex: /youtube\.com(.+)v=([^&]+)/, type: 'iframe', w: 425, h: 350, url: '//www.youtube.com/embed/$2', allowFullscreen: true},
{regex: /vimeo\.com\/([0-9]+)/, type: 'iframe', w: 425, h: 350, url: '//player.vimeo.com/video/$1?title=0&byline=0&portrait=0&color=8dc7dc', allowfullscreen: true},
{regex: /vimeo\.com\/(.*)\/([0-9]+)/, type: "iframe", w: 425, h: 350, url: "//player.vimeo.com/video/$2?title=0&byline=0", allowfullscreen: true},
{regex: /maps\.google\.([a-z]{2,3})\/maps\/(.+)msid=(.+)/, type: 'iframe', w: 425, h: 350, url: '//maps.google.com/maps/ms?msid=$2&output=embed"', allowFullscreen: false}
];
var embedChange = (tinymce.Env.ie && tinymce.Env.ie <= 8) ? 'onChange' : 'onInput';
@ -265,6 +265,7 @@ tinymce.PluginManager.add('media', function(editor, url) {
data.source1 = url;
data.type = pattern.type;
data.allowFullscreen = pattern.allowFullscreen;
data.width = data.width || pattern.w;
data.height = data.height || pattern.h;
}
@ -288,7 +289,8 @@ tinymce.PluginManager.add('media', function(editor, url) {
});
if (data.type == "iframe") {
html += '<iframe src="' + data.source1 + '" width="' + data.width + '" height="' + data.height + '"></iframe>';
var allowFullscreen = data.allowFullscreen ? ' allowFullscreen="1"' : '';
html += '<iframe src="' + data.source1 + '" width="' + data.width + '" height="' + data.height + '"' + allowFullscreen + '></iframe>';
} else if (data.source1mime == "application/x-shockwave-flash") {
html += '<object data="' + data.source1 + '" width="' + data.width + '" height="' + data.height + '" type="application/x-shockwave-flash">';
@ -394,7 +396,7 @@ tinymce.PluginManager.add('media', function(editor, url) {
return html;
}
var writer = new tinymce.html.Writer();
var writer = new tinymce.html.Writer(), blocked;
new tinymce.html.SaxParser({
validate: false,
@ -414,6 +416,8 @@ tinymce.PluginManager.add('media', function(editor, url) {
},
start: function(name, attrs, empty) {
blocked = true;
if (name == 'script' || name == 'noscript') {
return;
}
@ -422,13 +426,18 @@ tinymce.PluginManager.add('media', function(editor, url) {
if (attrs[i].name.indexOf('on') === 0) {
return;
}
if (attrs[i].name == 'style') {
attrs[i].value = editor.dom.serializeStyle(editor.dom.parseStyle(attrs[i].value), name);
}
}
writer.start(name, attrs, empty);
blocked = false;
},
end: function(name) {
if (name == 'script' || name == 'noscript') {
if (blocked) {
return;
}
@ -779,4 +788,6 @@ tinymce.PluginManager.add('media', function(editor, url) {
context: 'insert',
prependToContext: true
});
this.showDialog = showDialog;
});

File diff suppressed because one or more lines are too long

View File

@ -63,10 +63,12 @@
}
function expose(ids) {
for (var i = 0; i < ids.length; i++) {
var target = exports;
var id = ids[i];
var fragments = id.split(/[.\/]/);
var i, target, id, fragments, privateModules;
for (i = 0; i < ids.length; i++) {
target = exports;
id = ids[i];
fragments = id.split(/[.\/]/);
for (var fi = 0; fi < fragments.length - 1; ++fi) {
if (target[fragments[fi]] === undefined) {
@ -78,6 +80,21 @@
target[fragments[fragments.length - 1]] = modules[id];
}
// Expose private modules for unit tests
if (exports.AMDLC_TESTS) {
privateModules = exports.privateModules || {};
for (id in modules) {
privateModules[id] = modules[id];
}
for (i = 0; i < ids.length; i++) {
delete privateModules[ids[i]];
}
exports.privateModules = privateModules;
}
}
// Included from: js/tinymce/plugins/paste/classes/Utils.js

File diff suppressed because one or more lines are too long

View File

@ -1 +1 @@
.mce-object{border:1px dotted #3A3A3A;background:#d5d5d5 url(img/object.gif) no-repeat center}.mce-pagebreak{cursor:default;display:block;border:0;width:100%;height:5px;border:1px dashed #666;margin-top:15px;page-break-before:always}@media print{.mce-pagebreak{border:0}}.mce-item-anchor{cursor:default;display:inline-block;-webkit-user-select:all;-webkit-user-modify:read-only;-moz-user-select:all;-moz-user-modify:read-only;user-select:all;user-modify:read-only;width:9px!important;height:9px!important;border:1px dotted #3A3A3A;background:#d5d5d5 url(img/anchor.gif) no-repeat center}.mce-nbsp,.mce-shy{background:#AAA}.mce-shy::after{content:'-'}hr{cursor:default}.mce-match-marker{background:#AAA;color:#fff}.mce-match-marker-selected{background:#39f;color:#fff}.mce-spellchecker-word{border-bottom:2px solid red;cursor:default}.mce-spellchecker-grammar{border-bottom:2px solid green;cursor:default}.mce-item-table,.mce-item-table td,.mce-item-table th,.mce-item-table caption{border:1px dashed #BBB}td.mce-item-selected,th.mce-item-selected{background-color:#39f!important}.mce-edit-focus{outline:1px dotted #333}
.mce-content-body .mce-reset{margin:0;padding:0;border:0;outline:0;vertical-align:top;background:0 0;text-decoration:none;color:#000;font-family:Arial;font-size:11px;text-shadow:none;float:none;position:static;width:auto;height:auto;white-space:nowrap;cursor:inherit;line-height:normal;font-weight:400;text-align:left;-webkit-tap-highlight-color:transparent;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;box-sizing:content-box;direction:ltr;max-width:none}.mce-object{border:1px dotted #3A3A3A;background:#d5d5d5 url(img/object.gif) no-repeat center}.mce-pagebreak{cursor:default;display:block;border:0;width:100%;height:5px;border:1px dashed #666;margin-top:15px;page-break-before:always}@media print{.mce-pagebreak{border:0}}.mce-item-anchor{cursor:default;display:inline-block;-webkit-user-select:all;-webkit-user-modify:read-only;-moz-user-select:all;-moz-user-modify:read-only;user-select:all;user-modify:read-only;width:9px!important;height:9px!important;border:1px dotted #3A3A3A;background:#d5d5d5 url(img/anchor.gif) no-repeat center}.mce-nbsp,.mce-shy{background:#AAA}.mce-shy::after{content:'-'}hr{cursor:default}.mce-match-marker{background:#AAA;color:#fff}.mce-match-marker-selected{background:#39f;color:#fff}.mce-spellchecker-word{border-bottom:2px solid red;cursor:default}.mce-spellchecker-grammar{border-bottom:2px solid green;cursor:default}.mce-item-table,.mce-item-table td,.mce-item-table th,.mce-item-table caption{border:1px dashed #BBB}td.mce-item-selected,th.mce-item-selected{background-color:#39f!important}.mce-edit-focus{outline:1px dotted #333}

View File

@ -1 +1 @@
body{background-color:#FFF;color:#000;font-family:Verdana,Arial,Helvetica,sans-serif;font-size:11px;scrollbar-3dlight-color:#F0F0EE;scrollbar-arrow-color:#676662;scrollbar-base-color:#F0F0EE;scrollbar-darkshadow-color:#DDD;scrollbar-face-color:#E0E0DD;scrollbar-highlight-color:#F0F0EE;scrollbar-shadow-color:#F0F0EE;scrollbar-track-color:#F5F5F5}td,th{font-family:Verdana,Arial,Helvetica,sans-serif;font-size:11px}.mce-object{border:1px dotted #3A3A3A;background:#d5d5d5 url(img/object.gif) no-repeat center}.mce-pagebreak{cursor:default;display:block;border:0;width:100%;height:5px;border:1px dashed #666;margin-top:15px;page-break-before:always}@media print{.mce-pagebreak{border:0}}.mce-item-anchor{cursor:default;display:inline-block;-webkit-user-select:all;-webkit-user-modify:read-only;-moz-user-select:all;-moz-user-modify:read-only;user-select:all;user-modify:read-only;width:9px!important;height:9px!important;border:1px dotted #3A3A3A;background:#d5d5d5 url(img/anchor.gif) no-repeat center}.mce-nbsp,.mce-shy{background:#AAA}.mce-shy::after{content:'-'}hr{cursor:default}.mce-match-marker{background:#AAA;color:#fff}.mce-match-marker-selected{background:#39f;color:#fff}.mce-spellchecker-word{border-bottom:2px solid red;cursor:default}.mce-spellchecker-grammar{border-bottom:2px solid green;cursor:default}.mce-item-table,.mce-item-table td,.mce-item-table th,.mce-item-table caption{border:1px dashed #BBB}td.mce-item-selected,th.mce-item-selected{background-color:#39f!important}.mce-edit-focus{outline:1px dotted #333}
body{background-color:#FFF;color:#000;font-family:Verdana,Arial,Helvetica,sans-serif;font-size:11px;scrollbar-3dlight-color:#F0F0EE;scrollbar-arrow-color:#676662;scrollbar-base-color:#F0F0EE;scrollbar-darkshadow-color:#DDD;scrollbar-face-color:#E0E0DD;scrollbar-highlight-color:#F0F0EE;scrollbar-shadow-color:#F0F0EE;scrollbar-track-color:#F5F5F5}td,th{font-family:Verdana,Arial,Helvetica,sans-serif;font-size:11px}.mce-content-body .mce-reset{margin:0;padding:0;border:0;outline:0;vertical-align:top;background:0 0;text-decoration:none;color:#000;font-family:Arial;font-size:11px;text-shadow:none;float:none;position:static;width:auto;height:auto;white-space:nowrap;cursor:inherit;line-height:normal;font-weight:400;text-align:left;-webkit-tap-highlight-color:transparent;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;box-sizing:content-box;direction:ltr;max-width:none}.mce-object{border:1px dotted #3A3A3A;background:#d5d5d5 url(img/object.gif) no-repeat center}.mce-pagebreak{cursor:default;display:block;border:0;width:100%;height:5px;border:1px dashed #666;margin-top:15px;page-break-before:always}@media print{.mce-pagebreak{border:0}}.mce-item-anchor{cursor:default;display:inline-block;-webkit-user-select:all;-webkit-user-modify:read-only;-moz-user-select:all;-moz-user-modify:read-only;user-select:all;user-modify:read-only;width:9px!important;height:9px!important;border:1px dotted #3A3A3A;background:#d5d5d5 url(img/anchor.gif) no-repeat center}.mce-nbsp,.mce-shy{background:#AAA}.mce-shy::after{content:'-'}hr{cursor:default}.mce-match-marker{background:#AAA;color:#fff}.mce-match-marker-selected{background:#39f;color:#fff}.mce-spellchecker-word{border-bottom:2px solid red;cursor:default}.mce-spellchecker-grammar{border-bottom:2px solid green;cursor:default}.mce-item-table,.mce-item-table td,.mce-item-table th,.mce-item-table caption{border:1px dashed #BBB}td.mce-item-selected,th.mce-item-selected{background-color:#39f!important}.mce-edit-focus{outline:1px dotted #333}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -28,7 +28,7 @@ tinymce.ThemeManager.add('modern', function(editor) {
var defaultToolbar = "undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | " +
"bullist numlist outdent indent | link image";
function createToolbar(items) {
function createToolbar(items, size) {
var toolbarItems = [], buttonGroup;
if (!items) {
@ -88,12 +88,7 @@ tinymce.ThemeManager.add('modern', function(editor) {
buttonGroup = null;
} else {
if (Factory.has(item)) {
item = {type: item};
if (settings.toolbar_items_size) {
item.size = settings.toolbar_items_size;
}
item = {type: item, size: size};
toolbarItems.push(item);
buttonGroup = null;
} else {
@ -112,10 +107,7 @@ tinymce.ThemeManager.add('modern', function(editor) {
}
item.type = item.type || 'button';
if (settings.toolbar_items_size) {
item.size = settings.toolbar_items_size;
}
item.size = size;
item = Factory.create(item);
buttonGroup.items.push(item);
@ -140,14 +132,15 @@ tinymce.ThemeManager.add('modern', function(editor) {
/**
* Creates the toolbars from config and returns a toolbar array.
*
* @param {String} size Optional toolbar item size.
* @return {Array} Array with toolbars.
*/
function createToolbars() {
function createToolbars(size) {
var toolbars = [];
function addToolbar(items) {
if (items) {
toolbars.push(createToolbar(items));
toolbars.push(createToolbar(items, size));
return true;
}
}
@ -670,7 +663,7 @@ tinymce.ThemeManager.add('modern', function(editor) {
border: 1,
items: [
settings.menubar === false ? null : {type: 'menubar', border: '0 0 1 0', items: createMenuButtons()},
createToolbars()
createToolbars(settings.toolbar_items_size)
]
});
@ -747,7 +740,7 @@ tinymce.ThemeManager.add('modern', function(editor) {
border: 1,
items: [
settings.menubar === false ? null : {type: 'menubar', border: '0 0 1 0', items: createMenuButtons()},
createToolbars(),
createToolbars(settings.toolbar_items_size),
{type: 'panel', name: 'iframe', layout: 'stack', classes: 'edit-area', html: '', border: '1 0 0 0'}
]
});

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -18,7 +18,7 @@ $wp_db_version = 33056;
*
* @global string $tinymce_version
*/
$tinymce_version = '4203-20150730';
$tinymce_version = '4205-20150910';
/**
* Holds the required PHP version

View File

@ -19,14 +19,19 @@
<script src="http://www.google.com/jsapi"></script>
<script>google.load("jquery", "1");</script>
<script src="js/module_loader.js"></script>
<script src="js/qunit/qunit.js"></script>
<script src="../../../build/wp-includes/js/tinymce/tinymce.min.js"></script>
<!--<script src="../js/tinymce/classes/jquery.tinymce.js"></script> -->
<script src="js/utils.js"></script>
<script src="js/init.js"></script>
<!-- tinymce.data.* -->
<script src="tinymce/data/ObservableObject.js"></script>
<!-- tinymce.file.* -->
<script src="tinymce/file/Conversions.js"></script>
<script src="tinymce/file/ImageScanner.js"></script>
<script>
var wpPlugins = 'charmap colorpicker hr lists media paste tabfocus textcolor ' +

View File

@ -0,0 +1,37 @@
(function(exports) {
exports.AMDLC_TESTS = true;
function resolve(id) {
var i, target = exports, fragments = id.split(/[.\/]/);
for (i = 0; i < fragments.length; i++) {
if (!target[fragments[i]]) {
return;
}
target = target[fragments[i]];
}
return target;
}
function require(ids, callback) {
var i, module, defs = [], privateModules = exports.privateModules || {};
for (i = 0; i < ids.length; i++) {
module = privateModules[ids[i]] || resolve(ids[i]);
if (!module) {
throw 'module definition dependecy not found: ' + ids[i];
}
defs.push(module);
}
callback.apply(null, defs);
}
exports.ModuleLoader = {
require: require
};
})(this);

View File

@ -25,6 +25,38 @@ module("tinymce.plugins.Media", {
}
});
function fillAndSubmitWindowForm(data) {
var win = Utils.getFrontmostWindow();
win.fromJSON(data);
win.find('form')[0].submit();
win.close();
}
test('Default media dialog on empty editor', function() {
editor.setContent('');
editor.plugins.media.showDialog();
deepEqual(Utils.getFrontmostWindow().toJSON(), {
constrain: true,
embed: "",
height: "",
poster: "",
source1: "",
source2: "",
width: ""
});
fillAndSubmitWindowForm({
"source1": "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
});
equal(
editor.getContent(),
'<p><iframe src=\"//www.youtube.com/embed/dQw4w9WgXcQ\" width=\"425\" height=\"350\" allowfullscreen=\"allowfullscreen\"></iframe></p>'
);
});
test("Object retain as is", function() {
editor.setContent(
'<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="425" height="355">' +
@ -162,4 +194,8 @@ test("XSS content", function() {
testXss('<video><img src="x" onload="alert(1)"></video>', '<p><video width="300" height=\"150\"></video></p>');
testXss('<video><img src="x"></video>', '<p><video width="300" height="150"><img src="x" /></video></p>');
testXss('<video><!--[if IE]><img src="x"><![endif]--></video>', '<p><video width="300" height="150"><!-- [if IE]><img src="x"><![endif]--></video></p>');
testXss('<p><p><audio><audio src=x onerror=alert(1)>', '<p><audio></audio></p>');
testXss('<p><html><audio><br /><audio src=x onerror=alert(1)></p>', '');
testXss('<p><audio><img src="javascript:alert(1)"></audio>', '<p><audio><img /></audio></p>');
testXss('<p><audio><img src="x" style="behavior:url(x); width: 1px"></audio>', '<p><audio><img src="x" style="width: 1px;" /></audio></p>');
});

View File

@ -10,6 +10,7 @@ module("tinymce.plugins.SearchReplace", {
skin: false,
indent: false,
disable_nodechange: true,
valid_elements: 'b,i',
init_instance_callback : function(ed) {
window.editor = ed;
window.setTimeout(function() {
@ -31,7 +32,7 @@ test('Find single match', function() {
});
test('Find single match in multiple elements', function() {
editor.getBody().innerHTML = 't<b>e</b><em>xt</em>';
editor.getBody().innerHTML = 't<b>e</b><i>xt</i>';
equal(1, editor.plugins.searchreplace.find('text'));
});
@ -79,6 +80,20 @@ test('Find multiple matches, move to next and replace', function() {
equal("<p>a x</p>", editor.getContent());
});
test('Find and replace fragmented match', function() {
editor.getBody().innerHTML = '<b>te<i>s</i>t</b><b>te<i>s</i>t</b>';
editor.plugins.searchreplace.find('test');
ok(editor.plugins.searchreplace.replace('abc'));
equal(editor.getContent(), "<p><b>abc</b><b>te<i>s</i>t</b></p>");
});
test('Find and replace all fragmented matches', function() {
editor.getBody().innerHTML = '<b>te<i>s</i>t</b><b>te<i>s</i>t</b>';
editor.plugins.searchreplace.find('test');
ok(!editor.plugins.searchreplace.replace('abc', true, true));
equal(editor.getContent(), "<p><b>abc</b><b>abc</b></p>");
});
test('Find multiple matches, move to next and replace backwards', function() {
editor.getBody().innerHTML = 'a a';
equal(2, editor.plugins.searchreplace.find('a'));

View File

@ -1,4 +1,7 @@
(function() {
ModuleLoader.require([
"tinymce/file/Conversions",
"tinymce/Env"
], function(Conversions, Env) {
var testBlob, testBlobDataUri;
if (!tinymce.Env.fileApi) {
@ -37,7 +40,7 @@
testBlobDataUri = canvas.toDataURL();
tinymce.file.Conversions.uriToBlob(testBlobDataUri).then(function(blob) {
Conversions.uriToBlob(testBlobDataUri).then(function(blob) {
testBlob = blob;
QUnit.start();
});
@ -61,7 +64,7 @@
var blobInfo = result[0].blobInfo;
QUnit.equal("data:" + blobInfo.blob().type + ";base64," + blobInfo.base64(), testBlobDataUri);
QUnit.equal('<p><img src="' + blobInfo.blobUri() + '" alt=""></p>', editor.getBody().innerHTML);
QUnit.equal(Utils.normalizeHtml(editor.getBody().innerHTML), '<p><img alt="" src="' + blobInfo.blobUri() + '" /></p>');
QUnit.equal('<p><img src="data:' + blobInfo.blob().type + ';base64,' + blobInfo.base64() + '" alt="" /></p>', editor.getContent());
QUnit.strictEqual(editor.editorUpload.blobCache.get(blobInfo.id()), blobInfo);
}).then(QUnit.start);
@ -94,4 +97,61 @@
});
}).then(QUnit.start);
});
})();
asyncTest('uploadConcurrentImages', function() {
var uploadCount = 0, callCount = 0;
function done() {
callCount++;
if (callCount == 2) {
QUnit.start();
equal(uploadCount, 1, 'Should only be one upload.');
}
}
editor.setContent(imageHtml(testBlobDataUri));
editor.settings.images_upload_handler = function(data, success) {
uploadCount++;
success(data.id() + '.png');
};
editor.uploadImages(done);
editor.uploadImages(done);
});
asyncTest('Don\'t upload transparent image', function() {
var uploadCount = 0;
function done() {
QUnit.start();
equal(uploadCount, 0, 'Should not upload.');
}
editor.setContent(imageHtml(Env.transparentSrc));
editor.settings.images_upload_handler = function(data, success) {
uploadCount++;
};
editor.uploadImages(done);
});
asyncTest('Don\'t upload bogus image', function() {
var uploadCount = 0;
function done() {
QUnit.start();
equal(uploadCount, 0, 'Should not upload.');
}
editor.getBody().innerHTML = '<img src="' + testBlobDataUri + '" data-mce-bogus="1">';
editor.settings.images_upload_handler = function(data, success) {
uploadCount++;
};
editor.uploadImages(done);
});
});

View File

@ -1079,4 +1079,15 @@ if (window.getSelection) {
Utils.pressEnter();
equal(editor.getContent(), '<p>\u00a0</p><p>\u00a0</p><table><tbody><tr><td>x</td></tr></tbody></table>');
});
test('Enter after span with space', function() {
editor.setContent('<p><b>abc </b></p>');
Utils.setSelection('b', 3);
Utils.pressEnter();
equal(editor.getContent(), '<p><b>abc</b></p><p>\u00a0</p>');
var rng = editor.selection.getRng(true);
equal(rng.startContainer.nodeName, 'B');
notEqual(rng.startContainer.data, ' ');
});
}

View File

@ -0,0 +1,51 @@
ModuleLoader.require(["tinymce/data/ObservableObject"], function(ObservableObject) {
module("tinymce.data.ObservableObject");
test("Constructor", function(assert) {
var obj;
obj = new ObservableObject();
assert.ok(!obj.has('a'));
obj = new ObservableObject({a: 1, b: 2});
assert.strictEqual(obj.get('a'), 1);
assert.strictEqual(obj.get('b'), 2);
});
test("set/get and observe all", function(assert) {
var obj = new ObservableObject(), events = [];
obj.on('change', function(e) {
events.push(e);
});
obj.set('a', 'a');
obj.set('a', 'a2');
obj.set('a', 'a3');
obj.set('b', 'b');
assert.strictEqual(obj.get('a'), 'a3');
equal(events[0].type, 'change');
equal(events[0].value, 'a');
equal(events[1].type, 'change');
equal(events[1].value, 'a2');
equal(events[2].type, 'change');
equal(events[2].value, 'a3');
equal(events[3].type, 'change');
equal(events[3].value, 'b');
});
test("set/get and observe specific", function(assert) {
var obj = new ObservableObject(), events = [];
obj.on('change:a', function(e) {
events.push(e);
});
obj.set('a', 'a');
obj.set('b', 'b');
equal(events[0].type, 'change');
equal(events[0].value, 'a');
equal(events.length, 1);
});
});

View File

@ -1,4 +1,4 @@
(function(Conversions) {
ModuleLoader.require(["tinymce/file/Conversions"], function(Conversions) {
module("tinymce.file.Conversions");
if (!tinymce.Env.fileApi) {
@ -14,4 +14,4 @@
QUnit.equal(dataUri, "data:text/plain;base64,SGVsbG8sIFdvcmxkIQ==");
}).then(QUnit.start);
});
})(tinymce.file.Conversions);
});

View File

@ -0,0 +1,31 @@
ModuleLoader.require([
"tinymce/file/ImageScanner",
"tinymce/file/BlobCache",
"tinymce/Env"
], function(ImageScanner, BlobCache, Env) {
if (!tinymce.Env.fileApi) {
return;
}
module("tinymce.file.ImageScanner");
var base64Src = 'data:image/gif;base64,R0lGODlhAQABAIAAAAAAAAAAACH5BAAAAAAALAAAAAABAAEAAAICTAEAOw==';
QUnit.asyncTest("findAll", function() {
var imageScanner = new ImageScanner(new BlobCache());
document.getElementById('view').innerHTML = (
'<img src="' + base64Src + '">' +
'<img src="' + Env.transparentSrc + '">' +
'<img src="' + base64Src + '" data-mce-bogus="1">' +
'<img src="' + base64Src + '" data-mce-placeholder="1">'
);
imageScanner.findAll(document.getElementById('view')).then(function(result) {
QUnit.start();
equal(result.length, 1);
equal('data:image/gif;base64,' + result[0].blobInfo.base64(), base64Src);
strictEqual(result[0].image, document.getElementById('view').firstChild);
});
});
});

View File

@ -168,7 +168,8 @@ test('getBoolAttrs', function() {
"DECLARE": {}, "COMPACT": {}, "CHECKED": {},
"controls": {}, "loop": {}, "autoplay": {}, "selected": {}, "readonly": {}, "nowrap": {},
"noshade": {}, "noresize": {}, "nohref": {}, "multiple": {}, "ismap": {}, "disabled": {}, "defer": {},
"declare": {}, "compact": {}, "checked": {}
"declare": {}, "compact": {}, "checked": {},
"allowfullscreen": {}, "mozallowfullscreen": {}, "webkitallowfullscreen": {} // WP
});
});