Skip to content

Commit

Permalink
jquery 1.4.1 integration test patches, loading but not yet running
Browse files Browse the repository at this point in the history
  • Loading branch information
thatcher committed Feb 9, 2010
1 parent 0278d78 commit d3ef20e
Show file tree
Hide file tree
Showing 19 changed files with 280 additions and 99 deletions.
96 changes: 96 additions & 0 deletions bin/jquery-1.4.1-test.js
@@ -0,0 +1,96 @@
//debugger;
load("dist/env.rhino.js");

Envjs({
//let it load the script from the html
scriptTypes: {
"text/javascript" :true
},
afterScriptLoad:{
'qunit/testrunner.js': function(){
//hook into qunit.log
var count = 0;
QUnit.log = function(result, message){
console.log('(' + (count++) + ')[' +
((!!result) ? 'PASS' : 'FAIL') + '] ' + message);
};
//hook into qunit.done
QUnit.done = function(pass, fail){
console.log('Writing Results to File');
jQuery('script').each(function(){
this.type = 'text/envjs';
});
Envjs.writeToFile(
document.documentElement.xml,
Envjs.location('jqenv-'+Date.now()+'.html')
);
};

//allow jquery to run ajax
isLocal = false;


var unsafeStop = stop,
unsafeStart = start,
isStopped = null;

var config_timeout;
stop = function(timeout){
if(isStopped === null || isStopped === false){
console.log('PAUSING QUNIT');
isStopped = true;
unsafeStop.call(this);
timeout = ( timeout && timeout > 0 ) ? timeout : 10000;
/*if (timeout)
config_timeout = setTimeout(function() {
QUnit.ok( false, "Test timed out" );
start();
}, timeout);*/
Envjs.wait()
}
};
start = function(){
if(isStopped === null || isStopped === true ){
console.log('RESTARTING QUNIT');
isStopped = false;
if(config_timeout) {
clearTimeout(config_timeout);
config_timeout = undefined;
}
unsafeStart.call(this);
}
};
//we know some ajax calls will fail becuase
//we are not running against a running server
//for php files
var handleError = jQuery.handleError;
jQuery.handleError = function(){
ok(false, 'Ajax may have failed while running locally');
try{
handleError(arguments);
}catch(e){}
//allow tests to gracefully continue
start();
};
//allow unanticipated xhr error with no ajax.handleError
//callback (eg jQuery.getScript) to exit gracefully
Envjs.onInterrupt = function(){
console.log('thread interupt: gracefully continuing test');
start();
};


Envjs.onScriptLoadError = function(script){
Envjs.error("failed to load script \n"+script.text);
ok(false, 'Ajax may have failed to load correct script while running locally');
//allow tests to gracefully continue
start();
};
}
}
});

window.document.async = false;
window.location = 'test/vendor/jQuery/1.4.1/test/index.html';
Envjs.wait();

