Reviewers: MarkM,

Description:
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

Please review this at https://codereview.appspot.com/91450047/

Affected files (+26, -7 lines):
  M     src/com/google/caja/plugin/domado.js
  M     src/com/google/caja/ses/repairES5.js
  M     src/com/google/caja/ses/startSES.js
  M     tests/com/google/caja/plugin/browser-test-case.js
  M     tests/com/google/caja/plugin/test-scan-guest.js


Index: src/com/google/caja/plugin/domado.js
===================================================================
--- src/com/google/caja/plugin/domado.js        (revision 5684)
+++ src/com/google/caja/plugin/domado.js        (working copy)
@@ -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'; },
Index: src/com/google/caja/ses/repairES5.js
===================================================================
--- src/com/google/caja/ses/repairES5.js        (revision 5684)
+++ src/com/google/caja/ses/repairES5.js        (working copy)
@@ -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 (typeof global.DataView === 'undefined') { return false; }
+    if (typeof global.DOMException === 'undefined') { return false; }
     function subtest(f) {
       try {
         f();
Index: src/com/google/caja/ses/startSES.js
===================================================================
--- src/com/google/caja/ses/startSES.js (revision 5684)
+++ src/com/google/caja/ses/startSES.js (working copy)
@@ -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 = typeof global.Proxy !== 'undefined' &&
+          !!global.Proxy.create;
+
+      var nativeProxies = proxiesAvailable && (function () {
         var obj = {0: 'hi'};
         var p = global.Proxy.create({
           get: function(O, P) {
Index: tests/com/google/caja/plugin/browser-test-case.js
===================================================================
--- tests/com/google/caja/plugin/browser-test-case.js   (revision 5684)
+++ tests/com/google/caja/plugin/browser-test-case.js   (working copy)
@@ -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
+      typeof frameGroup.iframe.Proxy !== 'undefined' &&
+          !!frameGroup.iframe.Proxy.create;

standardImports.getUrlParam = frame.tame(frame.markFunction(getUrlParam));
   standardImports.modifyUrlParam = frame.tame(frame.markFunction(
Index: tests/com/google/caja/plugin/test-scan-guest.js
===================================================================
--- tests/com/google/caja/plugin/test-scan-guest.js     (revision 5684)
+++ tests/com/google/caja/plugin/test-scan-guest.js     (working copy)
@@ -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