Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

Enabling the behavior - updating the status bar panel

loadTinderboxStatus() を動作させるには、対応する updateTinderboxStatus() 関数を定義しなければなりません。

function updateTinderboxStatus()
{
  var icon = document.getElementById('tinderbox-status');
  
  if (gXMLHttpRequest.responseText.match("EE0000"))
    icon.setAttribute("status", "busted");
  else if (gXMLHttpRequest.responseText.match("FFAA00"))
    icon.setAttribute("status", "testfailed");
  else if (gXMLHttpRequest.responseText.match("11DD11"))
    icon.setAttribute("status", "success");
  else
    icon.setAttribute("status", "");
}

updateTinderboxStatus() では、我々の拡張機能の UI を表す statusbarpanel 要素への参照を取得し、次に、取得した HTML ドキュメント (XMLHttpRequest インスタンスの responseText プロパティに入っています) に検索をかけます。赤 (RGB コード「EE0000」で表される) が含まれていれば、それは Tinderbox クライアントが Mozilla のビルドに失敗したことを示しています。オレンジ色 (「FFAA00」) が含まれていれば、それは Tinderbox クライアントが Mozilla のビルドには成功したが、そのビルドがテストには失敗したことを示しています。緑色 (「11DD11」) が含まれていれば、それはクライアントが Mozilla のビルドにもテストにも成功したことを示しています。updateTinderboxStatus() 関数は、ドキュメント中に色を見つけたら、対応する値をパネルの status 属性にセットします。その結果、前に定義した CSS ルールによって、アイコンが Tinderbox の状態に対応するものに切り替えられます。我々の条件文は成功の判定よりも先に、悪い結果 (bustage 【訳注: ビルド失敗】、テスト失敗) の判定をしているため、成功のステータスよりも失敗のステータスが優先して表示されます。【訳注: もしそうでないと、「ひとつでも成功しているビルドがあれば、成功のステータスが表示される」ことになってしまいます】

ドキュメントのタグと貢献者

タグ: 
 このページの貢献者: Kohei
 最終更新者: Kohei,