12 changes: 7 additions & 5 deletions dist/dom.js
Expand Up @@ -495,17 +495,19 @@ var __findNamedItemIndex__ = function(namednodemap, name, isnsmap) {
// loop through all nodes
for (var i=0; i<namednodemap.length; i++) {
// compare name to each node's nodeName
if(isnsmap){
if(namednodemap[i].localName && name && isnsmap){
if (namednodemap[i].localName.toLowerCase() == name.toLowerCase()) {
// found it!
ret = i;
break;
}
}else{
if (namednodemap[i].name.toLowerCase() == name.toLowerCase()) {
// found it!
ret = i;
break;
if(namednodemap[i].name && name){
if (namednodemap[i].name.toLowerCase() == name.toLowerCase()) {
// found it!
ret = i;
break;
}
}
}
}
Expand Down
56 changes: 34 additions & 22 deletions dist/env.js
Expand Up @@ -165,7 +165,8 @@ Envjs.loadLocalScript = function(script){
}
base = "" + script.ownerDocument.location;
//filename = Envjs.location(script.src.match(/([^\?#]*)/)[1], base );
filename = Envjs.location(script.src, base );
//console.log('base %s', base);
filename = Envjs.location(script.src, base);
try {
load(filename);
console.log('loaded %s', filename);
Expand Down Expand Up @@ -1056,17 +1057,19 @@ var __findNamedItemIndex__ = function(namednodemap, name, isnsmap) {
// loop through all nodes
for (var i=0; i<namednodemap.length; i++) {
// compare name to each node's nodeName
if(isnsmap){
if(namednodemap[i].localName && name && isnsmap){
if (namednodemap[i].localName.toLowerCase() == name.toLowerCase()) {
// found it!
ret = i;
break;
}
}else{
if (namednodemap[i].name.toLowerCase() == name.toLowerCase()) {
// found it!
ret = i;
break;
if(namednodemap[i].name && name){
if (namednodemap[i].name.toLowerCase() == name.toLowerCase()) {
// found it!
ret = i;
break;
}
}
}
}
Expand Down Expand Up @@ -3702,6 +3705,8 @@ function __addEventListener__(target, type, fn, phase){
phase = !!phase?"CAPTURING":"BUBBLING";
if ( !target.uuid ) {
target.uuid = $events.length;
}
if ( !$events[target.uuid] ) {
$events[target.uuid] = {};
}
if ( !$events[target.uuid][type] ){
Expand All @@ -3717,19 +3722,21 @@ function __addEventListener__(target, type, fn, phase){
};


function __removeEventListener__(target, type, fn, _phase){
function __removeEventListener__(target, type, fn, phase){

phase = !!phase?"CAPTURING":"BUBBLING";
if ( !target.uuid ) {
target.uuid = $events.length;
}
if ( !$events[target.uuid] ) {
$events[target.uuid] = {};
}
if ( !$events[target.uuid][type] ){
$events[target.uuid][type] = {
CAPTURING:[],
BUBBLING:[]
};
}
}
$events[target.uuid][type][phase] =
$events[target.uuid][type][phase].filter(function(f){
return f != fn;
Expand Down Expand Up @@ -3757,7 +3764,7 @@ function __dispatchEvent__(target, event, bubbles){
__captureEvent__(target, event);

event.eventPhase = Event.AT_TARGET;
if ( target.uuid && $events[target.uuid][event.type] ) {
if ( target.uuid && $events[target.uuid] && $events[target.uuid][event.type] ) {
event.currentTarget = target;
$events[target.uuid][event.type]['CAPTURING'].forEach(function(fn){
var returnValue = fn( event );
Expand Down Expand Up @@ -3789,27 +3796,29 @@ function __captureEvent__(target, event){

event.eventPhase = Event.CAPTURING_PHASE;
while(parent){
if(parent.uuid && $events[parent.uuid][event.type]['CAPTURING']){
if(parent.uuid && $events[parent.uuid] && $events[parent.uuid][event.type]){
ancestorStack.push(parent);
}
parent = parent.parentNode;
}
while(ancestorStack.length && !event.cancelled){
event.currentTarget = ancestorStack.pop();
$events[event.currentTarget.uuid][event.type]['CAPTURING'].forEach(function(fn){
var returnValue = fn( event );
if(returnValue === false){
event.stopPropagation();
}
});
if($events[event.currentTarget.uuid] && $events[event.currentTarget.uuid][event.type]){
$events[event.currentTarget.uuid][event.type]['CAPTURING'].forEach(function(fn){
var returnValue = fn( event );
if(returnValue === false){
event.stopPropagation();
}
});
}
}
};

function __bubbleEvent__(target, event){
var parent = target.parentNode;
event.eventPhase = Event.BUBBLING_PHASE;
while(parent){
if(parent.uuid && $events[parent.uuid][event.type]['BUBBLING']){
if(parent.uuid && $events[parent.uuid] && $events[parent.uuid][event.type] ){
event.currentTarget = parent;
$events[event.currentTarget.uuid][event.type]['BUBBLING'].forEach(function(fn){
var returnValue = fn( event );
Expand Down Expand Up @@ -5115,10 +5124,10 @@ __extend__(HTMLElement.prototype, {
return this.setAttribute("lang",val);
},
get offsetHeight(){
return Number(this.style["height"].replace("px",""));
return Number((this.style["height"]||'').replace("px",""));
},
get offsetWidth(){
return Number(this.style["width"].replace("px",""));
return Number((this.style["width"]||'').replace("px",""));
},
offsetLeft: 0,
offsetRight: 0,
Expand Down Expand Up @@ -8721,12 +8730,14 @@ var __elementPopped__ = function(ns, name, node){
// something to watch for if this code changes.
var type = ( node.type === null ) ? "text/javascript" : node.type;
try{
if(node.nodeName.toLowerCase() == 'script' && type == "text/javascript"){
if(node.nodeName.toLowerCase() == 'script' && type == "text/javascript"
&& (node.src || node.childNodes.length > 0)){
//$env.debug("element popped: script\n"+node.xml);
// unless we're parsing in a window context, don't execute scripts
if (doc.toString() === '[object HTMLDocument]'){

okay = Envjs.loadLocalScript(node, null);
//console.log('loaded script? %s', okay);
//console.log('loaded script? %s %s', node.uuid, okay);
// only fire event if we actually had something to load
if (node.src && node.src.length > 0){
event = doc.createEvent('HTMLEvents');
Expand Down Expand Up @@ -9214,6 +9225,7 @@ Window = function(scope, parent, opener){
return $location;
},
set location(uri){
uri = Envjs.location(uri);
new Window(this, this.parent, this.opener);
if($location.href == uri){
$location.reload();
Expand Down Expand Up @@ -9309,7 +9321,7 @@ Window = function(scope, parent, opener){
if(name)
_window.name = name;
_window.document.async = false;
_window.location.assign(url);
_window.location.assign(Envjs.location(url));
return _window;
},
close: function(){
Expand Down

0 comments on commit d3ef20e

Please sign in to comment.