Reviewers: MikeSamuel,

Description:
window.onload commit causes an error if window.onload is not set.
oops.

added a todo for testing that case, because it requires
having more than one domita test, which is dependent on
resolution of splitting up domita_test

Please review this at http://codereview.appspot.com/151065

Affected files:
  M     src/com/google/caja/plugin/domita.js
  M     tests/com/google/caja/plugin/domita_test_untrusted.html


Index: tests/com/google/caja/plugin/domita_test_untrusted.html
===================================================================
--- tests/com/google/caja/plugin/domita_test_untrusted.html     (revision 3835)
+++ tests/com/google/caja/plugin/domita_test_untrusted.html     (working copy)
@@ -1946,6 +1946,7 @@
   window.addEventListener('load', setb2);
   window.removeEventListener('load', setb1);
   window.onload = setb3;
+  //TODO(felix8a): also need to test when onload isn't set

   assertAsynchronousRequirement(
       'onload listeners',
Index: src/com/google/caja/plugin/domita.js
===================================================================
--- src/com/google/caja/plugin/domita.js        (revision 3835)
+++ src/com/google/caja/plugin/domita.js        (working copy)
@@ -3389,9 +3389,10 @@
// Called by the html-emitter when the virtual document has been loaded.
     TameHTMLDocument.prototype.signalLoaded___ = function () {
       var onload = ((___.canRead(imports, '$v')
-                     && ___.canCallPub(imports.$v, 'ro')
-                     && imports.$v.ro('onload'))
-                    || ___.readPub(imports.window, 'onload'));
+                     && ___.canCallPub(imports.$v, 'ros')
+                     && imports.$v.ros('onload'))
+                    || (imports.window &&
+                        ___.readPub(imports.window, 'onload')));
       if (onload) {
         setTimeout(
             function () { ___.callPub(onload, 'call', [___.USELESS]); },


Reply via email to