“入门”教程中的ActionButton不起作用

时间:2015-03-14 06:03:52

标签: firefox-addon firefox-addon-sdk

我是firefox附加开发的新手,我无法理解为什么教程中最简单的例子不起作用。

我准确地遵循了此处的所有步骤:https://developer.mozilla.org/en-US/Add-ons/SDK/Tutorials/Getting_started 我无法在浏览器窗口的任何位置找到加载项按钮。仅限标准按钮: enter image description here

附加sdk似乎设置正确,cfx工作正常。以下是cfx run的控制台输出:

(addon-sdk-1.17)[12:40:05]sergey@linuxmain:my-addon> cfx run
Using binary at '/usr/bin/firefox'.

(process:10986): GLib-CRITICAL **: g_slice_set_config: assertion 'sys_page_size == 0' failed
Using profile at '/tmp/tmpPxd9iD.mozrunner'.

(process:10996): GLib-CRITICAL **: g_slice_set_config: assertion 'sys_page_size == 0' failed

(process:11006): GLib-CRITICAL **: g_slice_set_config: assertion 'sys_page_size == 0' failed
[10996] WARNING: Attempt to add property GnomeProgram::sm-connect after class was initialised: 'glib warning', file /home/abuild/rpmbuild/BUILD/mozilla/toolkit/xre/nsSigHandlers.cpp, line 140

(firefox:10996): GLib-GObject-WARNING **: Attempt to add property GnomeProgram::sm-connect after class was initialised
[10996] WARNING: Attempt to add property GnomeProgram::show-crash-dialog after class was initialised: 'glib warning', file /home/abuild/rpmbuild/BUILD/mozilla/toolkit/xre/nsSigHandlers.cpp, line 140

(firefox:10996): GLib-GObject-WARNING **: Attempt to add property GnomeProgram::show-crash-dialog after class was initialised
[10996] WARNING: Attempt to add property GnomeProgram::display after class was initialised: 'glib warning', file /home/abuild/rpmbuild/BUILD/mozilla/toolkit/xre/nsSigHandlers.cpp, line 140

(firefox:10996): GLib-GObject-WARNING **: Attempt to add property GnomeProgram::display after class was initialised
[10996] WARNING: Attempt to add property GnomeProgram::default-icon after class was initialised: 'glib warning', file /home/abuild/rpmbuild/BUILD/mozilla/toolkit/xre/nsSigHandlers.cpp, line 140

(firefox:10996): GLib-GObject-WARNING **: Attempt to add property GnomeProgram::default-icon after class was initialised
JavaScript error: resource://app/components/nsBrowserGlue.js, line 1610: NS_ERROR_FILE_NOT_FOUND: Component returned failure code: 0x80520012 (NS_ERROR_FILE_NOT_FOUND) [nsIPrefBranch.getComplexValue]

此输出的最后一行是什么?也许这就是原因?

附加文件和Python版本:

(addon-sdk-1.17)[12:46:06]sergey@linuxmain:my-addon> ls data/
icon-16.png  icon-32.png  icon-64.png
(addon-sdk-1.17)[12:46:10]sergey@linuxmain:my-addon> cat lib/main.js
var buttons = require('sdk/ui/button/action');
var tabs = require("sdk/tabs");

var button = buttons.ActionButton({
  id: "mozilla-link",
  label: "Visit Mozilla",
  icon: {
    "16": "./icon-16.png",
    "32": "./icon-32.png",
    "64": "./icon-64.png"
  },
  onClick: handleClick
});

function handleClick(state) {
  tabs.open("https://www.mozilla.org/");
}
(addon-sdk-1.17)[12:46:15]sergey@linuxmain:my-addon> python --version
Python 2.7.6

我运行Firefox版本36.0。加载项本身存在: enter image description here

那我错过了什么?如何将附加按钮带到面板上?

UPD:

如果我禁用插件,请打开&清除浏览器控制台,然后重新启用插件,然后我得到以下控制台输出:

Warning: attempting to write 4867 bytes to preference extensions.bootstrappedAddons. This is bad for general performance and memory usage. Such an amount of data should rather be written to an external file.
Warning: attempting to write 4670 bytes to preference extensions.xpiState. This is bad for general performance and memory usage. Such an amount of data should rather be written to an external file.

因此没有红色错误。

0 个答案:

没有答案