Revision: 5592
Author:   [email protected]
Date:     Mon Sep  9 17:11:26 2013 UTC
Log:      Fix test-scan-guest on Safari.
https://codereview.appspot.com/13602044

* isNativeFunction self-test assumed Function.prototype's toString was
  not "[native code]", which it is on Safari. (From r5574.)
* Removed accidental duplicate of isNativeFunction produced when scanner
  was split into two files. (From r5576.)

[email protected]

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

Modified:
 /trunk/tests/com/google/caja/plugin/test-scan-core.js
 /trunk/tests/com/google/caja/plugin/test-scan-guest.js

=======================================
--- /trunk/tests/com/google/caja/plugin/test-scan-core.js Mon Aug 26 17:08:41 2013 UTC +++ /trunk/tests/com/google/caja/plugin/test-scan-core.js Mon Sep 9 17:11:26 2013 UTC
@@ -52,16 +52,13 @@
       // ES5/3 Function.prototype is semi-toxic and throws in this case.
       //
// Also, Function.prototype is not a native function in the sense we care
-      // about (it is exercised separately), and since it doesn't match the
- // above pattern (its body is empty), returning false is consistent with
-      // the SES case.
+      // about (it is exercised separately), and also does not throw, so we
+      // don't care about the return value.
       return false;
     }
   }
   // self-test
-  if (isNativeFunction(Function.prototype)) {
-    throw new Error('isNativeFunction: failed on Function.prototype');
-  }
+  isNativeFunction(Function.prototype);  // don't care, must not throw
   if (!isNativeFunction(Math.sin)) {  // arbitrary boring native function
     throw new Error('isNativeFunction: failed on Math.sin');
   }
=======================================
--- /trunk/tests/com/google/caja/plugin/test-scan-guest.js Mon Aug 26 17:08:41 2013 UTC +++ /trunk/tests/com/google/caja/plugin/test-scan-guest.js Mon Sep 9 17:11:26 2013 UTC
@@ -43,31 +43,6 @@
   var PLAIN_CALL = scanning.PLAIN_CALL;
   var getFunctionName = scanning.getFunctionName;

-  function isNativeFunction(f) {
-    try {
-      return (/^[^{}]*\{\s*\[native code\]\s*}\s*$/
-          .test(Function.prototype.toString.call(f)));
-    } catch (e) {
-      // ES5/3 Function.prototype is semi-toxic and throws in this case.
-      //
- // Also, Function.prototype is not a native function in the sense we care
-      // about (it is exercised separately), and since it doesn't match the
- // above pattern (its body is empty), returning false is consistent with
-      // the SES case.
-      return false;
-    }
-  }
-  // self-test
-  if (isNativeFunction(Function.prototype)) {
-    throw new Error('isNativeFunction: failed on Function.prototype');
-  }
-  if (!isNativeFunction(Math.sin)) {  // arbitrary boring native function
-    throw new Error('isNativeFunction: failed on Math.sin');
-  }
-  if (isNativeFunction(function() {})) {
-    throw new Error('isNativeFunction: failed on non-native');
-  }
-
   /** Fake evaluator for ES5/3 compatibility */
   function simpleEval(env, expr) {
     var match;

--

--- You received this message because you are subscribed to the Google Groups "Google Caja Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to