Skip to content

Instantly share code, notes, and snippets.

@seanmonstar
Created June 2, 2017 18:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save seanmonstar/70637ef4c3c174373dc463f1b9b938b3 to your computer and use it in GitHub Desktop.
Save seanmonstar/70637ef4c3c174373dc463f1b9b938b3 to your computer and use it in GitHub Desktop.
Firefox Push Simulating
function sendMessage(json) {
let message = new TextEncoder('utf-8').encode(JSON.stringify(json));
let notifier = Cc['@mozilla.org/push/Notifier;1'].getService(Ci.nsIPushNotifier);
notifier.notifyPushWithData(
"chrome://fxa-device-update",
Services.scriptSecurityManager.getSystemPrincipal(),
"",
message.length,
message
);
}
// Usage:
// sendMessage({ command: 'fxaccounts:device_connected', data: { deviceName: 'Laptop' } })
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment