Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
r5149 committed - Systematize taming/untaming of primitives...
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  1 message - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
google-c...@googlecode.com  
View profile  
 More options Nov 9 2012, 5:58 pm
From: google-c...@googlecode.com
Date: Fri, 09 Nov 2012 22:58:10 +0000
Local: Fri, Nov 9 2012 5:58 pm
Subject: [google-caja] r5149 committed - Systematize taming/untaming of primitives...
Revision: 5149
Author:   ihab.a...@gmail.com
Date:     Fri Nov  9 14:57:44 2012
Log:      Systematize taming/untaming of primitives
http://codereview.appspot.com/6782044

See http://code.google.com/p/google-caja/issues/detail?id=1571

R=jas...@gmail.com

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

Added:
  /trunk/tests/com/google/caja/plugin/es53-test-taming-primitives.js
Modified:
  /trunk/src/com/google/caja/plugin/taming-membrane.js
  /trunk/tests/com/google/caja/plugin/GeneralBrowserTest.java
  /trunk/tests/com/google/caja/plugin/test-index.js

=======================================
--- /dev/null
+++ /trunk/tests/com/google/caja/plugin/es53-test-taming-primitives.js  Fri  
Nov  9 14:57:44 2012
@@ -0,0 +1,63 @@
+// Copyright (C) 2010 Google Inc.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+/**
+ * @fileoverview ES53 tests of taming and untaming of language primitives.
+ *
+ * @author ihab.a...@gmail.com
+ * @requires caja, jsunitRun, readyToTest
+ */
+
+(function() {
+
+  caja.initialize({
+    cajaServer: '/caja',
+    debug: true,
+    forceES5Mode: inES5Mode
+  });
+
+  // Set up basic stuff
+
+  var div = createDiv();
+  var uriPolicy = {
+    rewrite: function (uri, uriEffect, loaderType, hints) { return uri; }
+  };
+
+  caja.load(div, uriPolicy, function (frame) {
+
+    function assertPrimitives(f) {
+      assertEquals(null, f(null));
+      assertEquals(void 0, f(void 0));
+      assertEquals(37, f(37));
+      assertEquals(true, f(true));
+      assertEquals(false, f(false));
+      assertEquals('abc', f('abc'));
+    }
+
+    registerTest('testPrimitivesTaming',
+                   function testPrimitivesTaming() {
+      assertPrimitives(frame.tame);
+      jsunitPass('testPrimitivesTaming');
+    });
+
+    registerTest('testPrimitivesUntaming',
+                   function testPrimitivesUntaming() {
+      assertPrimitives(frame.untame);
+      jsunitPass('testPrimitivesUntaming');
+    });
+
+    readyToTest();
+    jsunitRun();
+  });
+})();
=======================================
--- /trunk/src/com/google/caja/plugin/taming-membrane.js        Tue Oct 23  
16:53:57 2012
+++ /trunk/src/com/google/caja/plugin/taming-membrane.js        Fri Nov  9  
14:57:44 2012
@@ -242,7 +242,10 @@
     * Returns a tame object representing f, or undefined on failure.
     */
    function tame(f) {
-    if (!f) { return f; }
+    if (f !== Object(f)) {
+      // Language primitive
+      return f;
+    }
      var ftype = typeof f;
      if (ftype !== 'function' && ftype !== 'object') {
        // Primitive value; tames to self
@@ -536,7 +539,10 @@
     * Returns a feral object representing t, or undefined on failure.
     */
    function untame(t) {
-    if (!t) { return t; }
+    if (t !== Object(t)) {
+      // language primitive
+      return t;
+    }
      var ttype = typeof t;
      if (ttype !== 'function' && ttype !== 'object') {
        // Primitive value; untames to self
=======================================
--- /trunk/tests/com/google/caja/plugin/GeneralBrowserTest.java Thu Nov  1  
12:06:52 2012
+++ /trunk/tests/com/google/caja/plugin/GeneralBrowserTest.java Fri Nov  9  
14:57:44 2012
@@ -183,6 +183,10 @@
    public final void testClientUriRewriting() throws Exception {
      runTestDriver("es53-test-client-uri-rewriting.js");
    }
+
+  public final void testTamingPrimitives() throws Exception {
+    runTestDriver("es53-test-taming-primitives.js", false);
+  }

    public final void testTamingTamed() throws Exception {
      runTestDriver("es53-test-taming-tamed.js");
=======================================
--- /trunk/tests/com/google/caja/plugin/test-index.js   Tue Nov  6 16:59:57  
2012
+++ /trunk/tests/com/google/caja/plugin/test-index.js   Fri Nov  9 14:57:44  
2012
@@ -48,6 +48,7 @@
      ['es53-test-relative-urls.js'],
      ['es53-test-taming-errors.js'],
      ['es53-test-taming-inout.js'],
+    ['es53-test-taming-primitives.js'],
      ['es53-test-taming-tamed.js'],
      ['es53-test-taming-untamed.js'],
      ['es53-test-unicode.js']


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »