diff --git a/specs/platform/core.js b/specs/platform/core.js index fd685e55..d175e949 100644 --- a/specs/platform/core.js +++ b/specs/platform/core.js @@ -35,8 +35,8 @@ test('Envjs.uri', function(){ ok(uri, 'Able to create uri'); equals(uri, 'http://envjs.com/specs/env/spec.html', 'uri'); equals(uri.toString(), 'http://envjs.com/specs/env/spec.html', 'uri'); - - document = null; + + document = null; uri = Envjs.uri('http://envjs.com/specs/env/spec.html'); ok(uri, 'Able to create uri'); @@ -53,6 +53,15 @@ test('Envjs.uri', function(){ uri = Envjs.uri('file:///foo/bar/'); equals(uri, 'file:///foo/bar/', 'File, absolute, with ending "/"'); + + // handle windows style file paths, firefox will convert this to a file: URL + uri = Envjs.uri('C:\\foo\\bar\\index.html'); + equals(uri, 'file:///C:/foo/bar/index.html', 'File, absolute, converted slashes'); + + // when there is no document and you pass a relative path, it should be converted to a file: URL + document = null; + uri = Envjs.uri('specs/env/spec.html'); + ok(/file\:\/\/\/.*\/specs\/env\/spec.html/.test(uri), 'Relative filesystem paths work'); uri = Envjs.uri('http://foo.com'); equals(uri, 'http://foo.com/', 'http, absolute, without path, without ending "/"'); diff --git a/src/console/__global__.js b/src/console/__global__.js index 1b073730..ab96506e 100644 --- a/src/console/__global__.js +++ b/src/console/__global__.js @@ -2,5 +2,5 @@ /** * @author envjs team */ -var Console, - console; +/*var Console, + console;*/ diff --git a/src/css/__global__.js b/src/css/__global__.js index f934c1a7..9c59f7f3 100644 --- a/src/css/__global__.js +++ b/src/css/__global__.js @@ -2,7 +2,7 @@ /** * DOM Style Level 2 */ -var CSS2Properties, +/*var CSS2Properties, CSSRule, CSSStyleRule, CSSImportRule, @@ -13,4 +13,4 @@ var CSS2Properties, CSSStyleSheet, StyleSheet, StyleSheetList; -; +;*/ diff --git a/src/dom/__global__.js b/src/dom/__global__.js index 2bd3345f..23ee796f 100644 --- a/src/dom/__global__.js +++ b/src/dom/__global__.js @@ -13,7 +13,7 @@ * be able to correctly implement to core browser DOM interfaces." */ -var Attr, +/*var Attr, CDATASection, CharacterData, Comment, @@ -35,5 +35,5 @@ var Attr, Range, XMLSerializer, DOMParser; - +*/ diff --git a/src/event/__global__.js b/src/event/__global__.js index 5111fb91..afc65082 100644 --- a/src/event/__global__.js +++ b/src/event/__global__.js @@ -7,7 +7,7 @@ * This file simply provides the global definitions we need to * be able to correctly implement to core browser DOM Event interfaces. */ -var Event, +/*var Event, MouseEvent, UIEvent, KeyboardEvent, @@ -17,4 +17,4 @@ var Event, EventException, //nonstandard but very useful for implementing mutation events //among other things like general profiling - Aspect; \ No newline at end of file + Aspect;*/ \ No newline at end of file diff --git a/src/html/__global__.js b/src/html/__global__.js index e60eb688..05b48f2a 100644 --- a/src/html/__global__.js +++ b/src/html/__global__.js @@ -6,7 +6,7 @@ * This file simply provides the global definitions we need to * be able to correctly implement to core browser DOM HTML interfaces. */ -var HTMLDocument, +/*var HTMLDocument, HTMLElement, HTMLCollection, HTMLAnchorElement, @@ -64,3 +64,4 @@ var HTMLDocument, Option, __loadImage__, __loadLink__; +*/ \ No newline at end of file diff --git a/src/parser/__global__.js b/src/parser/__global__.js index 51e04bcc..42ff5f2b 100644 --- a/src/parser/__global__.js +++ b/src/parser/__global__.js @@ -2,7 +2,6 @@ //these are both non-standard globals that //provide static namespaces and functions //to support the html 5 parser from nu. -var XMLParser = {}, - HTMLParser = {}; - +XMLParser = {}; +HTMLParser = {}; \ No newline at end of file diff --git a/src/parser/htmldocument.js b/src/parser/htmldocument.js index e4f6f1e8..4cbef07e 100644 --- a/src/parser/htmldocument.js +++ b/src/parser/htmldocument.js @@ -155,6 +155,12 @@ var __elementPopped__ = function(ns, name, node){ doc.parsing = false; //DOMContentLoaded event try{ + if ( Envjs.killTimersAfterLoad === true ) { + Envjs.clear(); + } + if ( Envjs.fireLoad === false ) { + return; + } if(doc.createEvent){ event = doc.createEvent('Events'); event.initEvent("DOMContentLoaded", false, false); diff --git a/src/platform/core/__global__.js b/src/platform/core/__global__.js index 08869f32..b7332c4c 100644 --- a/src/platform/core/__global__.js +++ b/src/platform/core/__global__.js @@ -5,7 +5,7 @@ * Copyright 2008-2010 John Resig, under the MIT License */ -var Envjs = function(){ +Envjs = function(){ var i, name, override = function(){ @@ -30,6 +30,10 @@ var Envjs = function(){ override(arguments[1]); window.location = arguments[0]; } + if (Envjs.dontPrintUserAgent !== true && Envjs.printedUserAgent !== true) { + Envjs.printedUserAgent = true; + console.log('[ %s ]', window.navigator.userAgent); + } return; }, __this__ = this; diff --git a/src/platform/core/html.js b/src/platform/core/html.js index 18aeba80..bc84d737 100644 --- a/src/platform/core/html.js +++ b/src/platform/core/html.js @@ -40,6 +40,9 @@ Envjs.loadInlineScript = function(script){ 'eval('+script.text.substring(0,16)+'...):'+new Date().getTime() ); } + if ( Envjs.afterInlineScriptLoad ) { + Envjs.afterInlineScriptLoad(script) + } //console.log('evaluated at scope %s \n%s', // script.ownerDocument.ownerWindow.guid, script.text); }; diff --git a/src/platform/core/xhr.js b/src/platform/core/xhr.js index 41141b7b..a4c2f7bb 100644 --- a/src/platform/core/xhr.js +++ b/src/platform/core/xhr.js @@ -14,6 +14,7 @@ Envjs.getcwd = function() { * @param {Object} base (semi-optional) The base url used in resolving "path" above */ Envjs.uri = function(path, base) { + path = path.replace(/\\/g, '/'); //console.log('constructing uri from path %s and base %s', path, base); // Semi-common trick is to make an iframe with src='javascript:false' @@ -27,6 +28,12 @@ Envjs.uri = function(path, base) { return urlparse.urlnormalize(path); } + // if path is a Windows style absolute path (C:\foo\bar\index.html) + // make it a file: URL + if (path.match('^[a-zA-Z]+:/')) { + return 'file:///' + urlparse.urlnormalize(path); + } + // interesting special case, a few very large websites use // '//foo/bar/' to mean 'http://foo/bar' if (path.match('^//')) { @@ -48,7 +55,7 @@ Envjs.uri = function(path, base) { // if base is still empty, then we are in QA mode loading local // files. Get current working directory if (!base) { - base = 'file://' + Envjs.getcwd() + '/'; + base = 'file:///' + (""+Envjs.getcwd()).replace(/\\/g, '/') + '/'; } // handles all cases if path is abosulte or relative to base // 3rd arg is "false" --> remove fragments diff --git a/src/platform/rhino/__global__.js b/src/platform/rhino/__global__.js index fab8f277..c5a40465 100644 --- a/src/platform/rhino/__global__.js +++ b/src/platform/rhino/__global__.js @@ -5,7 +5,7 @@ * Copyright 2008-2010 John Resig, under the MIT License */ -var __context__ = Packages.org.mozilla.javascript.Context.getCurrentContext(); +__context__ = Packages.org.mozilla.javascript.Context.getCurrentContext(); Envjs.platform = "Rhino"; Envjs.revision = "1.7.0.rc2"; diff --git a/src/timer/__global__.js b/src/timer/__global__.js index 0113278c..e36b4821 100644 --- a/src/timer/__global__.js +++ b/src/timer/__global__.js @@ -10,10 +10,10 @@ * * requires Envjs.wait, Envjs.sleep, Envjs.WAIT_INTERVAL */ -var setTimeout, +/*var setTimeout, clearTimeout, setInterval, clearInterval; - +*/ \ No newline at end of file diff --git a/src/timer/timer.js b/src/timer/timer.js index 3d6f217b..fa410c85 100644 --- a/src/timer/timer.js +++ b/src/timer/timer.js @@ -11,6 +11,18 @@ $timers.lock = function(fn){ Envjs.sync(fn)(); }; +Envjs.clear = function(){ + $timers.lock(function(){ + for(var i=0; i<$timers.length; i++) { + if ( !$timers[i] ) { + continue; + } + $timers[i].stop(); + delete $timers[i]; + } + }); +} + //private internal class var Timer = function(fn, interval){ this.fn = fn; diff --git a/src/window/__global__.js b/src/window/__global__.js index f0874bfd..30e13d29 100644 --- a/src/window/__global__.js +++ b/src/window/__global__.js @@ -2,8 +2,8 @@ /** * @todo: document */ -var Window, +/*var Window, Screen, History, Navigator; - +*/ diff --git a/src/window/window.js b/src/window/window.js index 06292fff..c6fe6b41 100644 --- a/src/window/window.js +++ b/src/window/window.js @@ -325,5 +325,4 @@ Window = function(scope, parent, opener){ //finally pre-supply the window with the window-like environment //console.log('Default Window'); -new Window(__this__, __this__); -console.log('[ %s ]',window.navigator.userAgent); +new Window(__this__, __this__); \ No newline at end of file diff --git a/src/xhr/__global__.js b/src/xhr/__global__.js index ff185f16..fa400c93 100644 --- a/src/xhr/__global__.js +++ b/src/xhr/__global__.js @@ -10,5 +10,6 @@ * be able to correctly implement to core browser (XML)HTTPRequest * interfaces. */ -var Location, +/*var Location, XMLHttpRequest; +*/ \ No newline at end of file