Comparing version 1.16.1 to 1.17.0
@@ -0,1 +1,13 @@ | ||
1.7.0 / 2015-09-22 | ||
================== | ||
* Fix #821 where Sinon.JS would leak a setImmdiate into global scope | ||
* Removed sinon-timers from the build. refs #811 | ||
* Added flag that, when set to true, makes sinon.logError throw errors synchronously. | ||
* Fix #777: Support non-enumerable props when stubbing objects | ||
* Made the sinon.test() function pass on errors to the callback | ||
* Expand conversion from ArrayBuffer to binary string | ||
* Add support for ArrayBuffer, blob responseTypes | ||
1.16.1 / 2015-08-20 | ||
@@ -2,0 +14,0 @@ =================== |
@@ -19,2 +19,3 @@ /** | ||
require("./sinon/extend"); | ||
require("./sinon/walk"); | ||
require("./sinon/typeOf"); | ||
@@ -21,0 +22,0 @@ require("./sinon/times_in_words"); |
@@ -27,2 +27,7 @@ /** | ||
function throwLoggedError() { | ||
err.message = msg + err.message; | ||
throw err; | ||
} | ||
sinon.log(msg + "[" + err.name + "] " + err.message); | ||
@@ -34,8 +39,13 @@ | ||
logError.setTimeout(function () { | ||
err.message = msg + err.message; | ||
throw err; | ||
}, 0); | ||
if (logError.useImmediateExceptions) { | ||
throwLoggedError(); | ||
} else { | ||
logError.setTimeout(throwLoggedError, 0); | ||
} | ||
} | ||
// When set to true, any errors logged will be thrown immediately; | ||
// If set to false, the errors will be thrown in separate execution frame. | ||
logError.useImmediateExceptions = false; | ||
// wrap realSetTimeout with something we can stub in tests | ||
@@ -42,0 +52,0 @@ logError.setTimeout = function (func, timeout) { |
@@ -6,2 +6,3 @@ /** | ||
* @depend behavior.js | ||
* @depend walk.js | ||
*/ | ||
@@ -25,4 +26,3 @@ /** | ||
var wrapper, | ||
prop; | ||
var wrapper; | ||
@@ -54,7 +54,12 @@ if (func) { | ||
if (typeof property === "undefined" && typeof object === "object") { | ||
for (prop in object) { | ||
if (typeof sinon.getPropertyDescriptor(object, prop).value === "function") { | ||
sinon.walk(object || {}, function (value, prop, propOwner) { | ||
// we don't want to stub things like toString(), valueOf(), etc. so we only stub if the object | ||
// is not Object.prototype | ||
if ( | ||
propOwner !== Object.prototype && | ||
typeof sinon.getPropertyDescriptor(propOwner, prop).value === "function" | ||
) { | ||
stub(object, prop); | ||
} | ||
} | ||
}); | ||
@@ -61,0 +66,0 @@ return object; |
@@ -38,3 +38,2 @@ /** | ||
sandbox.restore(); | ||
throw exception; | ||
} else { | ||
@@ -41,0 +40,0 @@ sandbox.verifyAndRestore(); |
@@ -37,2 +37,4 @@ /** | ||
var supportsFormData = typeof FormData !== "undefined"; | ||
var supportsArrayBuffer = typeof ArrayBuffer !== "undefined"; | ||
var supportsBlob = typeof Blob === "function"; | ||
var sinonXhr = { XMLHttpRequest: global.XMLHttpRequest }; | ||
@@ -292,15 +294,74 @@ sinonXhr.GlobalXMLHttpRequest = global.XMLHttpRequest; | ||
FakeXMLHttpRequest.parseXML = function parseXML(text) { | ||
var xmlDoc; | ||
function convertToArrayBuffer(body) { | ||
var buffer = new ArrayBuffer(body.length); | ||
var view = new Uint8Array(buffer); | ||
for (var i = 0; i < body.length; i++) { | ||
var charCode = body.charCodeAt(i); | ||
if (charCode >= 256) { | ||
throw new TypeError("arraybuffer or blob responseTypes require binary string, " + | ||
"invalid character " + body[i] + " found."); | ||
} | ||
view[i] = charCode; | ||
} | ||
return buffer; | ||
} | ||
if (typeof DOMParser !== "undefined") { | ||
var parser = new DOMParser(); | ||
xmlDoc = parser.parseFromString(text, "text/xml"); | ||
function isXmlContentType(contentType) { | ||
return !contentType || /(text\/xml)|(application\/xml)|(\+xml)/.test(contentType); | ||
} | ||
function convertResponseBody(responseType, contentType, body) { | ||
if (responseType === "" || responseType === "text") { | ||
return body; | ||
} else if (supportsArrayBuffer && responseType === "arraybuffer") { | ||
return convertToArrayBuffer(body); | ||
} else if (responseType === "json") { | ||
try { | ||
return JSON.parse(body); | ||
} catch (e) { | ||
// Return parsing failure as null | ||
return null; | ||
} | ||
} else if (supportsBlob && responseType === "blob") { | ||
var blobOptions = {}; | ||
if (contentType) { | ||
blobOptions.type = contentType; | ||
} | ||
return new Blob([convertToArrayBuffer(body)], blobOptions); | ||
} else if (responseType === "document") { | ||
if (isXmlContentType(contentType)) { | ||
return FakeXMLHttpRequest.parseXML(body); | ||
} | ||
return null; | ||
} | ||
throw new Error("Invalid responseType " + responseType); | ||
} | ||
function clearResponse(xhr) { | ||
if (xhr.responseType === "" || xhr.responseType === "text") { | ||
xhr.response = xhr.responseText = ""; | ||
} else { | ||
xmlDoc = new window.ActiveXObject("Microsoft.XMLDOM"); | ||
xmlDoc.async = "false"; | ||
xmlDoc.loadXML(text); | ||
xhr.response = xhr.responseText = null; | ||
} | ||
xhr.responseXML = null; | ||
} | ||
return xmlDoc; | ||
FakeXMLHttpRequest.parseXML = function parseXML(text) { | ||
// Treat empty string as parsing failure | ||
if (text !== "") { | ||
try { | ||
if (typeof DOMParser !== "undefined") { | ||
var parser = new DOMParser(); | ||
return parser.parseFromString(text, "text/xml"); | ||
} | ||
var xmlDoc = new window.ActiveXObject("Microsoft.XMLDOM"); | ||
xmlDoc.async = "false"; | ||
xmlDoc.loadXML(text); | ||
return xmlDoc; | ||
} catch (e) { | ||
// Unable to parse XML - no biggie | ||
} | ||
} | ||
return null; | ||
}; | ||
@@ -365,5 +426,3 @@ | ||
this.password = password; | ||
this.responseText = null; | ||
this.response = this.responseType === "json" ? null : ""; | ||
this.responseXML = null; | ||
clearResponse(this); | ||
this.requestHeaders = {}; | ||
@@ -462,3 +521,3 @@ this.sendFlag = false; | ||
this.sendFlag = this.async; | ||
this.response = this.responseType === "json" ? null : ""; | ||
clearResponse(this); | ||
this.readyStateChange(FakeXMLHttpRequest.OPENED); | ||
@@ -475,4 +534,3 @@ | ||
this.aborted = true; | ||
this.responseText = null; | ||
this.response = this.responseType === "json" ? null : ""; | ||
clearResponse(this); | ||
this.errorFlag = true; | ||
@@ -533,28 +591,30 @@ this.requestHeaders = {}; | ||
verifyResponseBodyType(body); | ||
var contentType = this.getResponseHeader("Content-Type"); | ||
var chunkSize = this.chunkSize || 10; | ||
var index = 0; | ||
this.responseText = ""; | ||
var isTextResponse = this.responseType === "" || this.responseType === "text"; | ||
clearResponse(this); | ||
if (this.async) { | ||
var chunkSize = this.chunkSize || 10; | ||
var index = 0; | ||
do { | ||
if (this.async) { | ||
do { | ||
this.readyStateChange(FakeXMLHttpRequest.LOADING); | ||
} | ||
this.responseText += body.substring(index, index + chunkSize); | ||
index += chunkSize; | ||
} while (index < body.length); | ||
if (isTextResponse) { | ||
this.responseText = this.response += body.substring(index, index + chunkSize); | ||
} | ||
index += chunkSize; | ||
} while (index < body.length); | ||
} | ||
var type = this.getResponseHeader("Content-Type"); | ||
this.response = convertResponseBody(this.responseType, contentType, body); | ||
if (isTextResponse) { | ||
this.responseText = this.response; | ||
} | ||
if (this.responseText && | ||
(!type || /(text\/xml)|(application\/xml)|(\+xml)/.test(type))) { | ||
try { | ||
this.responseXML = FakeXMLHttpRequest.parseXML(this.responseText); | ||
} catch (e) { | ||
// Unable to parse XML - no biggie | ||
} | ||
if (this.responseType === "document") { | ||
this.responseXML = this.response; | ||
} else if (this.responseType === "" && isXmlContentType(contentType)) { | ||
this.responseXML = FakeXMLHttpRequest.parseXML(this.responseText); | ||
} | ||
this.response = this.responseType === "json" ? JSON.parse(this.responseText) : this.responseText; | ||
this.readyStateChange(FakeXMLHttpRequest.DONE); | ||
@@ -561,0 +621,0 @@ }, |
{ | ||
"name": "sinon", | ||
"description": "JavaScript test spies, stubs and mocks.", | ||
"version": "1.16.1", | ||
"version": "1.17.0", | ||
"homepage": "http://sinonjs.org/", | ||
@@ -29,3 +29,3 @@ "author": "Christian Johansen", | ||
"util": ">=0.10.3 <1", | ||
"lolex": "1.3.1", | ||
"lolex": "1.3.2", | ||
"samsam": "1.1.2" | ||
@@ -35,2 +35,3 @@ }, | ||
"buster": "0.7.18", | ||
"buster-core": "^0.6.4", | ||
"buster-istanbul": "0.1.13", | ||
@@ -37,0 +38,0 @@ "eslint": "0.24.0", |
/** | ||
* Sinon.JS 1.16.1, 2015/08/20 | ||
* Sinon.JS 1.16.1, 2015/09/22 | ||
* | ||
@@ -4,0 +4,0 @@ * @author Christian Johansen (christian@cjohansen.no) |
/** | ||
* Sinon.JS 1.16.1, 2015/08/20 | ||
* Sinon.JS 1.17.0, 2015/09/22 | ||
* | ||
@@ -4,0 +4,0 @@ * @author Christian Johansen (christian@cjohansen.no) |
@@ -27,3 +27,3 @@ # Sinon.JS | ||
If you have questions that are not covered by the documentation, please post them to the [Sinon.JS mailinglist](http://groups.google.com/group/sinonjs) or drop by <a href="irc://irc.freenode.net:6667/sinon.js">#sinon.js on irc.freenode.net:6667</a> | ||
If you have questions that are not covered by the documentation, please post them to the [Sinon.JS mailing list](http://groups.google.com/group/sinonjs) or drop by <a href="irc://irc.freenode.net:6667/sinon.js">#sinon.js on irc.freenode.net:6667</a> | ||
@@ -30,0 +30,0 @@ ### Important: AMD needs pre-built version |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1053401
25970
7
6
8
+ Addedlolex@1.3.2(transitive)
- Removedlolex@1.3.1(transitive)
Updatedlolex@1.3.2