[Sugar-devel] sugar-web: env.js questions

Daniel Narvaez dwnarvaez at gmail.com
Fri Nov 22 14:17:18 EST 2013


I think a decent solution would be to check if window.location starts with
activity:// in the getEnvironment function (that's the protocol we use when
running inside sugar). If not, just return null to the callback.

Then fix envSpec.js to do a proper async check (see datastoreSpec.js, we
are doing it a lot there). And handle the null case to avoid an error when
running standalone.


On 22 November 2013 19:59, Daniel Narvaez <dwnarvaez at gmail.com> wrote:

> Oh actually I see why it succeeds... The test doesn't verify that it
> receives a response. It will only fail if it gets the wrong answer (and it
> probably it's not always to fail in that case either). We need to follow
> the async pattern we have in the datastore test. Though first maybe best to
> decide what we want to do with getEnvironment exactly...
>
>
> On 22 November 2013 19:56, Daniel Narvaez <dwnarvaez at gmail.com> wrote:
>
>> On 22 November 2013 19:31, Rogelio Mita <rogeliomita at activitycentral.com>wrote:
>>
>>> Hi,
>>>
>>> Can you help me to understand the getEnvironment function (
>>> https://github.com/sugarlabs/sugar-web/blob/master/env.js)?.
>>>
>>
>> This is used to pass some initial environment variables from python.
>>
>>
>>> My understanding is that if sugar.environment is undefined is because I
>>> am in standalone mode, is that right?
>>>
>>
>> Right now, I'd expect it to not return at all, which is a bug. I'm not
>> sure what's a good solution though, other than writing a webkit plugin in C
>> which I'm trying to resist.
>>
>>
>>> what is the purpose of this handler onEnvironmentSet (
>>> https://github.com/sugarlabs/sugar-web/blob/master/env.js#L22)?
>>>
>>>
>> Python calls it to notify js that it has set the environment variables on
>> window.sugar.
>>
>>
>>> I am running all tests (with karma but with a Chfome browser, no in
>>> sugar environment) and I noted some rare: when is running this test:
>>> https://github.com/sugarlabs/sugar-web/blob/master/test/envSpec.js is
>>> SUCCESS, I can't underestand why.
>>>
>>
>> You mean it sometimes succeed or it rarely does? (both are unexpected).
>>
>
>
>
> --
> Daniel Narvaez
>



-- 
Daniel Narvaez
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sugarlabs.org/archive/sugar-devel/attachments/20131122/c6391f27/attachment.html>


More information about the Sugar-devel mailing list