From d5afde88c92f40f2c60e1a91f0c6cdebed89277c Mon Sep 17 00:00:00 2001 From: Timo Tijhof Date: Thu, 10 Jul 2014 14:55:04 +0200 Subject: [PATCH] Update Sinon.JS to 1.10.3 Sinon.JS 1.10.2 had a regression causing a fatal https://github.com/cjohansen/Sinon.JS/issues/506 Fixed in version 1.10.3. Source code: http://sinonjs.org/releases/sinon-1.10.3.js http://sinonjs.org/releases/sinon-ie-1.10.3.js Change log: https://github.com/cjohansen/Sinon.JS/blob/v1.10.3/Changelog.txt#L1-L25 Change-Id: Ib667afc89c54b435b9d37e0d83a9aacdc7bb9807 --- RELEASE-NOTES-1.24 | 1 + .../{sinon-1.9.0.js => sinon-1.10.3.js} | 453 ++++++++++++++---- .../{sinon-ie-1.9.0.js => sinon-ie-1.10.3.js} | 16 +- tests/qunit/QUnitTestResources.php | 4 +- 4 files changed, 384 insertions(+), 90 deletions(-) rename resources/lib/sinonjs/{sinon-1.9.0.js => sinon-1.10.3.js} (91%) rename resources/lib/sinonjs/{sinon-ie-1.9.0.js => sinon-ie-1.10.3.js} (86%) diff --git a/RELEASE-NOTES-1.24 b/RELEASE-NOTES-1.24 index 656cd5430a..ec31355f41 100644 --- a/RELEASE-NOTES-1.24 +++ b/RELEASE-NOTES-1.24 @@ -109,6 +109,7 @@ production. permission needs to be set for 'pagelang'. * Upgrade Moment.js to v2.7.0. * (bug 67042) Added support for the HTML5 tag for East Asian typography. +* Upgrade Sinon.JS to 1.10.3. === Bug fixes in 1.24 === * (bug 49116) Footer copyright notice is now always displayed in user language diff --git a/resources/lib/sinonjs/sinon-1.9.0.js b/resources/lib/sinonjs/sinon-1.10.3.js similarity index 91% rename from resources/lib/sinonjs/sinon-1.9.0.js rename to resources/lib/sinonjs/sinon-1.10.3.js index 574e617ae7..703414dd49 100644 --- a/resources/lib/sinonjs/sinon-1.9.0.js +++ b/resources/lib/sinonjs/sinon-1.10.3.js @@ -1,5 +1,5 @@ /** - * Sinon.JS 1.9.0, 2014/03/05 + * Sinon.JS 1.10.3, 2014/07/11 * * @author Christian Johansen (christian@cjohansen.no) * @author Contributors: https://github.com/cjohansen/Sinon.JS/blob/master/AUTHORS @@ -35,8 +35,8 @@ this.sinon = (function () { var samsam, formatio; -function define(mod, deps, fn) { if (mod == "samsam") { samsam = deps(); } else { formatio = fn(samsam); } } -define.amd = true; +function define(mod, deps, fn) { if (mod == "samsam") { samsam = deps(); } else if (typeof fn === "function") { formatio = fn(samsam); } } +define.amd = {}; ((typeof define === "function" && define.amd && function (m) { define("samsam", m); }) || (typeof module === "object" && function (m) { module.exports = m(); }) || // Node @@ -655,6 +655,10 @@ var sinon = (function (formatio) { return typeof obj === "function" || !!(obj && obj.constructor && obj.call && obj.apply); } + function isReallyNaN(val) { + return typeof val === 'number' && isNaN(val); + } + function mirrorProperties(target, source) { for (var prop in source) { if (!hasOwn.call(target, prop)) { @@ -683,19 +687,15 @@ var sinon = (function (formatio) { if (!isFunction(wrappedMethod)) { error = new TypeError("Attempted to wrap " + (typeof wrappedMethod) + " property " + property + " as function"); - } - - if (wrappedMethod.restore && wrappedMethod.restore.sinon) { + } else if (wrappedMethod.restore && wrappedMethod.restore.sinon) { error = new TypeError("Attempted to wrap " + property + " which is already wrapped"); - } - - if (wrappedMethod.calledBefore) { + } else if (wrappedMethod.calledBefore) { var verb = !!wrappedMethod.returns ? "stubbed" : "spied on"; error = new TypeError("Attempted to wrap " + property + " which is already " + verb); } if (error) { - if (wrappedMethod._stack) { + if (wrappedMethod && wrappedMethod._stack) { error.stack += '\n--------------\n' + wrappedMethod._stack; } throw error; @@ -756,8 +756,13 @@ var sinon = (function (formatio) { if (sinon.match && sinon.match.isMatcher(a)) { return a.test(b); } - if (typeof a != "object" || typeof b != "object") { - return a === b; + + if (typeof a != 'object' || typeof b != 'object') { + if (isReallyNaN(a) && isReallyNaN(b)) { + return true; + } else { + return a === b; + } } if (isElement(a) || isElement(b)) { @@ -773,7 +778,7 @@ var sinon = (function (formatio) { } if (a instanceof RegExp && b instanceof RegExp) { - return (a.source === b.source) && (a.global === b.global) && + return (a.source === b.source) && (a.global === b.global) && (a.ignoreCase === b.ignoreCase) && (a.multiline === b.multiline); } @@ -795,6 +800,10 @@ var sinon = (function (formatio) { for (prop in a) { aLength += 1; + if (!(prop in b)) { + return false; + } + if (!deepEqual(a[prop], b[prop])) { return false; } @@ -940,30 +949,31 @@ var sinon = (function (formatio) { } }; - var isNode = typeof module !== "undefined" && module.exports; + var isNode = typeof module !== "undefined" && module.exports && typeof require == "function"; var isAMD = typeof define === 'function' && typeof define.amd === 'object' && define.amd; + function makePublicAPI(require, exports, module) { + module.exports = sinon; + sinon.spy = require("./sinon/spy"); + sinon.spyCall = require("./sinon/call"); + sinon.behavior = require("./sinon/behavior"); + sinon.stub = require("./sinon/stub"); + sinon.mock = require("./sinon/mock"); + sinon.collection = require("./sinon/collection"); + sinon.assert = require("./sinon/assert"); + sinon.sandbox = require("./sinon/sandbox"); + sinon.test = require("./sinon/test"); + sinon.testCase = require("./sinon/test_case"); + sinon.match = require("./sinon/match"); + } + if (isAMD) { - define(function(){ - return sinon; - }); + define(makePublicAPI); } else if (isNode) { try { formatio = require("formatio"); } catch (e) {} - module.exports = sinon; - module.exports.spy = require("./sinon/spy"); - module.exports.spyCall = require("./sinon/call"); - module.exports.behavior = require("./sinon/behavior"); - module.exports.stub = require("./sinon/stub"); - module.exports.mock = require("./sinon/mock"); - module.exports.collection = require("./sinon/collection"); - module.exports.assert = require("./sinon/assert"); - module.exports.sandbox = require("./sinon/sandbox"); - module.exports.test = require("./sinon/test"); - module.exports.testCase = require("./sinon/test_case"); - module.exports.assert = require("./sinon/assert"); - module.exports.match = require("./sinon/match"); + makePublicAPI(require, exports, module); } if (formatio) { @@ -999,7 +1009,7 @@ var sinon = (function (formatio) { */ (function (sinon) { - var commonJSModule = typeof module !== 'undefined' && module.exports; + var commonJSModule = typeof module !== "undefined" && module.exports && typeof require == "function"; if (!sinon && commonJSModule) { sinon = require("../sinon"); @@ -1222,10 +1232,12 @@ var sinon = (function (formatio) { match.regexp = match.typeOf("regexp"); match.date = match.typeOf("date"); - if (commonJSModule) { + sinon.match = match; + + if (typeof define === "function" && define.amd) { + define(["module"], function(module) { module.exports = match; }); + } else if (commonJSModule) { module.exports = match; - } else { - sinon.match = match; } }(typeof sinon == "object" && sinon || null)); @@ -1247,7 +1259,7 @@ var sinon = (function (formatio) { */ (function (sinon) { - var commonJSModule = typeof module !== 'undefined' && module.exports; + var commonJSModule = typeof module !== "undefined" && module.exports && typeof require == "function"; if (!sinon && commonJSModule) { sinon = require("../sinon"); } @@ -1424,10 +1436,12 @@ var sinon = (function (formatio) { } createSpyCall.toString = callProto.toString; // used by mocks - if (commonJSModule) { + sinon.spyCall = createSpyCall; + + if (typeof define === "function" && define.amd) { + define(["module"], function(module) { module.exports = createSpyCall; }); + } else if (commonJSModule) { module.exports = createSpyCall; - } else { - sinon.spyCall = createSpyCall; } }(typeof sinon == "object" && sinon || null)); @@ -1448,7 +1462,7 @@ var sinon = (function (formatio) { */ (function (sinon) { - var commonJSModule = typeof module !== 'undefined' && module.exports; + var commonJSModule = typeof module !== "undefined" && module.exports && typeof require == "function"; var push = Array.prototype.push; var slice = Array.prototype.slice; var callId = 0; @@ -1579,6 +1593,9 @@ var sinon = (function (formatio) { push.call(this.args, args); push.call(this.callIds, callId++); + // Make call properties available from within the spied function: + createCallProperties.call(this); + try { if (matching) { returnValue = matching.invoke(func, thisValue, args); @@ -1597,6 +1614,7 @@ var sinon = (function (formatio) { push.call(this.exceptions, exception); push.call(this.returnValues, returnValue); + // Make return value and exception available in the calls: createCallProperties.call(this); if (exception !== undefined) { @@ -1606,6 +1624,11 @@ var sinon = (function (formatio) { return returnValue; }, + named: function named(name) { + this.displayName = name; + return this; + }, + getCall: function getCall(i) { if (i < 0 || i >= this.callCount) { return null; @@ -1831,11 +1854,12 @@ var sinon = (function (formatio) { sinon.extend(spy, spyApi); spy.spyCall = sinon.spyCall; + sinon.spy = spy; - if (commonJSModule) { + if (typeof define === "function" && define.amd) { + define(["module"], function(module) { module.exports = spy; }); + } else if (commonJSModule) { module.exports = spy; - } else { - sinon.spy = spy; } }(typeof sinon == "object" && sinon || null)); @@ -1855,7 +1879,7 @@ var sinon = (function (formatio) { */ (function (sinon) { - var commonJSModule = typeof module !== 'undefined' && module.exports; + var commonJSModule = typeof module !== "undefined" && module.exports && typeof require == "function"; if (!sinon && commonJSModule) { sinon = require("../sinon"); @@ -2164,12 +2188,15 @@ var sinon = (function (formatio) { } } - if (commonJSModule) { + sinon.behavior = proto; + + if (typeof define === "function" && define.amd) { + define(["module"], function(module) { module.exports = proto; }); + } else if (commonJSModule) { module.exports = proto; - } else { - sinon.behavior = proto; } }(typeof sinon == "object" && sinon || null)); + /** * @depend ../sinon.js * @depend spy.js @@ -2187,7 +2214,7 @@ var sinon = (function (formatio) { */ (function (sinon) { - var commonJSModule = typeof module !== 'undefined' && module.exports; + var commonJSModule = typeof module !== "undefined" && module.exports && typeof require == "function"; if (!sinon && commonJSModule) { sinon = require("../sinon"); @@ -2322,10 +2349,12 @@ var sinon = (function (formatio) { return proto; }())); - if (commonJSModule) { + sinon.stub = stub; + + if (typeof define === "function" && define.amd) { + define(["module"], function(module) { module.exports = stub; }); + } else if (commonJSModule) { module.exports = stub; - } else { - sinon.stub = stub; } }(typeof sinon == "object" && sinon || null)); @@ -2345,7 +2374,7 @@ var sinon = (function (formatio) { */ (function (sinon) { - var commonJSModule = typeof module !== 'undefined' && module.exports; + var commonJSModule = typeof module !== "undefined" && module.exports && typeof require == "function"; var push = [].push; var match; @@ -2771,10 +2800,12 @@ var sinon = (function (formatio) { }; }()); - if (commonJSModule) { + sinon.mock = mock; + + if (typeof define === "function" && define.amd) { + define(["module"], function(module) { module.exports = mock; }); + } else if (commonJSModule) { module.exports = mock; - } else { - sinon.mock = mock; } }(typeof sinon == "object" && sinon || null)); @@ -2795,7 +2826,7 @@ var sinon = (function (formatio) { */ (function (sinon) { - var commonJSModule = typeof module !== 'undefined' && module.exports; + var commonJSModule = typeof module !== "undefined" && module.exports && typeof require == "function"; var push = [].push; var hasOwnProperty = Object.prototype.hasOwnProperty; @@ -2924,10 +2955,12 @@ var sinon = (function (formatio) { } }; - if (commonJSModule) { + sinon.collection = collection; + + if (typeof define === "function" && define.amd) { + define(["module"], function(module) { module.exports = collection; }); + } else if (commonJSModule) { module.exports = collection; - } else { - sinon.collection = collection; } }(typeof sinon == "object" && sinon || null)); @@ -2956,6 +2989,13 @@ if (typeof sinon == "undefined") { } (function (global) { + // node expects setTimeout/setInterval to return a fn object w/ .ref()/.unref() + // browsers, a number. + // see https://github.com/cjohansen/Sinon.JS/pull/436 + var timeoutResult = setTimeout(function() {}, 0); + var addTimerReturnsObject = typeof timeoutResult === 'object'; + clearTimeout(timeoutResult); + var id = 1; function addTimer(args, recurring) { @@ -2985,7 +3025,16 @@ if (typeof sinon == "undefined") { this.timeouts[toId].interval = delay; } - return toId; + if (addTimerReturnsObject) { + return { + id: toId, + ref: function() {}, + unref: function() {} + }; + } + else { + return toId; + } } function parseTime(str) { @@ -3051,10 +3100,18 @@ if (typeof sinon == "undefined") { }, clearTimeout: function clearTimeout(timerId) { + if (!timerId) { + // null appears to be allowed in most browsers, and appears to be relied upon by some libraries, like Bootstrap carousel + return; + } if (!this.timeouts) { this.timeouts = []; } - + // in Node, timerId is an object with .ref()/.unref(), and + // its .id field is the actual timer id. + if (typeof timerId === 'object') { + timerId = timerId.id + } if (timerId in this.timeouts) { delete this.timeouts[timerId]; } @@ -3441,7 +3498,7 @@ if (typeof sinon == "undefined") { xhr.supportsXHR = typeof xhr.GlobalXMLHttpRequest != "undefined"; xhr.workingXHR = xhr.supportsXHR ? xhr.GlobalXMLHttpRequest : xhr.supportsActiveX ? function() { return new xhr.GlobalActiveXObject("MSXML2.XMLHTTP.3.0") } : false; - xhr.supportsCORS = 'withCredentials' in (new sinon.xhr.GlobalXMLHttpRequest()); + xhr.supportsCORS = xhr.supportsXHR && 'withCredentials' in (new sinon.xhr.GlobalXMLHttpRequest()); /*jsl:ignore*/ var unsafeHeaders = { @@ -3979,7 +4036,7 @@ if (typeof sinon == "undefined") { sinon.FakeXMLHttpRequest = FakeXMLHttpRequest; -})(typeof global === "object" ? global : this); +})((function(){ return typeof global === "object" ? global : this; })()); if (typeof module !== 'undefined' && module.exports) { module.exports = sinon; @@ -4062,15 +4119,6 @@ sinon.fakeServer = (function () { return false; } - function log(response, request) { - var str; - - str = "Request:\n" + sinon.format(request) + "\n\n"; - str += "Response:\n" + sinon.format(response) + "\n\n"; - - sinon.log(str); - } - return { create: function () { var server = create(this); @@ -4123,6 +4171,15 @@ sinon.fakeServer = (function () { } }, + log: function(response, request) { + var str; + + str = "Request:\n" + sinon.format(request) + "\n\n"; + str += "Response:\n" + sinon.format(response) + "\n\n"; + + sinon.log(str); + }, + respondWith: function respondWith(method, url, body) { if (arguments.length == 1 && typeof method != "function") { this.response = responseArray(method); @@ -4178,7 +4235,7 @@ sinon.fakeServer = (function () { } if (request.readyState != 4) { - log(response, request); + sinon.fakeServer.log(response, request); request.respond(response[0], response[1], response[2]); } @@ -4298,7 +4355,7 @@ if (typeof module !== 'undefined' && module.exports) { * Copyright (c) 2010-2013 Christian Johansen */ -if (typeof module !== 'undefined' && module.exports) { +if (typeof module !== "undefined" && module.exports && typeof require == "function") { var sinon = require("../sinon"); sinon.extend(sinon, require("./util/fake_timers")); } @@ -4417,7 +4474,9 @@ if (typeof module !== 'undefined' && module.exports) { sinon.sandbox.useFakeXMLHttpRequest = sinon.sandbox.useFakeServer; - if (typeof module !== 'undefined' && module.exports) { + if (typeof define === "function" && define.amd) { + define(["module"], function(module) { module.exports = sinon.sandbox; }); + } else if (typeof module !== 'undefined' && module.exports) { module.exports = sinon.sandbox; } }()); @@ -4440,7 +4499,7 @@ if (typeof module !== 'undefined' && module.exports) { */ (function (sinon) { - var commonJSModule = typeof module !== 'undefined' && module.exports; + var commonJSModule = typeof module !== "undefined" && module.exports && typeof require == "function"; if (!sinon && commonJSModule) { sinon = require("../sinon"); @@ -4457,7 +4516,7 @@ if (typeof module !== 'undefined' && module.exports) { throw new TypeError("sinon.test needs to wrap a test function, got " + type); } - return function () { + function sinonSandboxedTest() { var config = sinon.getConfig(sinon.config); config.injectInto = config.injectIntoThis && this || config.injectInto; var sandbox = sinon.sandbox.create(config); @@ -4480,6 +4539,14 @@ if (typeof module !== 'undefined' && module.exports) { return result; }; + + if (callback.length) { + return function sinonAsyncSandboxedTest(callback) { + return sinonSandboxedTest.apply(this, arguments); + }; + } + + return sinonSandboxedTest; } test.config = { @@ -4490,10 +4557,12 @@ if (typeof module !== 'undefined' && module.exports) { useFakeServer: true }; - if (commonJSModule) { + sinon.test = test; + + if (typeof define === "function" && define.amd) { + define(["module"], function(module) { module.exports = test; }); + } else if (commonJSModule) { module.exports = test; - } else { - sinon.test = test; } }(typeof sinon == "object" && sinon || null)); @@ -4513,7 +4582,7 @@ if (typeof module !== 'undefined' && module.exports) { */ (function (sinon) { - var commonJSModule = typeof module !== 'undefined' && module.exports; + var commonJSModule = typeof module !== "undefined" && module.exports && typeof require == "function"; if (!sinon && commonJSModule) { sinon = require("../sinon"); @@ -4587,10 +4656,12 @@ if (typeof module !== 'undefined' && module.exports) { return methods; } - if (commonJSModule) { + sinon.testCase = testCase; + + if (typeof define === "function" && define.amd) { + define(["module"], function(module) { module.exports = testCase; }); + } else if (commonJSModule) { module.exports = testCase; - } else { - sinon.testCase = testCase; } }(typeof sinon == "object" && sinon || null)); @@ -4610,7 +4681,7 @@ if (typeof module !== 'undefined' && module.exports) { */ (function (sinon, global) { - var commonJSModule = typeof module !== "undefined" && module.exports; + var commonJSModule = typeof module !== "undefined" && module.exports && typeof require == "function"; var slice = Array.prototype.slice; var assert; @@ -4784,11 +4855,219 @@ if (typeof module !== 'undefined' && module.exports) { mirrorPropAsAssertion("threw", "%n did not throw exception%C"); mirrorPropAsAssertion("alwaysThrew", "%n did not always throw exception%C"); - if (commonJSModule) { + sinon.assert = assert; + + if (typeof define === "function" && define.amd) { + define(["module"], function(module) { module.exports = assert; }); + } else if (commonJSModule) { module.exports = assert; - } else { - sinon.assert = assert; } }(typeof sinon == "object" && sinon || null, typeof window != "undefined" ? window : (typeof self != "undefined") ? self : global)); +/** + * @depend ../../sinon.js + * @depend event.js + */ +/*jslint eqeqeq: false, onevar: false*/ +/*global sinon, module, require, XDomainRequest*/ +/** + * Fake XDomainRequest object + */ + +if (typeof sinon == "undefined") { + this.sinon = {}; +} +sinon.xdr = { XDomainRequest: this.XDomainRequest }; + +// wrapper for global +(function (global) { + var xdr = sinon.xdr; + xdr.GlobalXDomainRequest = global.XDomainRequest; + xdr.supportsXDR = typeof xdr.GlobalXDomainRequest != "undefined"; + xdr.workingXDR = xdr.supportsXDR ? xdr.GlobalXDomainRequest : false; + + function FakeXDomainRequest() { + this.readyState = FakeXDomainRequest.UNSENT; + this.requestBody = null; + this.requestHeaders = {}; + this.status = 0; + this.timeout = null; + + if (typeof FakeXDomainRequest.onCreate == "function") { + FakeXDomainRequest.onCreate(this); + } + } + + function verifyState(xdr) { + if (xdr.readyState !== FakeXDomainRequest.OPENED) { + throw new Error("INVALID_STATE_ERR"); + } + + if (xdr.sendFlag) { + throw new Error("INVALID_STATE_ERR"); + } + } + + function verifyRequestSent(xdr) { + if (xdr.readyState == FakeXDomainRequest.UNSENT) { + throw new Error("Request not sent"); + } + if (xdr.readyState == FakeXDomainRequest.DONE) { + throw new Error("Request done"); + } + } + + function verifyResponseBodyType(body) { + if (typeof body != "string") { + var error = new Error("Attempted to respond to fake XDomainRequest with " + + body + ", which is not a string."); + error.name = "InvalidBodyException"; + throw error; + } + } + + sinon.extend(FakeXDomainRequest.prototype, sinon.EventTarget, { + open: function open(method, url) { + this.method = method; + this.url = url; + + this.responseText = null; + this.sendFlag = false; + + this.readyStateChange(FakeXDomainRequest.OPENED); + }, + + readyStateChange: function readyStateChange(state) { + this.readyState = state; + var eventName = ''; + switch (this.readyState) { + case FakeXDomainRequest.UNSENT: + break; + case FakeXDomainRequest.OPENED: + break; + case FakeXDomainRequest.LOADING: + if (this.sendFlag){ + //raise the progress event + eventName = 'onprogress'; + } + break; + case FakeXDomainRequest.DONE: + if (this.isTimeout){ + eventName = 'ontimeout' + } + else if (this.errorFlag || (this.status < 200 || this.status > 299)) { + eventName = 'onerror'; + } + else { + eventName = 'onload' + } + break; + } + + // raising event (if defined) + if (eventName) { + if (typeof this[eventName] == "function") { + try { + this[eventName](); + } catch (e) { + sinon.logError("Fake XHR " + eventName + " handler", e); + } + } + } + }, + + send: function send(data) { + verifyState(this); + + if (!/^(get|head)$/i.test(this.method)) { + this.requestBody = data; + } + this.requestHeaders["Content-Type"] = "text/plain;charset=utf-8"; + + this.errorFlag = false; + this.sendFlag = true; + this.readyStateChange(FakeXDomainRequest.OPENED); + + if (typeof this.onSend == "function") { + this.onSend(this); + } + }, + + abort: function abort() { + this.aborted = true; + this.responseText = null; + this.errorFlag = true; + + if (this.readyState > sinon.FakeXDomainRequest.UNSENT && this.sendFlag) { + this.readyStateChange(sinon.FakeXDomainRequest.DONE); + this.sendFlag = false; + } + }, + + setResponseBody: function setResponseBody(body) { + verifyRequestSent(this); + verifyResponseBodyType(body); + + var chunkSize = this.chunkSize || 10; + var index = 0; + this.responseText = ""; + + do { + this.readyStateChange(FakeXDomainRequest.LOADING); + this.responseText += body.substring(index, index + chunkSize); + index += chunkSize; + } while (index < body.length); + + this.readyStateChange(FakeXDomainRequest.DONE); + }, + + respond: function respond(status, contentType, body) { + // content-type ignored, since XDomainRequest does not carry this + // we keep the same syntax for respond(...) as for FakeXMLHttpRequest to ease + // test integration across browsers + this.status = typeof status == "number" ? status : 200; + this.setResponseBody(body || ""); + }, + + simulatetimeout: function(){ + this.status = 0; + this.isTimeout = true; + // Access to this should actually throw an error + this.responseText = undefined; + this.readyStateChange(FakeXDomainRequest.DONE); + } + }); + + sinon.extend(FakeXDomainRequest, { + UNSENT: 0, + OPENED: 1, + LOADING: 3, + DONE: 4 + }); + + sinon.useFakeXDomainRequest = function () { + sinon.FakeXDomainRequest.restore = function restore(keepOnCreate) { + if (xdr.supportsXDR) { + global.XDomainRequest = xdr.GlobalXDomainRequest; + } + + delete sinon.FakeXDomainRequest.restore; + + if (keepOnCreate !== true) { + delete sinon.FakeXDomainRequest.onCreate; + } + }; + if (xdr.supportsXDR) { + global.XDomainRequest = sinon.FakeXDomainRequest; + } + return sinon.FakeXDomainRequest; + }; + + sinon.FakeXDomainRequest = FakeXDomainRequest; +})(this); + +if (typeof module == "object" && typeof require == "function") { + module.exports = sinon; +} + return sinon;}.call(typeof window != 'undefined' && window || {})); diff --git a/resources/lib/sinonjs/sinon-ie-1.9.0.js b/resources/lib/sinonjs/sinon-ie-1.10.3.js similarity index 86% rename from resources/lib/sinonjs/sinon-ie-1.9.0.js rename to resources/lib/sinonjs/sinon-ie-1.10.3.js index c9fbd9da2e..de8c23d1d1 100644 --- a/resources/lib/sinonjs/sinon-ie-1.9.0.js +++ b/resources/lib/sinonjs/sinon-ie-1.10.3.js @@ -1,5 +1,5 @@ /** - * Sinon.JS 1.9.0, 2014/03/05 + * Sinon.JS 1.10.3, 2014/07/11 * * @author Christian Johansen (christian@cjohansen.no) * @author Contributors: https://github.com/cjohansen/Sinon.JS/blob/master/AUTHORS @@ -84,3 +84,17 @@ function XMLHttpRequest() {} // Reassign the original function. Now its writable attribute // should be true. Hackish, I know, but it works. XMLHttpRequest = sinon.xhr.XMLHttpRequest || undefined; +/*global sinon*/ +/** + * Helps IE run the fake XDomainRequest. By defining global functions, IE allows + * them to be overwritten at a later point. If these are not defined like + * this, overwriting them will result in anything from an exception to browser + * crash. + * + * If you don't require fake XDR to work in IE, don't include this file. + */ +function XDomainRequest() {} + +// Reassign the original function. Now its writable attribute +// should be true. Hackish, I know, but it works. +XDomainRequest = sinon.xdr.XDomainRequest || undefined; diff --git a/tests/qunit/QUnitTestResources.php b/tests/qunit/QUnitTestResources.php index b2b5322bd6..34007eda56 100644 --- a/tests/qunit/QUnitTestResources.php +++ b/tests/qunit/QUnitTestResources.php @@ -8,14 +8,14 @@ return array( 'test.sinonjs' => array( 'scripts' => array( - 'resources/lib/sinonjs/sinon-1.9.0.js', + 'resources/lib/sinonjs/sinon-1.10.3.js', // We want tests to work in IE, but can't include this as it // will break the placeholders in Sinon because the hack it uses // to hijack IE globals relies on running in the global scope // and in ResourceLoader this won't be running in the global scope. // Including it results (among other things) in sandboxed timers // being broken due to Date inheritance being undefined. - // 'resources/lib/sinonjs/sinon-ie-1.9.0.js', + // 'resources/lib/sinonjs/sinon-ie-1.10.3.js', ), 'targets' => array( 'desktop', 'mobile' ), ), -- 2.20.1