Skip to content
Browse files

global xhr constructor options can now be set ( for system xhr in b2g)

  • Loading branch information...
1 parent 5a97196 commit 08a6ce10660e4436d48ad85075d6d092431b426e @lightsofapollo lightsofapollo committed Jul 20, 2012
Showing with 35 additions and 3 deletions.
  1. +1 −0 lib/caldav/resources/calendar.js
  2. +8 −3 lib/caldav/xhr.js
  3. +2 −0 scripts/connect
  4. +23 −0 test/caldav/xhr_test.js
  5. +1 −0 test/support/fake_xhr.js
View
1 lib/caldav/resources/calendar.js
@@ -34,6 +34,7 @@
'calendar-description': 'description',
'getctag': 'ctag',
+ 'getlastmodified': 'lastmodified',
'resourcetype': {
field: 'resourcetype',
View
11 lib/caldav/xhr.js
@@ -41,8 +41,7 @@
}
Xhr.prototype = {
- /** @scope Caldav.Xhr.prototype */
-
+ globalXhrOptions: null,
xhrClass: Native,
method: 'GET',
async: true,
@@ -79,7 +78,13 @@
callback = this.callback;
}
- xhr = this.xhr = new this.xhrClass();
+ if (this.globalXhrOptions) {
+ xhr = new this.xhrClass(this.globalXhrOptions);
+ } else {
+ xhr = new this.xhrClass();
+ }
+
+ this.xhr = xhr;
if (Xhr.authHack) {
xhr.open(this.method, this.url, this.async);
View
2 scripts/connect
@@ -50,6 +50,8 @@ function getCalendarDetails(caluri) {
resources.prop(['caldav', 'calendar-timezone']);
resources.prop('displayname');
resources.prop('resourcetype');
+ resources.prop('getlastmodified');
+ resources.prop('current-user-privilege-set')
resources.prop(['calserver', 'getctag']);
// found calendar home find calendars.
View
23 test/caldav/xhr_test.js
@@ -24,6 +24,29 @@ suite('webacls/xhr', function() {
assert.equal(subject.method, 'POST');
});
+ suite('with global args', function() {
+ var old;
+ var opts = { system: true };
+
+ setup(function() {
+ var old = Xhr.prototype.globalXhrOptions;
+ Xhr.prototype.globalXhrOptions = opts;
+ });
+
+ teardown(function() {
+ Xhr.prototype.globalXhrOptions = old;
+ });
+
+ test('constructed xhr', function() {
+ var subject = new Xhr({
+ method: 'POST',
+ xhrClass: FakeXhr
+ });
+ subject.send(function() {});
+ assert.ok(subject.xhr);
+ assert.equal(subject.xhr.constructorArgs[0], opts);
+ });
+ });
});
suite('.abort', function() {
View
1 test/support/fake_xhr.js
@@ -5,6 +5,7 @@
this.sendArgs = null;
this.headers = {};
this.responseHeaders = {};
+ this.constructorArgs = arguments;
FakeXhr.instances.push(this);
}

0 comments on commit 08a6ce1

Please sign in to comment.
Something went wrong with that request. Please try again.