2010-07-27 55 views
-1

使用此JavaScript通过jssh编译和新的Firefox 4.0 beta 1构建返回一个奇怪的消息。这里是代码(对不起,如果有点混乱) 总之,代码检查所有框架的firefox窗口,这是我们的单元测试的一个测试页面,其元素的onclick包含短语Goodbye Wonderful,而不是获取一个失败的回应,我们在最后收到这个奇怪的错误,这是我们无法解释的。在JavaScript中的JavaScript错误在Firefox 4.0B1

var firefoxWindow = getWindows()[0]; 
var browser = firefoxWindow.getBrowser(); 
var doc = browser.contentDocument; 


var elem = null; 
var elems = doc.getElementsByTagName('td'); 

for(a=0;a < elems.length;a++){ if(((elems[a] !== null && elems[a].hasAttributes() === true && elems[a].getAttribute('onclick') !== null && elems[a].getAttribute('onclick').toString().match(/doNothing/gim) !== null && elems[a].getAttribute('onclick').toString().match(/Goodbye Wonderful/gim).length >= 0) || (elems[a] !== null && elems[a].onclick !== null && elems[a].onclick.toString().match(/Goodbye Wonderful/gim) !== null && elems[a].onclick.toString().match(/Goodbye Wonderful/gim).length >= 0))) { elem = elems[a]; } } 

var found = false; 
var window = null; 

for(var i=0; i < firefoxWindow.frames.length; i++){if(firefoxWindow.frames[i].toString().toLowerCase().indexOf('object window') > -1){window = firefoxWindow.frames[i]; break;}} 


function recursiveSearch(frames){ for(var i=0; i<frames.length; i++){var elems = frames[i].document.getElementsByTagName('td'); for(a=0;a < elems.length;a++){ if(((elems[a] !== null && elems[a].hasAttributes() === true && elems[a].getAttribute('onclick') !== null && elems[a].getAttribute('onclick').toString().match(/Goodbye Wonderful/gim) !== null && elems[a].getAttribute('onclick').toString().match(/Goodbye Wonderful/gim).length >= 0) || (elems[a] !== null && elems[a].onclick !== null && elems[a].onclick.toString().match(/Goodbye Wonderful/gim) !== null && elems[a].onclick.toString().match(/Goodbye Wonderful/gim).length >= 0))) { elem = elems[a]; } } if(elem){found = true; return;} else{ if(frames[i].frames.length>0){recursiveSearch(frames[i].frames);}}}}if(!elem && window.frames.length > 0){ recursiveSearch(window.frames); }var origColor = '';if(elem !== null){origColor = elem.style.backgroundColor;if(origColor === null){origColor = '';} elem.style.backgroundColor = 'yellow';} 

下面是从jssh返回消息:

收稿:未捕获的异常:[异常... “组件不可用” nsresult: “0x80040111(NS_ERROR_NOT_AVAILABLE)” 位置:“JS帧:: interactive :: :: line 1“data:no]

回答

0

Firefox 4不再支持JSSh,它处理起来很麻烦,因为它主要是用JavaScript编写的,并且直接将自己的javascript命令添加到扩展中,所以切换到mozrepl似乎是完成某些事情的更好方式。