Aha, I've found the solution! I botched the use of Date(), when I needed to
use it as a constructor, instead of subtracting from it. I've update MDN
docs with the new examples here. The old examples were 2 years old! :P

https://developer.mozilla.org/en-US/docs/Web/API/Network_Stats_API

Thanks for the help! :)

Best,
John Zeller
Website <http://www.johnzeller.com> | Github
<http://www.github.com/JohnLZeller> | FB
<http://facebook.com/JohnLukeZeller> | Twitter
<http://twitter.com/JohnLukeZeller> | G+
<https://plus.google.com/109697196852908178819/posts> | Resume
<http://www.johnzeller.com/ZellerJohnResume.pdf>
[email protected]
(503) 896-4679 (Text/Call Okay)

On Fri, Feb 20, 2015 at 5:32 PM, John Zeller <[email protected]> wrote:

> Hey Geo,
>
> Thanks for the stab :)
>
> So I rewrote it, to keep a better chain:
> https://zeller.pastebin.mozilla.org/8822671
>
> Still getting the weird error. Also, I even attempt to build what I
> believe to be the proper network variable and it does the same thing. you
> can see it commented out on line 33.
>
> I've been basing my js on things like this:
> http://mxr.mozilla.org/mozilla-central/source/dom/network/tests/test_networkstats_basics.html?force=1#103
>
> In that setup, you can see that the interface is also being pulled from
> result[0], so I *think* that's the right way to go about this. But,
> obviously I'm missing something.
>
> Best,
> John Zeller
> Website <http://www.johnzeller.com> | Github
> <http://www.github.com/JohnLZeller> | FB
> <http://facebook.com/JohnLukeZeller> | Twitter
> <http://twitter.com/JohnLukeZeller> | G+
> <https://plus.google.com/109697196852908178819/posts> | Resume
> <http://www.johnzeller.com/ZellerJohnResume.pdf>
> [email protected]
> (503) 896-4679 (Text/Call Okay)
>
> On Fri, Feb 20, 2015 at 5:20 PM, Geo Mealer <[email protected]> wrote:
>
>> John,
>>
>> I'll take a stab at a sanity check:
>>
>> Comparing line 35,
>>
>> var samples = navigator.mozNetworkStats.getSamples(networks.network,
>> start, end);
>>
>> with lines 25-27,
>>
>> networks.onsuccess = function() {
>>   var network = this.result[0];
>> }
>>
>> Was your intention to write "this.network = this.result[0]"?
>>
>> Also, unless one of the property accesses off mozNetworkStats is spinning
>> the event loop there after line 27, I'm not sure that networks.network
>> would be available by the time you get to line 35. I wonder if you're
>> actually sending an undefined into getSamples, and possibly getting a weird
>> error from that.
>>
>> Seems like all the rest of the code really depends on being in
>> networks.onsuccess(), a la a promise chain, similar to how you handled the
>> getSamples request.
>>
>> Geo
>>
>> On Fri, Feb 20, 2015 at 5:06 PM, John Zeller <[email protected]>
>> wrote:
>>
>>> Hello!
>>>
>>> I am attempting to get network stats on B2G device from certified app
>>> via WebIDE.
>>>
>>> I built a new blank privileged app with WebIDE, then I set the following
>>> in the manifest:
>>>
>>>   "type": "certified",
>>>   "permissions": {
>>>     "networkstats-manage": {}
>>>   },
>>>
>>> Now, I'm stuck getting 'uncaught exception: 2147942487', on line 35 of
>>> my js.
>>> https://zeller.pastebin.mozilla.org/8822668
>>>
>>> When I catch the exception, it's just '2147942487', which is not
>>> helpful. Googling tells me it seems to be related to a messed up parameter,
>>> but everything seems to be what is expected, afaik.
>>>
>>> Does anyone know what I am missing here?
>>>
>>> Best,
>>> John Zeller
>>> Website <http://www.johnzeller.com> | Github
>>> <http://www.github.com/JohnLZeller> | FB
>>> <http://facebook.com/JohnLukeZeller> | Twitter
>>> <http://twitter.com/JohnLukeZeller> | G+
>>> <https://plus.google.com/109697196852908178819/posts> | Resume
>>> <http://www.johnzeller.com/ZellerJohnResume.pdf>
>>> [email protected]
>>> (503) 896-4679 (Text/Call Okay)
>>>
>>> _______________________________________________
>>> dev-b2g mailing list
>>> [email protected]
>>> https://lists.mozilla.org/listinfo/dev-b2g
>>>
>>>
>>
>
_______________________________________________
dev-b2g mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-b2g

Reply via email to