What steps will reproduce the problem?
1. Try to execute www.google.com/jsapi in a server side environment (like
Node.js)
2. Dependencies on windows and document break execution.
What is the expected output? What do you see instead?
The window issue is simple enough I just did this:
var global.window = global;
loadAndExecuteJSAPIScript();
However you are using the document object to load script files and this is a
little harder to 'mock'. It would be ideal if you added an extension point
into jsapi where I can hook my own load script function. I.e:
google.loader2.loadScript = function(src, callback) {
// Your code here
};
I could then just make my own implementation of this for my corresponding
framework.
Note: you would also need to give the developer time/namespace to mock this
(Hence the 'loader2' namespace above). I.e. Currently you do not execute the
code if google.loader already exists, so there needs to be a way of providing
the mock before the heavy processing/loading of libs starts (most probably just
another callback).
Thanks
Guido
Original issue reported on code.google.com by guido.tapia@gmail.com on 16 Jan 2011 at 1:37
Original issue reported on code.google.com by
guido.tapia@gmail.com
on 16 Jan 2011 at 1:37