Reviewers: felix8a,
Description:
Opera supports both addEventListener and attachEvent but events
created using the DOM standard mechanism can only be dispatched to
listeners added using addEventListener.
Please review this at http://codereview.appspot.com/167059
Affected files:
M src/com/google/caja/plugin/bridal.js
M tests/com/google/caja/plugin/domita_test.html
M tests/com/google/caja/plugin/domita_test_untrusted.html
M tests/com/google/caja/plugin/jsunit.js
Index: tests/com/google/caja/plugin/domita_test.html
===================================================================
--- tests/com/google/caja/plugin/domita_test.html (revision 3895)
+++ tests/com/google/caja/plugin/domita_test.html (working copy)
@@ -193,6 +193,10 @@
}
var isValija = /[&?]valija([=&]|$)/.test(location.search);
+ var filter = /[&?]filter=([^&]+)/.exec(location.search);
+ if (filter) {
+ jsunitFilter(new RegExp(decodeURIComponent(filter[1])));
+ }
function moduleIdResolver(base, input) {
return defaultModuleIdResolver(base, input + '.out.js');
Index: tests/com/google/caja/plugin/jsunit.js
===================================================================
--- tests/com/google/caja/plugin/jsunit.js (revision 3895)
+++ tests/com/google/caja/plugin/jsunit.js (working copy)
@@ -126,6 +126,10 @@
jsunit.popTestId();
}
+function jsunitFilter(filter) {
+ jsunitFilter.filter = filter;
+}
+
/** Run tests. */
function jsunitRun(opt_testNames) {
document.title += ' (' + (navigator.appName
@@ -133,11 +137,14 @@
: navigator.userAgent) + ')';
jsunit.originalTitle = document.title;
+ var filter = jsunitFilter.filter || /.?/;
var testNames = [];
for (var k in jsunit.tests) {
if (jsunit.tests.hasOwnProperty(k)) {
if (!opt_testNames || arrayContains(arguments, k)) {
- testNames.push(k);
+ if (filter.test(k)) {
+ testNames.push(k);
+ }
}
}
}
Index: tests/com/google/caja/plugin/domita_test_untrusted.html
===================================================================
--- tests/com/google/caja/plugin/domita_test_untrusted.html (revision 3895)
+++ tests/com/google/caja/plugin/domita_test_untrusted.html (working copy)
@@ -2617,7 +2617,7 @@
// Event dispatch for custom events is synchronous
var fired = false;
var myHandler = jsunitCallback(function (event) {
- assertEquals("received correct event", 'hiya', event.details);
+ assertEquals("received correct event", 'hiya', event.details);
fired = true;
});
Index: src/com/google/caja/plugin/bridal.js
===================================================================
--- src/com/google/caja/plugin/bridal.js (revision 3895)
+++ src/com/google/caja/plugin/bridal.js (working copy)
@@ -35,7 +35,7 @@
var isIE = !isOpera && navigator.userAgent.indexOf('MSIE') !== -1;
var isWebkit = !isOpera && navigator.userAgent.indexOf('WebKit') !== -1;
- var featureAttachEvent = !!(document.createElement('div').attachEvent);
+ var featureAttachEvent = !!(window.attachEvent
&& !window.addEventListener);
/**
* Does the extended form of extendedCreateElement work?
* From
http://msdn.microsoft.com/en-us/library/ms536389.aspx :<blockquote>