新しいFirefox4.0ベータ1用にコンパイルおよびビルドされたjsshを介してこのJavascriptを使用すると、奇妙なメッセージが返されます。これがコードです(少し面倒な場合は申し訳ありません)。
要約すると、コードは、ユニットテストのテストページであるFirefoxウィンドウのすべてのフレームをチェックし<td>
て、Goodbye Wonderfulというフレーズを含む要素を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フレーム::インタラクティブ::<TOP_LEVEL> ::行1"データ:いいえ]