From 08a6ce10660e4436d48ad85075d6d092431b426e Mon Sep 17 00:00:00 2001 From: James Lal Date: Fri, 20 Jul 2012 09:13:46 -0700 Subject: global xhr constructor options can now be set ( for system xhr in b2g) --- test/caldav/xhr_test.js | 23 +++++++++++++++++++++++ test/support/fake_xhr.js | 1 + 2 files changed, 24 insertions(+) (limited to 'test') diff --git a/test/caldav/xhr_test.js b/test/caldav/xhr_test.js index c442852..1082958 100644 --- a/test/caldav/xhr_test.js +++ b/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() { diff --git a/test/support/fake_xhr.js b/test/support/fake_xhr.js index 3f0c9d9..0ffcff8 100644 --- a/test/support/fake_xhr.js +++ b/test/support/fake_xhr.js @@ -5,6 +5,7 @@ this.sendArgs = null; this.headers = {}; this.responseHeaders = {}; + this.constructorArgs = arguments; FakeXhr.instances.push(this); } -- cgit