Socket
Socket
Sign inDemoInstall

fake-xml-http-request

Package Overview
Dependencies
0
Maintainers
4
Versions
15
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.0.0 to 2.0.1

test/readyStateChange_test.js

2

bower.json
{
"name": "fake-xml-http-request",
"version": "2.0.0",
"version": "2.0.1",
"main": [

@@ -5,0 +5,0 @@ "./fake_xml_http_request.js"

# FakeXMLHttpRequest Changelog
## 2.0.1
[#42](https://github.com/pretenderjs/FakeXMLHttpRequest/pull/42) Adds better supported for aborted fetches
[#43](https://github.com/pretenderjs/FakeXMLHttpRequest/pull/43) Adds `url` to responses for better Fetch
## 1.4.0
* [#23](https://github.com/pretenderjs/FakeXMLHttpRequest/pull/23) Adds an `overrideMimeType` method.
* [#23](https://github.com/pretenderjs/FakeXMLHttpRequest/pull/23) Adds an `overrideMimeType` method.

@@ -246,2 +246,3 @@ (function (global, factory) {

this.responseXML = null;
this.responseURL = url;
this.requestHeaders = {};

@@ -311,12 +312,11 @@ this.sendFlag = false;

this.dispatchEvent(new _Event("abort", false, false, this));
if (this.readyState > FakeXMLHttpRequest.UNSENT && this.sendFlag) {
this._readyStateChange(FakeXMLHttpRequest.DONE);
this._readyStateChange(FakeXMLHttpRequest.UNSENT);
this.sendFlag = false;
}
this.readyState = FakeXMLHttpRequest.UNSENT;
this.dispatchEvent(new _Event("abort", false, false, this));
if (typeof this.onerror === "function") {
this.onerror();
this.onerror();
}

@@ -392,2 +392,4 @@ },

this.dispatchEvent(new _Event("load", false, false, this));
}
if (this.readyState == FakeXMLHttpRequest.UNSENT || this.readyState == FakeXMLHttpRequest.DONE) {
this.dispatchEvent(new _Event("loadend", false, false, this));

@@ -394,0 +396,0 @@ }

{
"name": "fake-xml-http-request",
"version": "2.0.0",
"version": "2.0.1",
"description": "test infrastructure for a fake XMLHttpRequest object",
"main": "fake_xml_http_request.js",
"module": "./src/fake-xml-http-request.js",
"repository": "https://github.com/trek/FakeXMLHttpRequest.git",

@@ -7,0 +8,0 @@ "scripts": {

@@ -240,2 +240,3 @@ /**

this.responseXML = null;
this.responseURL = url;
this.requestHeaders = {};

@@ -305,12 +306,11 @@ this.sendFlag = false;

this.dispatchEvent(new _Event("abort", false, false, this));
if (this.readyState > FakeXMLHttpRequest.UNSENT && this.sendFlag) {
this._readyStateChange(FakeXMLHttpRequest.DONE);
this._readyStateChange(FakeXMLHttpRequest.UNSENT);
this.sendFlag = false;
}
this.readyState = FakeXMLHttpRequest.UNSENT;
this.dispatchEvent(new _Event("abort", false, false, this));
if (typeof this.onerror === "function") {
this.onerror();
this.onerror();
}

@@ -386,2 +386,4 @@ },

this.dispatchEvent(new _Event("load", false, false, this));
}
if (this.readyState == FakeXMLHttpRequest.UNSENT || this.readyState == FakeXMLHttpRequest.DONE) {
this.dispatchEvent(new _Event("loadend", false, false, this));

@@ -388,0 +390,0 @@ }

@@ -57,1 +57,29 @@ var xhr;

});
test("does not call the onload event", function(){
var wasCalled = false;
xhr.onload = function() {
wasCalled = true;
};
xhr.open("POST", "/");
xhr.send("data");
xhr.abort();
notOk(wasCalled);
});
test("calls the loadend event", function(){
var wasCalled = false;
xhr.onloadend = function() {
wasCalled = true;
};
xhr.open("POST", "/");
xhr.send("data");
xhr.abort();
ok(wasCalled);
});

@@ -51,2 +51,7 @@ var xhr;

test("initializes the responseURL as the opened url", function(){
xhr.open('get', '/some/url');
equal(xhr.responseURL, '/some/url');
});
test("initializes the requestHeaders property as empty object", function(){

@@ -53,0 +58,0 @@ xhr.open('get', '/some/url');

@@ -76,2 +76,14 @@ var xhr, xmlDocumentConstructor;

test("calls the onloadend callback once", function(){
var wasCalled = 0;
xhr.onloadend = function(ev){
wasCalled += 1;
};
xhr.respond(200, {}, "");
strictEqual(wasCalled, 1);
});
test("passes event target as context to onload", function() {

@@ -78,0 +90,0 @@ var context;

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc