Reviewers: jasvir,
Description:
http://code.google.com/p/google-caja/issues/detail?id=1063
1. the testbed doesn't pass the extra arg to HtmlEmitter,
so onload never fires in the testbed.
2. even when onload does fire, it sometimes doesn't fire.
cajole this:
<div>foo</div>
<script>
window.onload = function(){cajita.log(1);};
1;
</script>
note that in the cajoled output, there are no calls to
emitter___.signalLoaded();
Fixed SafeHtmlMaker to make sure that emitter___.signalLoaded()
is always present when there is user supplied JS inline in the
input.
Please review this at http://codereview.appspot.com/120061
Affected files:
M src/com/google/caja/plugin/templates/SafeHtmlMaker.java
M tests/com/google/caja/plugin/templates/TemplateCompilerTest.java
Index: tests/com/google/caja/plugin/templates/TemplateCompilerTest.java
===================================================================
--- tests/com/google/caja/plugin/templates/TemplateCompilerTest.java
(revision 3733)
+++ tests/com/google/caja/plugin/templates/TemplateCompilerTest.java
(working copy)
@@ -277,6 +277,9 @@
+ "} catch (ex___) {"
+ " ___.getNewModuleHandler().handleUncaughtException("
+ " ex___, onerror, 'testDeferredScripts', '1');"
+ + "}"
+ + "{"
+ + " IMPORTS___.htmlEmitter___.signalLoaded();"
+ "}"))
);
}
Index: src/com/google/caja/plugin/templates/SafeHtmlMaker.java
===================================================================
--- src/com/google/caja/plugin/templates/SafeHtmlMaker.java (revision 3733)
+++ src/com/google/caja/plugin/templates/SafeHtmlMaker.java (working copy)
@@ -284,6 +284,9 @@
private void signalLoaded() {
if (started) {
emitStatement(quasiStmt("emitter___./*...@synthetic*/signalLoaded();"));
+ } else if (!js.isEmpty()) {
+ emitStatement(quasiStmt(
+ "IMPORTS___.htmlEmitter___./*...@synthetic*/signalLoaded();"));
}
}