Skip to content

Commit

Permalink
added __initStandardObjects__ to internal window to protect prototype…
Browse files Browse the repository at this point in the history
…s across windows
  • Loading branch information
thatcher committed Feb 6, 2010
1 parent ee8ffd9 commit a531039
Show file tree
Hide file tree
Showing 5 changed files with 106 additions and 23 deletions.
3 changes: 2 additions & 1 deletion dist/env.rhino.js
Expand Up @@ -9135,6 +9135,7 @@ Envjs.platform = "Rhino ";//how do we get the version
*/
Envjs.proxy = function(scope, parent){


var _scope = scope;
_parent = parent||null,
_this = this,
Expand Down Expand Up @@ -9210,7 +9211,7 @@ Envjs.proxy = function(scope, parent){
return (value === _scope || value === this );
}
});

return _proxy;
};

Expand Down
3 changes: 2 additions & 1 deletion dist/platform/rhino.js
Expand Up @@ -339,6 +339,7 @@ Envjs.platform = "Rhino ";//how do we get the version
*/
Envjs.proxy = function(scope, parent){


var _scope = scope;
_parent = parent||null,
_this = this,
Expand Down Expand Up @@ -414,7 +415,7 @@ Envjs.proxy = function(scope, parent){
return (value === _scope || value === this );
}
});

return _proxy;
};

Expand Down
60 changes: 50 additions & 10 deletions dist/window.js
Expand Up @@ -282,16 +282,7 @@ Window = function(scope, parent, opener){
});


var __Array__;
if(!scope.Array){
__Array__ = function(){
return new parent.top.Array();
};
__extend__(__Array__.prototype, parent.top.Array.prototype);
scope.__defineGetter__('Array', function(){
return __Array__;
});
}
__initStandardObjects__(scope, parent);


var $uuid = new Date().getTime()+'-'+Math.floor(Math.random()*1000000000000000);
Expand Down Expand Up @@ -565,6 +556,55 @@ var __top__ = function(_scope){

var __windows__ = {};

var __initStandardObjects__ = function(scope, parent){

var __Array__;
if(!scope.Array){
__Array__ = function(){
return new parent.top.Array();
};
__extend__(__Array__.prototype, parent.top.Array.prototype);
scope.__defineGetter__('Array', function(){
return __Array__;
});
}

var __Object__;
if(!scope.Object){
__Object__ = function(){
return new parent.top.Object();
};
__extend__(__Object__.prototype, parent.top.Object.prototype);
scope.__defineGetter__('Object', function(){
return __Object__;
});
}


var __Date__;
if(!scope.Date){
__Date__ = function(){
return new parent.top.Date();
};
__extend__(__Date__.prototype, parent.top.Date.prototype);
scope.__defineGetter__('Date', function(){
return __Date__;
});
}

var __Number__;
if(!scope.Number){
__Number__ = function(){
return new parent.top.Number();
};
__extend__(__Number__.prototype, parent.top.Number.prototype);
scope.__defineGetter__('Number', function(){
return __Number__;
});
}

};

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

Expand Down
3 changes: 2 additions & 1 deletion src/env/rhino/window.js
Expand Up @@ -18,6 +18,7 @@ Envjs.platform = "Rhino ";//how do we get the version
*/
Envjs.proxy = function(scope, parent){


var _scope = scope;
_parent = parent||null,
_this = this,
Expand Down Expand Up @@ -93,6 +94,6 @@ Envjs.proxy = function(scope, parent){
return (value === _scope || value === this );
}
});

return _proxy;
};
60 changes: 50 additions & 10 deletions src/window/window.js
Expand Up @@ -18,16 +18,7 @@ Window = function(scope, parent, opener){
});


var __Array__;
if(!scope.Array){
__Array__ = function(){
return new parent.top.Array();
};
__extend__(__Array__.prototype, parent.top.Array.prototype);
scope.__defineGetter__('Array', function(){
return __Array__;
});
}
__initStandardObjects__(scope, parent);


var $uuid = new Date().getTime()+'-'+Math.floor(Math.random()*1000000000000000);
Expand Down Expand Up @@ -301,6 +292,55 @@ var __top__ = function(_scope){

var __windows__ = {};

var __initStandardObjects__ = function(scope, parent){

var __Array__;
if(!scope.Array){
__Array__ = function(){
return new parent.top.Array();
};
__extend__(__Array__.prototype, parent.top.Array.prototype);
scope.__defineGetter__('Array', function(){
return __Array__;
});
}

var __Object__;
if(!scope.Object){
__Object__ = function(){
return new parent.top.Object();
};
__extend__(__Object__.prototype, parent.top.Object.prototype);
scope.__defineGetter__('Object', function(){
return __Object__;
});
}


var __Date__;
if(!scope.Date){
__Date__ = function(){
return new parent.top.Date();
};
__extend__(__Date__.prototype, parent.top.Date.prototype);
scope.__defineGetter__('Date', function(){
return __Date__;
});
}

var __Number__;
if(!scope.Number){
__Number__ = function(){
return new parent.top.Number();
};
__extend__(__Number__.prototype, parent.top.Number.prototype);
scope.__defineGetter__('Number', function(){
return __Number__;
});
}

};

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

Expand Down

0 comments on commit a531039

Please sign in to comment.