ツールバー ボタンを作成するMozilla Addon Builderを使用して拡張機能を作成しました。現在の安定版 FF 3 で実行されているコードに変更は加えられていません。
var mytestextension = {
onLoad: function() {
// initialization code
this.initialized = true;
this.strings = document.getElementById("mytestextension-strings");
},
onMenuItemCommand: function(e) {
var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
.getService(Components.interfaces.nsIPromptService);
promptService.alert(window, this.strings.getString("helloMessageTitle"),
this.strings.getString("helloMessage"));
},
onToolbarButtonCommand: function(e) {
// just reuse the function above. you can change this, obviously!
mytestextension.onMenuItemCommand(e);
}
};
window.addEventListener("load", mytestextension.onLoad, false);
ツールバーボタンが表示されますが、クリックすると(onToolbarButtonCommandをトリガーする必要があると理解しています)、何もしません。ここでのデバッグについては少し曖昧です。'hello world' が機能しない言語を試したのはこれが初めてです!