aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorGareth Aye <gaye@mozilla.com>2014-04-08 20:39:18 -0400
committerGareth Aye <gaye@mozilla.com>2014-04-08 20:55:13 -0400
commitb15fe723595219e0e31ec84af246446668d297c8 (patch)
tree77d5299e63ae923a20457eae50ac1353990d5752 /test
parentc197deab25d8425bdfa8d8d2feccedbb2776a48e (diff)
downloadjsCalDAV-b15fe723595219e0e31ec84af246446668d297c8.tar.gz
Bug 974554 - CalDAV parser should accept ical inside xml comments nested in <calendar-data> elements
Diffstat (limited to 'test')
-rw-r--r--test/caldav/sax/calendar_data_handler_test.js50
-rw-r--r--test/caldav/sax_test.js20
2 files changed, 45 insertions, 25 deletions
diff --git a/test/caldav/sax/calendar_data_handler_test.js b/test/caldav/sax/calendar_data_handler_test.js
index 867cbe3..9f33192 100644
--- a/test/caldav/sax/calendar_data_handler_test.js
+++ b/test/caldav/sax/calendar_data_handler_test.js
@@ -34,33 +34,39 @@ suite('caldav/sax/calendar_data_handler', function() {
};
});
- suite('ontext', function() {
- var originalHandler;
+ // Should treat text and xml character data the same.
+ [
+ 'ontext',
+ 'oncdata'
+ ].forEach(function(nodetype) {
+ suite(nodetype, function() {
+ var originalHandler;
- suiteSetup(function() {
- originalHandler = Handler.parseICAL;
- });
+ suiteSetup(function() {
+ originalHandler = Handler.parseICAL;
+ });
- teardown(function() {
- Handler.parseICAL = originalHandler;
- });
+ teardown(function() {
+ Handler.parseICAL = originalHandler;
+ });
- test('without handler', function() {
- callProxy('ontext', 'foo');
- assert.equal(proxy.current[0], 'foo');
- });
- test('with handler', function() {
- var calledWith;
- Handler.parseICAL = function() {
- calledWith = arguments;
- return 'hit';
- }
+ test('without handler', function() {
+ callProxy(nodetype, 'foo');
+ assert.equal(proxy.current[0], 'foo');
+ });
- callProxy('ontext', 'baz');
- assert.deepEqual(calledWith, ['baz']);
- assert.equal(proxy.current[0], 'hit');
+ test('with handler', function() {
+ var calledWith;
+ Handler.parseICAL = function() {
+ calledWith = arguments;
+ return 'hit';
+ };
+
+ callProxy(nodetype, 'baz');
+ assert.deepEqual(calledWith, ['baz']);
+ assert.equal(proxy.current[0], 'hit');
+ });
});
});
});
-
diff --git a/test/caldav/sax_test.js b/test/caldav/sax_test.js
index 8896abf..a175cdd 100644
--- a/test/caldav/sax_test.js
+++ b/test/caldav/sax_test.js
@@ -15,6 +15,7 @@ suite('caldav/sax', function() {
// to make testing easier.
function TestHander() {
this.text = [];
+ this.cdata = [];
this.opentag = [];
this.closetag = [];
this.error = [];
@@ -22,9 +23,13 @@ suite('caldav/sax', function() {
this.end = [];
var events = [
- 'ontext', 'onclosetag',
- 'onopentag', 'onerror',
- 'oncomplete', 'onend'
+ 'ontext',
+ 'oncdata',
+ 'onclosetag',
+ 'onopentag',
+ 'onerror',
+ 'oncomplete',
+ 'onend'
];
}
@@ -34,6 +39,10 @@ suite('caldav/sax', function() {
handler.text.push(data);
},
+ oncdata: function(data, handler) {
+ handler.cdata.push(data);
+ },
+
onclosetag: function(data, handler) {
handler.closetag.push(data);
},
@@ -237,6 +246,11 @@ suite('caldav/sax', function() {
firesHandler('text', 'foo');
});
+ test('#oncdata', function() {
+ subject.oncdata('foo');
+ firesHandler('cdata', 'foo');
+ });
+
test('#onerror', function() {
subject.onerror('foo');
firesHandler('error', 'foo');