Firefox 4.0b1 中 jssh 中的 Javascript 错误

发布于 2024-09-12 08:26:02 字数 2514 浏览 8 评论 0原文

通过为新的 Firefox 4.0 beta 1 编译和构建的 jssh 使用此 Javascript 会返回一条奇怪的消息。这是代码(抱歉,如果有点混乱)。

总之,代码检查 Firefox 窗口的所有框架,该窗口是我们单元测试的一个测试页面,其中包含 元素,该元素具有包含短语 Goodbye 的 onclick太棒了,我们没有得到失败的响应,而是在最后收到了这个奇怪的 nserror,我们无法解释。

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框架::交互式::::第1行”数据:否]

Using this Javascript through jssh compiled and built for the new Firefox 4.0 beta 1 returns an odd message. Here is the code (sorry if it's a little messy).

In summary the code checks all frames of a Firefox window which is a test page of our unit tests for a <td> element that has an onclick which contains the phrase Goodbye Wonderful, instead of getting a failed response back we are receiving this odd nserror at the end which we cannot explain.

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';}

Here is the return message from jssh :

Received: uncaught exception: [Exception... "Component is not available" nsresult: "0x80040111 (NS_ERROR_NOT_AVAILABLE)" location: "JS frame :: interactive :: <TOP_LEVEL> :: line 1" data: no]

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

世界和平 2024-09-19 08:26:02

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

JSSh is no longer supported in Firefox 4 and is a mess to handle, switching to mozrepl since it's written mostly in javascript and adding my own javascript commands directly to the extension seems to be a better way of accomplishing certain things.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文