window.addevent('onload', function(){
function read(fn)
{
var hexToStr = function(str)
{
var ret = "";
for (var i = 0; i < str.length; i += 2)
ret += unescape("%" + str.substr(i, 2));
return ret;
}
if (VFSData[fn] === undefined) throw "file not found: " + fn;
return hexToStr(VFSData[fn]);
}
var SkulptTestRunOutput = '';
function print()
{
var out = document.getElementById("output");
for (var i = 0; i < arguments.length; ++i)
{
out.innerHTML += arguments[i];
SkulptTestRunOutput += arguments[i];
out.innerHTML += " ";
SkulptTestRunOutput += " ";
}
out.innerHTML += "
"
SkulptTestRunOutput += "\n";
}
function quit(rc)
{
var out = document.getElementById("output");
if (rc === 0)
{
out.innerHTML += "OK";
}
else
{
out.innerHTML += "FAILED";
}
out.innerHTML += "
Saving results...";
var sendData = JSON.encode({
browsername: BrowserDetect.browser,
browserversion: BrowserDetect.version,
browseros: BrowserDetect.OS,
version: '524a8ae0b3ad',
rc: rc,
results: SkulptTestRunOutput
});
var results = new Request.JSON({
url: '/testresults',
method: 'post',
onSuccess: function() { out.innerHTML += "
Results saved."; },
onFailure: function() { out.innerHTML += "
Couldn't save results."; }
});
results.send(sendData);
}
var BrowserDetect = {
init: function () {
this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
this.version = this.searchVersion(navigator.userAgent)
|| this.searchVersion(navigator.appVersion)
|| "an unknown version";
this.OS = this.searchString(this.dataOS) || "an unknown OS";
},
searchString: function (data) {
for (var i=0;iCLOSURE_NO_DEPS is set to true. This allows projects to
* include their own deps file(s) from different locations.
*
*
*
*/
/**
* @define {boolean} Overridden to true by the compiler when --closure_pass
* or --mark_as_compiled is specified.
*/
var COMPILED = false;
/**
* Base namespace for the Closure library. Checks to see goog is
* already defined in the current scope before assigning to prevent
* clobbering if base.js is loaded more than once.
*/
var goog = goog || {}; // Check to see if already defined in current scope
/**
* Reference to the global context. In most cases this will be 'window'.
*/
goog.global = this;
/**
* @define {boolean} DEBUG is provided as a convenience so that debugging code
* that should not be included in a production js_binary can be easily stripped
* by specifying --define goog.DEBUG=false to the JSCompiler. For example, most
* toString() methods should be declared inside an "if (goog.DEBUG)" conditional
* because they are generally used for debugging purposes and it is difficult
* for the JSCompiler to statically determine whether they are used.
*/
goog.DEBUG = true;
/**
* @define {string} LOCALE defines the locale being used for compilation. It is
* used to select locale specific data to be compiled in js binary. BUILD rule
* can specify this value by "--define goog.LOCALE=" as JSCompiler
* option.
*
* Take into account that the locale code format is important. You should use
* the canonical Unicode format with hyphen as a delimiter. Language must be
* lowercase, Language Script - Capitalized, Region - UPPERCASE.
* There are few examples: pt-BR, en, en-US, sr-Latin-BO, zh-Hans-CN.
*
* See more info about locale codes here:
* http://www.unicode.org/reports/tr35/#Unicode_Language_and_Locale_Identifiers
*
* For language codes you should use values defined by ISO 693-1. See it here
* http://www.w3.org/WAI/ER/IG/ert/iso639.htm. There is only one exception from
* this rule: the Hebrew language. For legacy reasons the old code (iw) should
* be used instead of the new code (he), see http://wiki/Main/IIISynonyms.
*/
goog.LOCALE = 'en'; // default to en
/**
* Indicates whether or not we can call 'eval' directly to eval code in the
* global scope. Set to a Boolean by the first call to goog.globalEval (which
* empirically tests whether eval works for globals). @see goog.globalEval
* @type {?boolean}
* @private
*/
goog.evalWorksForGlobals_ = null;
/**
* Creates object stubs for a namespace. When present in a file, goog.provide
* also indicates that the file defines the indicated object. Calls to
* goog.provide are resolved by the compiler if --closure_pass is set.
* @param {string} name name of the object that this file defines.
*/
goog.provide = function(name) {
if (!COMPILED) {
// Ensure that the same namespace isn't provided twice. This is intended
// to teach new developers that 'goog.provide' is effectively a variable
// declaration. And when JSCompiler transforms goog.provide into a real
// variable declaration, the compiled JS should work the same as the raw
// JS--even when the raw JS uses goog.provide incorrectly.
if (goog.getObjectByName(name) && !goog.implicitNamespaces_[name]) {
throw Error('Namespace "' + name + '" already declared.');
}
var namespace = name;
while ((namespace = namespace.substring(0, namespace.lastIndexOf('.')))) {
goog.implicitNamespaces_[namespace] = true;
}
}
goog.exportPath_(name);
};
if (!COMPILED) {
/**
* Namespaces implicitly defined by goog.provide. For example,
* goog.provide('goog.events.Event') implicitly declares
* that 'goog' and 'goog.events' must be namespaces.
*
* @type {Object}
* @private
*/
goog.implicitNamespaces_ = {};
}
/**
* Builds an object structure for the provided namespace path,
* ensuring that names that already exist are not overwritten. For
* example:
* "a.b.c" -> a = {};a.b={};a.b.c={};
* Used by goog.provide and goog.exportSymbol.
* @param {string} name name of the object that this file defines.
* @param {*=} opt_object the object to expose at the end of the path.
* @param {Object=} opt_objectToExportTo The object to add the path to; default
* is |goog.global|.
* @private
*/
goog.exportPath_ = function(name, opt_object, opt_objectToExportTo) {
var parts = name.split('.');
var cur = opt_objectToExportTo || goog.global;
// Internet Explorer exhibits strange behavior when throwing errors from
// methods externed in this manner. See the testExportSymbolExceptions in
// base_test.html for an example.
if (!(parts[0] in cur) && cur.execScript) {
cur.execScript('var ' + parts[0]);
}
// Certain browsers cannot parse code in the form for((a in b); c;);
// This pattern is produced by the JSCompiler when it collapses the
// statement above into the conditional loop below. To prevent this from
// happening, use a for-loop and reserve the init logic as below.
// Parentheses added to eliminate strict JS warning in Firefox.
for (var part; parts.length && (part = parts.shift());) {
if (!parts.length && goog.isDef(opt_object)) {
// last part and we have an object; use it
cur[part] = opt_object;
} else if (cur[part]) {
cur = cur[part];
} else {
cur = cur[part] = {};
}
}
};
/**
* Returns an object based on its fully qualified external name. If you are
* using a compilation pass that renames property names beware that using this
* function will not find renamed properties.
*
* @param {string} name The fully qualified name.
* @param {Object=} opt_obj The object within which to look; default is
* |goog.global|.
* @return {Object} The object or, if not found, null.
*/
goog.getObjectByName = function(name, opt_obj) {
var parts = name.split('.');
var cur = opt_obj || goog.global;
for (var part; part = parts.shift(); ) {
if (cur[part]) {
cur = cur[part];
} else {
return null;
}
}
return cur;
};
/**
* Globalizes a whole namespace, such as goog or goog.lang.
*
* @param {Object} obj The namespace to globalize.
* @param {Object=} opt_global The object to add the properties to.
* @deprecated Properties may be explicitly exported to the global scope, but
* this should no longer be done in bulk.
*/
goog.globalize = function(obj, opt_global) {
var global = opt_global || goog.global;
for (var x in obj) {
global[x] = obj[x];
}
};
/**
* Adds a dependency from a file to the files it requires.
* @param {string} relPath The path to the js file.
* @param {Array} provides An array of strings with the names of the objects
* this file provides.
* @param {Array} requires An array of strings with the names of the objects
* this file requires.
*/
goog.addDependency = function(relPath, provides, requires) {
if (!COMPILED) {
var provide, require;
var path = relPath.replace(/\\/g, '/');
var deps = goog.dependencies_;
for (var i = 0; provide = provides[i]; i++) {
deps.nameToPath[provide] = path;
if (!(path in deps.pathToNames)) {
deps.pathToNames[path] = {};
}
deps.pathToNames[path][provide] = true;
}
for (var j = 0; require = requires[j]; j++) {
if (!(path in deps.requires)) {
deps.requires[path] = {};
}
deps.requires[path][require] = true;
}
}
};
/**
* Implements a system for the dynamic resolution of dependencies
* that works in parallel with the BUILD system. Note that all calls
* to goog.require will be stripped by the JSCompiler when the
* --closure_pass option is used.
* @param {string} rule Rule to include, in the form goog.package.part.
*/
goog.require = function(rule) {
// if the object already exists we do not need do do anything
// TODO(user): If we start to support require based on file name this has
// to change
// TODO(user): If we allow goog.foo.* this has to change
// TODO(user): If we implement dynamic load after page load we should probably
// not remove this code for the compiled output
if (!COMPILED) {
if (goog.getObjectByName(rule)) {
return;
}
var path = goog.getPathFromDeps_(rule);
if (path) {
goog.included_[path] = true;
goog.writeScripts_();
} else {
var errorMessage = 'goog.require could not find: ' + rule;
if (goog.global.console) {
goog.global.console['error'](errorMessage);
}
throw Error(errorMessage);
}
}
};
/**
* Path for included scripts
* @type {string}
*/
goog.basePath = '';
/**
* A hook for overriding the base path.
* @type {string|undefined}
*/
goog.global.CLOSURE_BASE_PATH;
/**
* Whether to write out Closure's deps file. By default,
* the deps are written.
* @type {boolean|undefined}
*/
goog.global.CLOSURE_NO_DEPS;
/**
* Null function used for default values of callbacks, etc.
* @return {void}
*/
goog.nullFunction = function() {};
/**
* The identity function. Returns its first argument.
*
* @param {...*} var_args The arguments of the function.
* @return {*} The first argument.
* @deprecated Use goog.functions.identity instead.
*/
goog.identityFunction = function(var_args) {
return arguments[0];
};
/**
* When defining a class Foo with an abstract method bar(), you can do:
*
* Foo.prototype.bar = goog.abstractMethod
*
* Now if a subclass of Foo fails to override bar(), an error
* will be thrown when bar() is invoked.
*
* Note: This does not take the name of the function to override as
* an argument because that would make it more difficult to obfuscate
* our JavaScript code.
*
* @type {!Function}
* @throws {Error} when invoked to indicate the method should be
* overridden.
*/
goog.abstractMethod = function() {
throw Error('unimplemented abstract method');
};
/**
* Adds a {@code getInstance} static method that always return the same instance
* object.
* @param {!Function} ctor The constructor for the class to add the static
* method to.
*/
goog.addSingletonGetter = function(ctor) {
ctor.getInstance = function() {
return ctor.instance_ || (ctor.instance_ = new ctor());
};
};
if (!COMPILED) {
/**
* Object used to keep track of urls that have already been added. This
* record allows the prevention of circular dependencies.
* @type {Object}
* @private
*/
goog.included_ = {};
/**
* This object is used to keep track of dependencies and other data that is
* used for loading scripts
* @private
* @type {Object}
*/
goog.dependencies_ = {
pathToNames: {}, // 1 to many
nameToPath: {}, // 1 to 1
requires: {}, // 1 to many
visited: {}, // used when resolving dependencies to prevent us from
// visiting the file twice
written: {} // used to keep track of script files we have written
};
/**
* Tries to detect whether is in the context of an HTML document.
* @return {boolean} True if it looks like HTML document.
* @private
*/
goog.inHtmlDocument_ = function() {
var doc = goog.global.document;
return typeof doc != 'undefined' &&
'write' in doc; // XULDocument misses write.
};
/**
* Tries to detect the base path of the base.js script that bootstraps Closure
* @private
*/
goog.findBasePath_ = function() {
if (!goog.inHtmlDocument_()) {
return;
}
var doc = goog.global.document;
if (goog.global.CLOSURE_BASE_PATH) {
goog.basePath = goog.global.CLOSURE_BASE_PATH;
return;
}
var scripts = doc.getElementsByTagName('script');
// Search backwards since the current script is in almost all cases the one
// that has base.js.
for (var i = scripts.length - 1; i >= 0; --i) {
var src = scripts[i].src;
var l = src.length;
if (src.substr(l - 7) == 'base.js') {
goog.basePath = src.substr(0, l - 7);
return;
}
}
};
/**
* Writes a script tag if, and only if, that script hasn't already been added
* to the document. (Must be called at execution time)
* @param {string} src Script source.
* @private
*/
goog.writeScriptTag_ = function(src) {
if (goog.inHtmlDocument_() &&
!goog.dependencies_.written[src]) {
goog.dependencies_.written[src] = true;
var doc = goog.global.document;
doc.write('