Revision: 5685
Author:   [email protected]
Date:     Fri May 16 16:33:03 2014 UTC
Log:      Fix incorrect feature tests in SES and Domado.
https://codereview.appspot.com/91450047

Fixes the following:

inTestFrame used for repairES5 repairs
http://code.google.com/p/google-caja/issues/detail?id=1917

test_TYPED_ARRAYS_THROW_DOMEXCEPTION
http://code.google.com/p/google-caja/issues/detail?id=1918

Distinguishing between direct-proxies and old style proxies
http://code.google.com/p/google-caja/issues/detail?id=1919

[email protected]

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

Modified:
 /trunk/src/com/google/caja/plugin/domado.js
 /trunk/src/com/google/caja/ses/repairES5.js
 /trunk/src/com/google/caja/ses/startSES.js
 /trunk/tests/com/google/caja/plugin/browser-test-case.js
 /trunk/tests/com/google/caja/plugin/test-scan-guest.js

=======================================
--- /trunk/src/com/google/caja/plugin/domado.js Mon Apr 28 22:53:26 2014 UTC
+++ /trunk/src/com/google/caja/plugin/domado.js Fri May 16 16:33:03 2014 UTC
@@ -118,7 +118,10 @@
     }
   }

-  var proxiesAvailable = typeof Proxy !== 'undefined';
+ // test for old-style proxies, not ES6 direct proxies, because that's what we
+  // used and what ES5/3 provides.
+  // TODO(kpreid): Need to migrate to ES6-planned proxy API
+  var proxiesAvailable = typeof Proxy !== 'undefined' && !!Proxy.create;
   var proxiesInterceptNumeric = proxiesAvailable && (function() {
     var handler = {
toString: function() { return 'proxiesInterceptNumeric test handler'; },
=======================================
--- /trunk/src/com/google/caja/ses/repairES5.js Tue May  6 03:32:16 2014 UTC
+++ /trunk/src/com/google/caja/ses/repairES5.js Fri May 16 16:33:03 2014 UTC
@@ -681,8 +681,13 @@
     return false;
   }

+ // Create a new iframe and pass its 'window' object to the provided callback. + // If the environment is not a browser, return undefined and do not call the
+  // callback.
   function inTestFrame(callback) {
-    if (!document || !document.createElement) { return undefined; }
+    if (!(typeof document !== 'undefined' && document.createElement)) {
+      return undefined;
+    }
     var iframe = document.createElement('iframe');
var container = document.body || document.getElementsByTagName('head')[0] ||
         document.documentElement || document;
@@ -2566,8 +2571,8 @@
   ];

   function test_TYPED_ARRAYS_THROW_DOMEXCEPTION() {
-    if (global.DataView === 'undefined') { return false; }
-    if (global.DOMException === 'undefined') { return false; }
+    if (global.DataView === undefined) { return false; }
+    if (global.DOMException === undefined) { return false; }
     function subtest(f) {
       try {
         f();
=======================================
--- /trunk/src/com/google/caja/ses/startSES.js  Mon Mar 17 02:52:38 2014 UTC
+++ /trunk/src/com/google/caja/ses/startSES.js  Fri May 16 16:33:03 2014 UTC
@@ -1141,7 +1141,12 @@
       }
       constFunc(lengthGetter);

-      var nativeProxies = global.Proxy && (function () {
+      // test for old-style proxies, not ES6 direct proxies
+      // TODO(kpreid): Need to migrate to ES6-planned proxy API
+      var proxiesAvailable = global.Proxy !== undefined &&
+          !!global.Proxy.create;
+
+      var nativeProxies = proxiesAvailable && (function () {
         var obj = {0: 'hi'};
         var p = global.Proxy.create({
           get: function(O, P) {
=======================================
--- /trunk/tests/com/google/caja/plugin/browser-test-case.js Tue Oct 8 22:01:03 2013 UTC +++ /trunk/tests/com/google/caja/plugin/browser-test-case.js Fri May 16 16:33:03 2014 UTC
@@ -542,8 +542,13 @@
   standardImports.console = frame.tame(fakeConsole);

   standardImports.proxiesAvailableToTamingCode =
-      // Domado runs in the taming frame's real global env
-      typeof frameGroup.iframe.Proxy !== 'undefined';
+ // Domado runs in the taming frame's real global env, so test that rather
+      // than SES.
+ // test for old-style proxies, not ES6 direct proxies, because that's what
+      // Domado uses.
+      // TODO(kpreid): Need to migrate to ES6-planned proxy API
+      frameGroup.iframe.Proxy !== undefined &&
+          !!frameGroup.iframe.Proxy.create;

standardImports.getUrlParam = frame.tame(frame.markFunction(getUrlParam));
   standardImports.modifyUrlParam = frame.tame(frame.markFunction(
=======================================
--- /trunk/tests/com/google/caja/plugin/test-scan-guest.js Mon May 12 17:27:32 2014 UTC +++ /trunk/tests/com/google/caja/plugin/test-scan-guest.js Fri May 16 16:33:03 2014 UTC
@@ -750,6 +750,7 @@
           }
         }));

+    argsByIdentity(window.Proxy, G.none);  // TODO abuse
     argsByIdentity(window.Proxy && Proxy.create, G.none);  // TODO abuse
argsByIdentity(window.Proxy && Proxy.createFunction, G.none); // TODO abuse

--

--- 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/d/optout.

Reply via email to