Skip to content

Commit

Permalink
window is created as final step in env.js so it is available without …
Browse files Browse the repository at this point in the history
…manual construction
  • Loading branch information
thatcher committed Feb 4, 2010
1 parent 8995a76 commit 12e5b40
Show file tree
Hide file tree
Showing 12 changed files with 80 additions and 8 deletions.
3 changes: 2 additions & 1 deletion build.xml
Expand Up @@ -108,7 +108,7 @@
<token key="VERSION" value="core-env.${BUILD_VERSION}"/>
</replacetokens>
</filterchain>
<fileset dir="${SRC_DIR}" includes="env/__global__.js" />
<fileset dir="${SRC_DIR}" includes="env/core/__global__.js" />
<fileset dir="${SRC_DIR}" includes="common/intro.js" />
<fileset dir="${SRC_DIR}" includes="env/core/console.js" />
<fileset dir="${SRC_DIR}" includes="env/core/dom.js" />
Expand All @@ -134,6 +134,7 @@
<token key="VERSION" value="rhino-env.${BUILD_VERSION}"/>
</replacetokens>
</filterchain>
<fileset dir="${SRC_DIR}" includes="env/rhino/__global__.js" />
<fileset dir="${SRC_DIR}" includes="common/intro.js" />
<fileset dir="${SRC_DIR}" includes="env/rhino/console.js" />
<fileset dir="${SRC_DIR}" includes="env/rhino/dom.js" />
Expand Down
1 change: 1 addition & 0 deletions dist/platform/core.js
Expand Up @@ -26,6 +26,7 @@ Envjs.appCodeName = "Envjs";
//eg "Gecko/20070309 Firefox/2.0.0.3"
Envjs.appName = "Resig/20070309 PilotFish/1.2.0.1";


/*
* Envjs core-env.1.2.0.0
* Pure JavaScript Browser Environment
Expand Down
27 changes: 27 additions & 0 deletions dist/platform/rhino.js
@@ -1,3 +1,11 @@
/*
* Envjs rhino-env.1.2.0.0
* Pure JavaScript Browser Environment
* By John Resig <http://ejohn.org/> and the Envjs Team
* Copyright 2008-2010 John Resig, under the MIT License
*/

var __context__ = Packages.org.mozilla.javascript.Context.getCurrentContext();

/*
* Envjs rhino-env.1.2.0.0
Expand Down Expand Up @@ -39,6 +47,25 @@ Envjs.sleep = function(millseconds){
java.lang.Thread.currentThread().sleep(millseconds);
};

/**
* provides callback hook for when the system exits
*/
Envjs.onExit = function(callback){
var rhino = Packages.org.mozilla.javascript,
contextFactory = __context__.getFactory(),
listener = new rhino.ContextFactory.Listener({
contextReleased: function(context){
if(context === __context__)
console.log('context released', context);
contextFactory.removeListener(this);
if(callback)
callback();
}
});
contextFactory.addListener(listener);
};


/**
* resolves location relative to doc location
* @param {Object} path
Expand Down
8 changes: 7 additions & 1 deletion dist/window.js
Expand Up @@ -5,7 +5,8 @@
var Window,
Screen,
History,
Navigator;
Navigator,
__this__ = this;


/*
Expand Down Expand Up @@ -547,6 +548,11 @@ Window = function(scope, parent, opener){

var __windows__ = {};

//finally pre-supply the window with the window-like environment
new Window(__this__, __this__);



/**
* @author john resig & the envjs team
* @uri http://www.envjs.com/
Expand Down
File renamed without changes.
1 change: 1 addition & 0 deletions src/env/__global__.js → src/env/core/__global__.js
Expand Up @@ -25,3 +25,4 @@ var Envjs = function(){
Envjs.appCodeName = "Envjs";
//eg "Gecko/20070309 Firefox/2.0.0.3"
Envjs.appName = "Resig/20070309 PilotFish/1.2.0.1";

8 changes: 8 additions & 0 deletions src/env/rhino/__global__.js
@@ -0,0 +1,8 @@
/*
* Envjs @VERSION@
* Pure JavaScript Browser Environment
* By John Resig <http://ejohn.org/> and the Envjs Team
* Copyright 2008-2010 John Resig, under the MIT License
*/

var __context__ = Packages.org.mozilla.javascript.Context.getCurrentContext();
19 changes: 19 additions & 0 deletions src/env/rhino/timer.js
Expand Up @@ -13,3 +13,22 @@ Envjs.sync = sync;
Envjs.sleep = function(millseconds){
java.lang.Thread.currentThread().sleep(millseconds);
};

/**
* provides callback hook for when the system exits
*/
Envjs.onExit = function(callback){
var rhino = Packages.org.mozilla.javascript,
contextFactory = __context__.getFactory(),
listener = new rhino.ContextFactory.Listener({
contextReleased: function(context){
if(context === __context__)
console.log('context released', context);
contextFactory.removeListener(this);
if(callback)
callback();
}
});
contextFactory.addListener(listener);
};

3 changes: 2 additions & 1 deletion src/window/__global__.js
Expand Up @@ -5,5 +5,6 @@
var Window,
Screen,
History,
Navigator;
Navigator,
__this__ = this;

5 changes: 5 additions & 0 deletions src/window/window.js
Expand Up @@ -283,3 +283,8 @@ Window = function(scope, parent, opener){
};

var __windows__ = {};

//finally pre-supply the window with the window-like environment
new Window(__this__, __this__);


7 changes: 6 additions & 1 deletion test/specs/env/spec.js
Expand Up @@ -50,7 +50,8 @@ test('Envjs Platform Interfaces Available', function(){
});


var document = null;
var document = null,
path = 'specs/env/spec.html';

test('Envjs.location', function(){

Expand Down Expand Up @@ -120,5 +121,9 @@ test('Envjs.proxy', function(){

});

Envjs.onExit(function(){
console.log('onExit!');
});

_start();

6 changes: 2 additions & 4 deletions test/specs/window/spec.js
Expand Up @@ -9,8 +9,7 @@ var _load,
_endtime,
Envjs;

var __this__ = this,
expected_path = 'test/specs/window/spec.html';
var expected_path = 'test/specs/window/spec.html';

try{
_load = load;
Expand All @@ -27,11 +26,10 @@ try{
_load('settings.js');
_load('local_settings.js');

//mock the window and document in envjs
new Window(__this__, __this__);
document.async = false;

_load('test/specs/qunit.js');

location = SETTINGS.AJAX_BASE + expected_path;

}catch(e){
Expand Down

0 comments on commit 12e5b40

Please sign in to comment.