Revision: 4236
Author: [email protected]
Date: Tue Aug 10 09:47:59 2010
Log: Have HostTools runCajoledModuleString give a nice error if the string doesn't ___.loadModule().
http://codereview.appspot.com/1942042

[email protected]

http://code.google.com/p/google-caja/source/detail?r=4236

Modified:
 /trunk/src/com/google/caja/plugin/host-tools.js

=======================================
--- /trunk/src/com/google/caja/plugin/host-tools.js     Wed Jul 21 21:05:55 2010
+++ /trunk/src/com/google/caja/plugin/host-tools.js     Tue Aug 10 09:47:59 2010
@@ -89,7 +89,8 @@
// This is primarily useful when used from caja.js (Caja in an iframe),
         // since the host page doesn't have eval of the frame

-        var moduleFunc;
+        var pumpkin = {};
+        var moduleFunc = pumpkin;
         var oldModuleHandler = ___.getNewModuleHandler();
         var newModuleHandler = ___.makeNormalNewModuleHandler();
         newModuleHandler.handle = ___.markFuncFreeze(
@@ -105,6 +106,10 @@
         } finally {
           ___.setNewModuleHandler(oldModuleHandler);
         }
+        if (moduleFunc === pumpkin) {
+ throw new Error("runCajoledModuleString: the provided code did not " +
+            "invoke the new module handler");
+        }
         return moduleFunc(imports);
       }

Reply via email to