Revision: 4556
Author:   jasvir
Date:     Thu Jul 14 22:49:32 2011
Log: Adds more tests for undefined uriPolicy and for undefined dom in caja.load()
http://codereview.appspot.com/4748041

Adds two tests.
* removes an extraneous call to createDiv()
* corrects a typo

[email protected]

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

Modified:
 /trunk/src/com/google/caja/plugin/caja.js
 /trunk/tests/com/google/caja/plugin/es53-test-cajajs-invocation.js

=======================================
--- /trunk/src/com/google/caja/plugin/caja.js   Thu Jul 14 18:12:55 2011
+++ /trunk/src/com/google/caja/plugin/caja.js   Thu Jul 14 22:49:32 2011
@@ -671,7 +671,7 @@
     }

     whenReady(function() {
-      frameGroup_.makeES5Frame(div, uriCallback || caja.policy.NO_NETWORK,
+ frameGroup_.makeES5Frame(div, uriCallback || caja.policy.net.NO_NETWORK,
         function (frame) {
           function run(resultCallback) {
             if (!builderState.primaryMethod) {
=======================================
--- /trunk/tests/com/google/caja/plugin/es53-test-cajajs-invocation.js Thu Jul 14 18:12:55 2011 +++ /trunk/tests/com/google/caja/plugin/es53-test-cajajs-invocation.js Thu Jul 14 22:49:32 2011
@@ -92,10 +92,37 @@
     });
   });

+  registerTest('testBuilderApiJsNoDom', function testBuilderApiJsNoDom() {
+    caja.load(undefined, uriCallback, function (frame) {
+      var extraImports = { x: 4, y: 3 };
+      frame.code('es53-test-guest.js', 'text/javascript')
+           .api(extraImports)
+           .run(function(result) {
+             assertEquals(12, result);
+             jsunitPass('testBuilderApiJsNoDom');
+           });
+    });
+  });
+
+  registerTest('testBuilderApiNetUndefined',
+      function testBuilderApiNetUndefined() {
+    var div = createDiv();
+    caja.load(div, undefined, function (frame) {
+      frame.code('http://localhost:8080/', 'text/html',
+          '<a href="http://fake1.url/foo";>fake1</a>' +
+          '<a href="http://fake2.url/foo";>fake2</a>'
+          )
+        .run(function (result) {
+ assertStringDoesNotContain('http://fake1.url/foo', div.innerHTML); + assertStringDoesNotContain('http://fake2.url/foo', div.innerHTML);
+          jsunitPass('testBuilderApiNetUndefined');
+        });
+    });
+  });
+
   registerTest('testBuilderApiNetNone', function testBuilderApiNetNone() {
     var div = createDiv();
     caja.load(div, caja.policy.net.NO_NETWORK, function (frame) {
-      var div = createDiv();
       frame.code('http://localhost:8080/', 'text/html',
           '<a href="http://fake1.url/foo";>fake1</a>' +
           '<a href="http://fake2.url/foo";>fake2</a>'

Reply via email to