You must declare the "idle" permission in your extension's manifest to use the idle API. For example:
{ "name": "My extension", ... "permissions": [ "idle" ], ... }