Last active
December 17, 2015 22:09
Add a `deviceorientation` comand to the Firefox command line.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Running the following code in a Scratchpad running in the 'browser' context | |
* will add a `deviceorientation` command to the Firefox command line. | |
*/ | |
Components.utils.import("resource:///modules/devtools/gcli.jsm"); | |
gcli.addCommand({ | |
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, args.omega, true); | |
win.dispatchEvent(event); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To run this, first enable chrome debugging:
Then open a Scratchpad:
Try it out
deviceorientation 30 40 -120
into the toolbar and press Enter:Turn it into an addon