代码之家  ›  专栏  ›  技术社区  ›  Jesus Ramos

firefox 4.0b1中jssh的javascript错误

  •  -1
  • Jesus Ramos  · 技术社区  · 15 年前

    通过为新的火狐4.0测试版1编译和构建的JSSH使用这个javascript,会返回一条奇怪的消息。这是密码(如果有点乱,对不起) 总之,代码检查了firefox窗口的所有帧,该窗口是我们单元测试的一个测试页,其中有一个onclick元素,其中包含短语“再见,太棒了”,而不是得到一个失败的响应,我们在最后收到这个奇怪的nserrror,我们无法解释。

    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 frame::interactive:::line 1“数据:否]

    1 回复  |  直到 15 年前
        1
  •  0
  •   Jesus Ramos    15 年前

    JSSH在firefox 4中不再受支持,而且处理起来很混乱,切换到mozrepl,因为它主要是用javascript编写的,直接将我自己的javascript命令添加到扩展中似乎是完成某些事情的更好方法。

    推荐文章