Rewrite of globalEval. Uses window.execScript or window.eval with a trick to ensure proper context. Unit tests added.

This commit is contained in:
jaubourg 2011-04-07 06:47:15 +02:00
parent 4552d135f4
commit f3c6077da0
2 changed files with 30 additions and 17 deletions

View file

@ -172,6 +172,26 @@ test("selector state", function() {
);
});
test( "globalEval", function() {
expect( 3 );
jQuery.globalEval( "var globalEvalTest = true;" );
ok( window.globalEvalTest, "Test variable declarations are global" );
window.globalEvalTest = false;
jQuery.globalEval( "globalEvalTest = true;" );
ok( window.globalEvalTest, "Test variable assignments are global" );
window.globalEvalTest = false;
jQuery.globalEval( "this.globalEvalTest = true;" );
ok( window.globalEvalTest, "Test context (this) is the window object" );
window.globalEvalTest = undefined;
});
if ( !isLocal ) {
test("browser", function() {
stop();