Revision: 3717
Author: mikesamuel
Date: Wed Sep 9 14:17:58 2009
Log: Bug 1120: document.compatMode missing
http://codereview.appspot.com/115080
From http://code.google.com/p/google-caja/issues/detail?id=1120 :
Uncajoled code that is forking on the compatMode may take the omission to
indicate the page is in quirks.
Specific to YUI, forking on the compatMode triggers whether to look for the
following properties on document.body or document.documentElement:
clientHeight
clientWidth
scrollHeight
scrollWidth
scrollTop
scrollLeft
[email protected]
http://code.google.com/p/google-caja/source/detail?r=3717
Modified:
/trunk/src/com/google/caja/plugin/domita.js
/trunk/tests/com/google/caja/plugin/domita_test_untrusted.html
=======================================
--- /trunk/src/com/google/caja/plugin/domita.js Fri Aug 28 19:16:06 2009
+++ /trunk/src/com/google/caja/plugin/domita.js Wed Sep 9 14:17:58 2009
@@ -3192,7 +3192,8 @@
}
this.documentElement___ = tameHtmlElement;
classUtils.exportFields(
- this, ['documentElement', 'body', 'title', 'domain', 'forms']);
+ this, ['documentElement', 'body', 'title', 'domain', 'forms',
+ 'compatMode']);
}
inertCtor(TameHTMLDocument, TamePseudoNode, 'HTMLDocument');
TameHTMLDocument.prototype.getNodeType = function () { return 9; };
@@ -3294,6 +3295,9 @@
}
return fakeNodeList(tameForms);
};
+ TameHTMLDocument.prototype.getCompatMode = function () {
+ return 'CSS1Compat';
+ };
TameHTMLDocument.prototype.toString = function () {
return '[Fake Document]';
};
=======================================
--- /trunk/tests/com/google/caja/plugin/domita_test_untrusted.html Wed Sep
2 13:52:16 2009
+++ /trunk/tests/com/google/caja/plugin/domita_test_untrusted.html Wed Sep
9 14:17:58 2009
@@ -71,7 +71,7 @@
<button type="button" name="b">Button B 2</button>
<input type="checkbox" name="c">
</form>
-
+
<form id="test-onreset-form">
<div class="clickme-testcontainer" id="test-onreset">
<input type="reset" value="click me">
@@ -279,6 +279,8 @@
<p>I have <b title="I have attributes">content</b></p>
</div>
+<p class="testcontainer" id="test-compat-mode">Compat Mode:</p>
+
<div class="testcontainer" id="test-clone-node-listeners">
<input id="test-clone-node-clickable" type="checkbox">
</div>
@@ -2163,6 +2165,12 @@
pass('test-clone-node-custom-attrs');
});
+jsunitRegister('testCompatMode',
+ function testCompatMode() {
+ assertEquals('CSS1Compat', document.compatMode);
+ pass('test-compat-mode');
+});
+
jsunitRegister('testCustomEvents',
function testCustomEvents() {
assertTrue(!!document.createEvent);
@@ -2792,12 +2800,12 @@
}
}
-jsunitRegister('testXhrModuleLoader',
+jsunitRegister('testXhrModuleLoader',
function testXhrModuleLoader() {
testAsyncModuleLoader(xhrModuleLoad, xhrIncludeScript, "xhr");
});
-jsunitRegister('testScriptModuleLoader',
+jsunitRegister('testScriptModuleLoader',
function testScriptModuleLoader() {
testAsyncModuleLoader(scriptModuleLoad, scriptIncludeScript, "script");
});
@@ -2807,14 +2815,14 @@
if (!valijaMode) {
var m = load.async('foo/b.co');
var f1 = function(module) {
- var r = module({x: 1, y: 2, load: { async: function(src)
- { return load.async('foo/' + src); } },
+ var r = module({x: 1, y: 2, load: { async: function(src)
+ { return load.async('foo/' + src); } },
Q: Q, fail: fail});
- Q.when(r, function(result) {
+ Q.when(r, function(result) {
assertEquals(result, 5);
pass(prefix + '-module-loader-2');
},
- function(reason) {
+ function(reason) {
fail("Waiting for result failed, " + reason);
});
};
@@ -2824,15 +2832,15 @@
Q.when(m, f1, f2);
} else {
pass(prefix + '-module-loader-2');
- }
+ }
}
-jsunitRegister('testXhrModuleLoader2',
+jsunitRegister('testXhrModuleLoader2',
function testXhrModuleLoader2() {
testAsyncModuleLoader2(xhrModuleLoad, "xhr");
});
-jsunitRegister('testScriptModuleLoader2',
+jsunitRegister('testScriptModuleLoader2',
function testScriptModuleLoader2() {
testAsyncModuleLoader2(scriptModuleLoad, "script");
});
@@ -2842,21 +2850,20 @@
var f1 = function(module) {
fail('It should not be resolved.');
};
-
+
var f2 = function(reason) {
- if (reason.substring(0, 22) === 'Retrieving the module ') {
+ if (reason.substring(0, 22) === 'Retrieving the module ') {
pass(prefix + '-module-loader-failure');
}
};
-
+
if (!valijaMode) {
var m = xhrModuleLoad.async('b.co');
Q.when(m, f1, f2);
- }
- else {
+ } else {
var m = xhrIncludeScript.async('foo/x.vo');
Q.when(m, f1, f2);
- }
+ }
}
jsunitRegister('testXhrModuleLoaderFailure',
@@ -2876,15 +2883,15 @@
var m = scriptModuleLoad.async('recursion.co');
var f1 = function(module) {
var r = module({x: 5, load: scriptModuleLoad, Q: Q});
- Q.when(r, function(result) {
+ Q.when(r, function(result) {
assertEquals(result, 120);
pass('recursive-module');
},
- function(reason) {
+ function(reason) {
fail("Waiting for result failed, " + reason);
});
};
- var f2 = function(reason) {
+ var f2 = function(reason) {
fail("Loading module Recursion failed, " + reason);
};
Q.when(m, f1, f2);