--- /dev/null
+// =========
+// Browser
+
+// Encapsulates access to the document object, so that we can
+// fall back to alternate behaviour during command-line unit testing
+
+var Browser = (function() {
+ var my = {};
+
+ function isDefined(obj) {
+ return !( typeof obj === 'undefined' || obj === null );
+ }
+
+ my.getElementById = function(id) {
+ if ( isDefined(document) ) {
+ var result = document.getElementById(id);
+ if ( isDefined(result) ) {
+ return result;
+ }
+ else {
+ console.log('ERROR! Document element not found for ID:', id);
+ return undefined;
+ }
+ }
+ else {
+ return undefined;
+ }
+ };
+
+ my.setOnMouseMove = function(handler) {
+ if ( typeof(document) === 'undefined' || document === null ) {
+ // no-op
+ }
+ else {
+ document.onmousemove = handler;
+ }
+ };
+
+ return my;
+})();