forked from farnoy/frozen-moment
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.html
36 lines (35 loc) · 925 Bytes
/
test.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<!DOCTYPE html>
<script src="node_modules/moment/moment.js"></script>
<script>
function require() {
return moment;
}
</script>
<script src="frozen-moment.js"></script>
<script>
function printToDOM(/* ...arguments */) {
var str = '';
for (var i = 0; i < arguments.length; i++) {
str += ' ' + arguments[i];
}
document.body.innerHTML = document.body.innerHTML + '<p>' + str + '</p>';
}
function wrapConsole(methodName) {
var oldConsole = console[methodName];
console[methodName] = function (firstArgument) {
if (oldConsole && oldConsole.apply) {
oldConsole.apply(this, arguments);
}
printToDOM.apply(this, arguments);
};
}
wrapConsole('error');
wrapConsole('log');
window.onerror = function (err) {
printToDOM('test failed, see console for details');
};
</script>
<body>
<p>Running tests...</p>
<script src="test.js"></script>
</body>