Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Add a `deviceorientation` comand to the Firefox command line.
* Running the following code in a Scratchpad running in the 'browser' context
* will add a `deviceorientation` command to the Firefox command line.
name: 'deviceorientation',
description: 'Fire a deviceorientation event',
params: [{
name: 'alpha',
type: 'number'
}, {
name: 'beta',
type: 'number'
}, {
name: 'gamma',
type: 'number'
exec: function(args, context) {
var win = context.environment.document.defaultView;
var event = win.document.createEvent("DeviceOrientationEvent");
event.initDeviceOrientationEvent('deviceorientation', true
, true, args.alpha, args.gamma,, true);

This comment has been minimized.

Copy link
Owner Author

@harthur harthur commented May 30, 2013

To run this, first enable chrome debugging:

  1. Open the DevTools window with Web Developer > Toggle Tools.
  2. Open the settings tab (the gear icon)
  3. Check "Enable chrome debugging" under Advanced Settings
  4. Restart Firefox (try the Restartless Restart addon)

Then open a Scratchpad:

  1. Tools > Web Developer > Scratchpad
  2. Set the scratchpad to "chrome" mode with Environment > Browser
  3. Copy the above code into the scratchpad and run it (Cmd-R / Ctrl-R)

Try it out

  1. Tools > Web Developer > Developer Toolbar
  2. Navigate to Marine Compass demo
  3. Type deviceorientation 30 40 -120 into the toolbar and press Enter:


Turn it into an addon

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment