Created
November 25, 2013 21:00
-
-
Save oconnore/7648810 to your computer and use it in GitHub Desktop.
'alarm' message handler issue
This file contains hidden or 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
(function() { | |
'use strict'; | |
var received = false; | |
navigator.mozSetMessageHandler('alarm', function(ev) { | |
received = true; | |
console.log('message handled ->', JSON.stringify(ev)); | |
}); | |
navigator.mozAlarms.add(Date.now() + 1000, 'ignoreTimezone', { | |
testData: 42 | |
}); | |
var start = Date.now(), limit = start + 2000; | |
var loop = function() { | |
var req = navigator.mozAlarms.getAll(); | |
req.onsuccess = function(ev) { | |
var cur = Date.now(); | |
console.log('at ', (cur - start), ' alarms: ', | |
JSON.stringify(req.result), 'handled?', received); | |
if (cur < limit) { | |
setTimeout(loop, 100); | |
} | |
} | |
}; | |
loop(); | |
})(this); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment