Personal tools


From MozillaWiki

Jump to: navigation, search


partial interface Navigator {
  void addIdleObserver(IdleObserver);
  void removeIdleObserver(IdleObserver);

interface IdleObserver {
  attribute long time; // seconds
  void onidle();
  void onactive();

Using this APi would look something like:

navigator.addIdleObserver({ time: 4, onidle: myIdleHandler, onactive: myActiveHandler});

This will call the myIdleHandler function once the user has been inactive for 4 seconds. Once the user goes active again we'd call the myActiveHandler function. You can of course use any means of producing the object passed to the function, such as:

navigator.addIdleObserver(new WidgetUpdateThingy(...));

Security/Privacy considerations

For normal webpages the timing of when the user goes idle can be used to correlate identities used in separate windows. I.e. if the user has two windows open to two separate websites and one window is in privacy mode, the websites can figure out the user's identity even in the privacy-mode window by noticing that the user goes idle in both windows at the exact same time.

In order to fix this we switch to "user is idle" mode in each window with a small amount of "fuzz". I.e. we delay the switch by a few seconds or minutes. This delay is different in different tabs. This affects both the timing of when the mozUserIdle boolean changes value and when the "mozuseridle" event fires.

Same thing when switching back to active mode. This happens with a small randomized delay. However, if the user interacts with a tab, the page in the tab can clearly detect that the user is no longer idle. In this scenario we switch the user to active mode immediately before firing the mouse/keyboard/touch event. This *only* affects the tab the user interacted with. But if the user switches between multiple tabs, we can be forced to do this early switch in several tabs.

When switching between idle/active modes, we should ideally do that for a whole tab at a time. I.e. it should affect all windows in a given tab at the same time.

We might also want to display UI which allows the user to choose if he/she wants to expose idle/active status to page. This is something we still need to figure out.