Preliminary comments attached. http://codereview.appspot.com/96177/diff/1028/26 File src/com/google/caja/cajita.js (right): http://codereview.appspot.com/96177/diff/1028/26#newcode3172 Line 3172: /* The promise implementation and ...
16 years, 8 months ago
(2009-08-03 18:24:09 UTC)
#2
Preliminary comments attached.
http://codereview.appspot.com/96177/diff/1028/26
File src/com/google/caja/cajita.js (right):
http://codereview.appspot.com/96177/diff/1028/26#newcode3172
Line 3172: /*
The promise implementation and the definition of Q can be moved to a different
file, right? You can have the file contain something like:
var Q;
(function() {
/* encapsulated definitions ... */
Q = /* something */;
})();
Then cajita.js can check if Q is available, and do:
if (Q) { /* freeze Q */ }
cajita = { Q: Q, /* ... */ };
People who want to provide Q to their Cajita would then be sure to include the
necessary file before "cajita.js". And we would modify our build scripts to
always bundle that file in by default.
The advantage of this approach is it makes it possible to diff directly with
Tyler's implementation and move towards a more common Q.
The file should contain a comment based on Tyler's original, giving credit etc.
http://codereview.appspot.com/96177/diff/1028/26#newcode3176
Line 3176: * Mostly taken from the web_send implementation by Tyler Close
I think you meant ref_send.js? (ref_send is a component of web_send.)
http://codereview.appspot.com/96177/diff/1028/26#newcode3576
Line 3576:
Extra leading spaces added to this line.
http://codereview.appspot.com/96177/diff/1028/26#newcode3691
Line 3691: secureModuleOf: secureModuleOf,
TODO(ihab.awad): Check whether this is actually used anywhere. Since
secureModuleOf just passes thru to eval() at the moment (and hence isn't
secure), it is risky unless necessary.
http://codereview.appspot.com/96177/diff/1028/26#newcode3750
Line 3750: /**
I think the module loader makers can be in a separate file as well. The platform
can choose to include these and use them if it wishes. They need not be part of
cajita.js proper.
Again, our build scripts may or may not choose to bundle these into the default
minified chunks.
In a comment in the resulting file, please summarize the API of a "loader
object" as returned by either of the *ModuleLoaderMaker() functions.
Also ... I am coming to the conclusion that maybe your module loaders are
actually best seen as a JS API to the cajoling service; see:
http://docs.google.com/Doc?docid=0AVWyIFBvIVXGZGZneGI3Z2tfNjVkbjV0OXdmaw&hl=en
If you agree, then maybe in refactoring them, we should just optimize their API
to work with the cajoling service and, for other stuff that's different, just
let programmers build whatever they want as long as it satisfies the (dead
simple!) loader interface?
http://codereview.appspot.com/96177/diff/1028/26#newcode3756
Line 3756: xhrModuleLoaderMaker = function(urlRewriter) {
You know what? I was thinking and maybe it's easiest to just make the
xhrModuleLoader a *singleton* in the page in which it lives. If I want to
provide an attenuated loader, I just do:
var theLoader = ___.primFreeze({
load: ___.markFuncFreeze(function(name) {
return xhrModuleLoader.load(
'http://cajoler.org/' + name + '.js');
})
});
or whatever. Would that be easier and simpler and more easily explainable to the
universe than having to deal with the "URL rewriter chain" in the loaders?
http://codereview.appspot.com/96177/diff/1028/26#newcode3763
Line 3763: if (xhr.status === 200) {
Extra space before "===".
http://codereview.appspot.com/96177/diff/1028/26#newcode3767
Line 3767: r.resolve(theModule);
Can eliminate local variable 'theModule' -> simpler?
http://codereview.appspot.com/96177/diff/1028/25
File src/com/google/caja/parser/quasiliteral/CajitaRewriter.java (right):
http://codereview.appspot.com/96177/diff/1028/25#newcode437
Line 437: matches="sload(@arg)",
Interesting. What was the reason for choosing to rename the loader syntax versus
just recognizing "loader.load()" with a string literal?
http://codereview.appspot.com/96177/diff/1028/18
File tests/com/google/caja/a.js (right):
http://codereview.appspot.com/96177/diff/1028/18#newcode1
Line 1: ({
Why do you need to create explicit cajoled modules in the test source directory?
You can instead use the build file to cajole some things into the ant-lib
directory, similarly to how (say) domita_test_untrusted.html is cajoled at build
time.
http://codereview.appspot.com/96177/diff/1028/22
File tests/com/google/caja/plugin/domita_test.html (right):
http://codereview.appspot.com/96177/diff/1028/22#newcode408
Line 408: function (src) {return '/tests/com/google/caja/' + src;});
How does that work without the "http://localhost:8000/..." stuff added to the
front? :)
http://codereview.appspot.com/96177/diff/1028/23
File tests/com/google/caja/plugin/domita_test_untrusted.html (right):
http://codereview.appspot.com/96177/diff/1028/23#newcode2508
Line 2508: function testXhrModuleLoader() {
Indentation.
http://codereview.appspot.com/96177/diff/1028/23#newcode2519
Line 2519: var r = Q.when(m, f1, f2);
Variable 'r' unused.
http://codereview.appspot.com/96177/diff/1028/23#newcode2555
Line 2555: function testScriptModuleLoader() {
Indentation.
http://codereview.appspot.com/96177/diff/1028/26 File src/com/google/caja/cajita.js (right): http://codereview.appspot.com/96177/diff/1028/26#newcode3172 Line 3172: /* On 2009/08/03 18:24:09, ihab.awad wrote: > The ...
16 years, 7 months ago
(2009-08-16 21:31:41 UTC)
#3
http://codereview.appspot.com/96177/diff/1028/26
File src/com/google/caja/cajita.js (right):
http://codereview.appspot.com/96177/diff/1028/26#newcode3172
Line 3172: /*
On 2009/08/03 18:24:09, ihab.awad wrote:
> The promise implementation and the definition of Q can be moved to a different
> file, right? You can have the file contain something like:
>
> var Q;
> (function() {
> /* encapsulated definitions ... */
> Q = /* something */;
> })();
>
> Then cajita.js can check if Q is available, and do:
>
> if (Q) { /* freeze Q */ }
> cajita = { Q: Q, /* ... */ };
>
> People who want to provide Q to their Cajita would then be sure to include the
> necessary file before "cajita.js". And we would modify our build scripts to
> always bundle that file in by default.
>
> The advantage of this approach is it makes it possible to diff directly with
> Tyler's implementation and move towards a more common Q.
>
> The file should contain a comment based on Tyler's original, giving credit
etc.
Done.
http://codereview.appspot.com/96177/diff/1028/26#newcode3176
Line 3176: * Mostly taken from the web_send implementation by Tyler Close
On 2009/08/03 18:24:09, ihab.awad wrote:
> I think you meant ref_send.js? (ref_send is a component of web_send.)
Done.
http://codereview.appspot.com/96177/diff/1028/26#newcode3576
Line 3576:
On 2009/08/03 18:24:09, ihab.awad wrote:
> Extra leading spaces added to this line.
Done.
http://codereview.appspot.com/96177/diff/1028/26#newcode3756
Line 3756: xhrModuleLoaderMaker = function(urlRewriter) {
On 2009/08/03 18:24:09, ihab.awad wrote:
> You know what? I was thinking and maybe it's easiest to just make the
> xhrModuleLoader a *singleton* in the page in which it lives. If I want to
> provide an attenuated loader, I just do:
>
> var theLoader = ___.primFreeze({
> load: ___.markFuncFreeze(function(name) {
> return xhrModuleLoader.load(
> 'http://cajoler.org/' + name + '.js');
> })
> });
>
> or whatever. Would that be easier and simpler and more easily explainable to
the
> universe than having to deal with the "URL rewriter chain" in the loaders?
Done.
http://codereview.appspot.com/96177/diff/1028/26#newcode3763
Line 3763: if (xhr.status === 200) {
On 2009/08/03 18:24:09, ihab.awad wrote:
> Extra space before "===".
Done.
http://codereview.appspot.com/96177/diff/1028/26#newcode3767
Line 3767: r.resolve(theModule);
On 2009/08/03 18:24:09, ihab.awad wrote:
> Can eliminate local variable 'theModule' -> simpler?
Done.
http://codereview.appspot.com/96177/diff/1028/18
File tests/com/google/caja/a.js (right):
http://codereview.appspot.com/96177/diff/1028/18#newcode1
Line 1: ({
On 2009/08/03 18:24:09, ihab.awad wrote:
> Why do you need to create explicit cajoled modules in the test source
directory?
> You can instead use the build file to cajole some things into the ant-lib
> directory, similarly to how (say) domita_test_untrusted.html is cajoled at
build
> time.
Done.
http://codereview.appspot.com/96177/diff/1028/22
File tests/com/google/caja/plugin/domita_test.html (right):
http://codereview.appspot.com/96177/diff/1028/22#newcode408
Line 408: function (src) {return '/tests/com/google/caja/' + src;});
On 2009/08/03 18:24:09, ihab.awad wrote:
> How does that work without the "http://localhost:8000/..." stuff added to the
> front? :)
"http://localhost:8000" is implicit because the page is on localhost:8000. I did
not include that because using xhr loader implicitly requires the module to be
retrieved from the same domain.
http://codereview.appspot.com/96177/diff/1028/23
File tests/com/google/caja/plugin/domita_test_untrusted.html (right):
http://codereview.appspot.com/96177/diff/1028/23#newcode2508
Line 2508: function testXhrModuleLoader() {
On 2009/08/03 18:24:09, ihab.awad wrote:
> Indentation.
Done.
http://codereview.appspot.com/96177/diff/1028/23#newcode2519
Line 2519: var r = Q.when(m, f1, f2);
On 2009/08/03 18:24:09, ihab.awad wrote:
> Variable 'r' unused.
Done.
http://codereview.appspot.com/96177/diff/1028/23#newcode2555
Line 2555: function testScriptModuleLoader() {
On 2009/08/03 18:24:09, ihab.awad wrote:
> Indentation.
Done.
Comments below, to discuss as well. http://codereview.appspot.com/96177/diff/1028/22 File tests/com/google/caja/plugin/domita_test.html (right): http://codereview.appspot.com/96177/diff/1028/22#newcode408 Line 408: function (src) ...
16 years, 7 months ago
(2009-08-18 17:33:46 UTC)
#4
http://codereview.appspot.com/96177/diff/4026/5034 File src/com/google/caja/cajita-module.js (right): http://codereview.appspot.com/96177/diff/4026/5034#newcode26 Line 26: xhr.responseText.replace("___.loadModule", ""))); On 2009/08/18 21:22:26, maoziqing wrote: > ...
16 years, 7 months ago
(2009-08-18 21:27:47 UTC)
#6
http://codereview.appspot.com/96177/diff/4026/5034
File src/com/google/caja/cajita-module.js (right):
http://codereview.appspot.com/96177/diff/4026/5034#newcode26
Line 26: xhr.responseText.replace("___.loadModule", "")));
On 2009/08/18 21:22:26, maoziqing wrote:
> If we directly remove the ___.loadModule, the xhr requests
> can be sent in parallel.
Echoing our verbal discussion for the folks in TV land. :) If we save the
previous module handler and restore it afterwards, and *assuming* there is no
browser quirk that executes the JavaScript "multi-threaded", we should be ok.
16 years, 7 months ago
(2009-08-18 21:36:44 UTC)
#7
Done. Thanks.
On 2009/08/18 21:27:47, ihab.awad wrote:
> http://codereview.appspot.com/96177/diff/4026/5034
> File src/com/google/caja/cajita-module.js (right):
>
> http://codereview.appspot.com/96177/diff/4026/5034#newcode26
> Line 26: xhr.responseText.replace("___.loadModule", "")));
> On 2009/08/18 21:22:26, maoziqing wrote:
> > If we directly remove the ___.loadModule, the xhr requests
> > can be sent in parallel.
>
> Echoing our verbal discussion for the folks in TV land. :) If we save the
> previous module handler and restore it afterwards, and *assuming* there is no
> browser quirk that executes the JavaScript "multi-threaded", we should be ok.
Plus verbal comments re error conditions in cajita-module.js http://codereview.appspot.com/96177/diff/7064/6075 File src/com/google/caja/valija-cajita.js (right): http://codereview.appspot.com/96177/diff/7064/6075#newcode500 Line 500: ...
16 years, 7 months ago
(2009-08-20 21:07:16 UTC)
#10
http://codereview.appspot.com/96177/diff/7064/6069 File src/com/google/caja/cajita-module.js (right): http://codereview.appspot.com/96177/diff/7064/6069#newcode92 Line 92: handle: ___.markFuncFreeze(function theHandler(module) { As we discussed, this ...
16 years, 7 months ago
(2009-08-20 22:10:58 UTC)
#11
Issue 96177: Dynamic module loading for Cajita
(Closed)
Created 16 years, 8 months ago by maoziqing
Modified 16 years, 7 months ago
Reviewers: ihab.awad
Base URL: http://google-caja.googlecode.com/svn/trunk/
Comments: 144