Account Options

  1. Sign in
The old Google Groups will be going away soon.
Switch to the new Google Groups.
Google Groups Home
« Groups Home
r4778 committed - Fixes several failing jQuery tests...
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 Feb 10, 12:06 am
From: google-c...@googlecode.com
Date: Fri, 10 Feb 2012 05:06:15 +0000
Local: Fri, Feb 10 2012 12:06 am
Subject: [google-caja] r4778 committed - Fixes several failing jQuery tests...
Revision: 4778
Author:   metaweta
Date:     Thu Feb  9 21:05:25 2012
Log:      Fixes several failing jQuery tests
http://codereview.appspot.com/5654047

The lexCss() function requires a string as input but some callers weren't
casting first.  I added a cast at the start of the function.

If you wrap the onreadystatechange property of XHR in an untame(), then
when the feral native DOM layer tries to call the event callback, it will
try to tame the |event| object passed in, which is neither possible
(it's an unsupported weirdo object) nor necessary,
so the correct thing to do is just to pass a plain function.

We do not tame xhr.responseXML, but jquery tests crash if it does not
contain at least documentElement.cloneNode.  I added a kludge that allows
the jQuery tests to continue to run and a message that Caja doesn't
support it.

attachDocumentStub() was renamed to attachDocument() a while back; this
changes the error message to match.

In one situation in jquery that I haven't been able to replicate outside
it, traversing the parentNode chain can lead to a host page DOM node that
has not yet had the caja properties attached so that cajoled Domado can
use them.  This change makes sure the properties are there.

Before this change, the HTML element violated the spec that says the
parentNode of the element should be the document, so this change
fixes that.

R=ihab.awad

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

Modified:
  /trunk/src/com/google/caja/plugin/csslexer.js
  /trunk/src/com/google/caja/plugin/domado.js
  /trunk/tests/com/google/caja/plugin/es53-test-domado-dom-guest.html

=======================================
--- /trunk/src/com/google/caja/plugin/csslexer.js       Thu Jan 19 09:04:11 2012
+++ /trunk/src/com/google/caja/plugin/csslexer.js       Thu Feb  9 21:05:25 2012
@@ -223,6 +223,7 @@
     *    delimiters and to not otherwise contain double quotes.
     */
    lexCss = function (cssText) {
+    cssText = '' + cssText;
      var tokens = cssText.replace(/\r\n?/g, '\n')  // Normalize CRLF & CR  
to LF.
          .match(CSS_TOKEN) || [];
      var j = 0;
=======================================
--- /trunk/src/com/google/caja/plugin/domado.js Thu Feb  2 09:47:25 2012
+++ /trunk/src/com/google/caja/plugin/domado.js Thu Feb  9 21:05:25 2012
@@ -618,10 +618,10 @@
            // 'target'? May need to implement full "tame event" wrapper  
similar
            // to DOM events.
            var self = this;
-          p(this).feral.onreadystatechange = taming.untame(function  
(event) {
+          p(this).feral.onreadystatechange = function (event) {
              var evt = { target: self };
              return handler.call(void 0, evt);
-          });
+          };
            // Store for later direct invocation if need be
            p(this).handler = handler;
          })
@@ -647,7 +647,14 @@
            // TODO(ihab.awad): Implement a taming layer for XML. Requires
            // generalizing the HTML node hierarchy as well so we have a  
unified
            // implementation.
-          return {};
+
+          // This kludge is just enough to keep the jQuery tests from  
freezing.
+          var node = {nodeName: '#document'};
+          node.cloneNode = function () { return node; };
+          node.toString = function () {
+            return 'Caja does not support XML.';
+          };
+          return {documentElement: node};
          })
        },
        status: {
@@ -719,7 +726,7 @@
          // TODO(ihab.awad): Expect tamed XML document; unwrap and send
          p(this).feral.send('');
        }
-
+
        // Firefox does not call the 'onreadystatechange' handler in
        // the case of a synchronous XHR. We simulate this behavior by
        // calling the handler explicitly.
@@ -1299,7 +1306,7 @@
          idSuffix, uriCallback, pseudoBodyNode, optPseudoWindowLocation) {
        if (arguments.length < 3) {
          throw new Error(
-            'attachDocumentStub arity mismatch: ' + arguments.length);
+            'attachDocument arity mismatch: ' + arguments.length);
        }
        if (!optPseudoWindowLocation) {
            optPseudoWindowLocation = {};
@@ -1960,7 +1967,9 @@
          // Catch errors because node might be from a different domain.
          try {
            var docElem = node.ownerDocument.documentElement;
-          for (var ancestor = node; ancestor; ancestor =  
ancestor.parentNode) {
+          for (var ancestor = node;
+              ancestor;
+              ancestor = makeDOMAccessible(ancestor.parentNode)) {
              if (idClassPattern.test(ancestor.className)) {
                return tameNodeCtor(node, editable);
              } else if (ancestor === docElem) {
@@ -4653,7 +4662,7 @@
              'HTML',
              this,
              function () { return [tameHeadElement, tameBodyElement]; },
-            function () { return tamingProxies.get(this); },
+            function () { return tameDocument; },
              function () {
                return ('<head>' + tameHeadElement.innerHTML
                        + '<\/head><body>'
@@ -5267,12 +5276,7 @@
        function TameWindow() {
          // These descriptors were chosen to resemble actual ES5-supporting  
browser
          // behavior.
-        Object.defineProperty(this, "document", {
-          value: tameDocument,
-          configurable: false,
-          enumerable: true,
-          writable: false
-        });
+        // The document property is defined below.
          Object.defineProperty(this, "location", {
            value: tameLocation,
            configurable: false,
@@ -5571,6 +5575,12 @@

        domicile.window = tameWindow;
        domicile.document = tameDocument;
+      Object.defineProperty(tameWindow, 'document', {
+        value: tameDocument,
+        configurable: false,
+        enumerable: true,
+        writable: false
+      });

        pluginId = rulebreaker.getId(tameWindow);
        windowToDomicile.set(tameWindow, domicile);
=======================================
--- /trunk/tests/com/google/caja/plugin/es53-test-domado-dom-guest.html Tue  
Jan 24 11:04:08 2012
+++ /trunk/tests/com/google/caja/plugin/es53-test-domado-dom-guest.html Thu  
Feb  9 21:05:25 2012
@@ -462,6 +462,7 @@
      assertEquals(null, title.getAttribute('foo'));
      assertEquals('HTML', html.tagName);
      assertEquals(null, html.getAttribute('foo'));
+    assertEquals(html.parentNode, document);
      assertEquals(html, all[0]);
      assertEquals(head, all[1]);
      assertEquals(title, all[2]);


 
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 »