|
|
@ -7,7 +7,8 @@ define([
|
|
|
|
'/drive/tests.js',
|
|
|
|
'/drive/tests.js',
|
|
|
|
'/common/test.js',
|
|
|
|
'/common/test.js',
|
|
|
|
'/common/common-thumbnail.js',
|
|
|
|
'/common/common-thumbnail.js',
|
|
|
|
], function ($, Hyperjson, TextPatcher, Sortify, Cryptpad, Drive, Test, Thumb) {
|
|
|
|
'/common/flat-dom.js',
|
|
|
|
|
|
|
|
], function ($, Hyperjson, TextPatcher, Sortify, Cryptpad, Drive, Test, Thumb, Flat) {
|
|
|
|
window.Hyperjson = Hyperjson;
|
|
|
|
window.Hyperjson = Hyperjson;
|
|
|
|
window.TextPatcher = TextPatcher;
|
|
|
|
window.TextPatcher = TextPatcher;
|
|
|
|
window.Sortify = Sortify;
|
|
|
|
window.Sortify = Sortify;
|
|
|
@ -241,6 +242,7 @@ define([
|
|
|
|
return cb(true);
|
|
|
|
return cb(true);
|
|
|
|
}, "version 2 hash failed to parse correctly");
|
|
|
|
}, "version 2 hash failed to parse correctly");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
assert(function (cb) {
|
|
|
|
assert(function (cb) {
|
|
|
|
var getBlob = function (url, cb) {
|
|
|
|
var getBlob = function (url, cb) {
|
|
|
|
var xhr = new XMLHttpRequest();
|
|
|
|
var xhr = new XMLHttpRequest();
|
|
|
@ -266,9 +268,21 @@ define([
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
Drive.test(assert);
|
|
|
|
Drive.test(assert);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assert(function (cb) {
|
|
|
|
|
|
|
|
// extract dom elements into a flattened JSON representation
|
|
|
|
|
|
|
|
var flat = Flat.fromDOM(document.body);
|
|
|
|
|
|
|
|
// recreate a _mostly_ equivalent DOM
|
|
|
|
|
|
|
|
var dom = Flat.toDOM(flat);
|
|
|
|
|
|
|
|
// assume we don't care about comments
|
|
|
|
|
|
|
|
var bodyText = document.body.outerHTML.replace(/<!\-\-[\s\S]*?\-\->/g, '')
|
|
|
|
|
|
|
|
// check for equality
|
|
|
|
|
|
|
|
cb(dom.outerHTML === bodyText);
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
var swap = function (str, dict) {
|
|
|
|
var swap = function (str, dict) {
|
|
|
|
return str.replace(/\{\{(.*?)\}\}/g, function (all, key) {
|
|
|
|
return str.replace(/\{\{(.*?)\}\}/g, function (all, key) {
|
|
|
|
return typeof dict[key] !== 'undefined'? dict[key] : all;
|
|
|
|
return typeof dict[key] !== 'undefined'? dict[key] : all;
|
|
|
|