michael@0: /** michael@0: * Any copyright is dedicated to the Public Domain. michael@0: * http://creativecommons.org/publicdomain/zero/1.0/ michael@0: */ michael@0: michael@0: onmessage = function(event) { michael@0: // TEST: does console exist? michael@0: postMessage({event: 'console exists', status: !!console, last : false}); michael@0: michael@0: postMessage({event: 'trace without function', status: true, last : false}); michael@0: michael@0: for (var i = 0; i < 10; ++i) { michael@0: console.what('1', 123, 321); michael@0: } michael@0: michael@0: for (var i = 0; i < 10; ++i) { michael@0: console.log(i, i, i); michael@0: } michael@0: michael@0: function trace1() { michael@0: function trace2() { michael@0: function trace3() { michael@0: console.trace("trace " + i); michael@0: } michael@0: trace3(); michael@0: } michael@0: trace2(); michael@0: } michael@0: trace1(); michael@0: michael@0: foobar585956c = function(a) { michael@0: console.trace(); michael@0: return a+"c"; michael@0: }; michael@0: michael@0: function foobar585956b(a) { michael@0: return foobar585956c(a+"b"); michael@0: } michael@0: michael@0: function foobar585956a(omg) { michael@0: return foobar585956b(omg + "a"); michael@0: } michael@0: michael@0: function foobar646025(omg) { michael@0: console.log(omg, "o", "d"); michael@0: } michael@0: michael@0: function startTimer(timer) { michael@0: console.time(timer); michael@0: } michael@0: michael@0: function stopTimer(timer) { michael@0: console.timeEnd(timer); michael@0: } michael@0: michael@0: function testGroups() { michael@0: console.groupCollapsed("a", "group"); michael@0: console.group("b", "group"); michael@0: console.groupEnd("b", "group"); michael@0: } michael@0: michael@0: foobar585956a('omg'); michael@0: foobar646025('omg'); michael@0: testGroups(); michael@0: startTimer('foo'); michael@0: setTimeout(function() { michael@0: stopTimer('foo'); michael@0: nextSteps(event); michael@0: }, 10); michael@0: } michael@0: michael@0: function nextSteps(event) { michael@0: michael@0: function namelessTimer() { michael@0: console.time(); michael@0: console.timeEnd(); michael@0: } michael@0: michael@0: namelessTimer(); michael@0: michael@0: var str = "Test Message." michael@0: console.foobar(str); // if this throws, we don't execute following funcs michael@0: console.log(str); michael@0: console.info(str); michael@0: console.warn(str); michael@0: console.error(str); michael@0: console.exception(str); michael@0: console.assert(true, str); michael@0: console.assert(false, str); michael@0: console.profile(str); michael@0: console.profileEnd(str); michael@0: postMessage({event: '4 messages', status: true, last : false}); michael@0: michael@0: // Recursive: michael@0: if (event.data == true) { michael@0: var worker = new Worker('console_worker.js'); michael@0: worker.onmessage = function(event) { michael@0: postMessage(event.data); michael@0: } michael@0: worker.postMessage(false); michael@0: } else { michael@0: postMessage({event: 'bye bye', status: true, last : true}); michael@0: } michael@0: }