Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

dojo

Package Overview
Dependencies
Maintainers
3
Versions
104
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dojo - npm Package Compare versions

Comparing version 1.14.2 to 1.15.0

4

_base/kernel.js

@@ -82,3 +82,3 @@ define(["../global", "../has", "./config", "require", "module"], function(global, has, config, require, module){

var rev = "$Rev: d6e8ff38 $".match(/[0-9a-f]{7,}/);
var rev = "$Rev:$".match(/[0-9a-f]{7,}/);
dojo.version = {

@@ -96,3 +96,3 @@ // summary:

major: 1, minor: 14, patch: 2, flag: "",
major: 1, minor: 15, patch: 0, flag: "",
revision: rev ? rev[0] : NaN,

@@ -99,0 +99,0 @@ toString: function(){

@@ -23,3 +23,3 @@ define(["exports", "./sniff", "./_base/lang", "./dom", "./dom-style", "./dom-prop"],

className: 1,
htmlFor: has("ie"),
htmlFor: has("ie") ? 1 : 0,
value: 1

@@ -59,3 +59,3 @@ },

var lc = name.toLowerCase();
return forcePropNames[prop.names[lc] || name] || _hasAttr(dom.byId(node), attrNames[lc] || name); // Boolean
return !!forcePropNames[prop.names[lc] || name] || _hasAttr(dom.byId(node), attrNames[lc] || name); // Boolean
};

@@ -62,0 +62,0 @@

@@ -29,3 +29,3 @@ define(["./sniff", "./_base/window", "./_base/kernel"],

if(typeof id != "string"){
return id;
return id || null;
}

@@ -50,2 +50,3 @@ var _d = doc || win.doc, te = id && _d.getElementById(id);

}
return null;
};

@@ -52,0 +53,0 @@ }else{

@@ -480,2 +480,3 @@ define(["./_base/kernel", "require", "./has", "./_base/array", "./_base/config", "./_base/lang", "./has!host-browser?./_base/xhr", "./json", "module"],

var amdValue = {},
l10nCache = {},
evalBundle,

@@ -603,2 +604,7 @@

l10nName = getBundleName(moduleName, bundleName, locale);
if (l10nCache[l10nName]) {
return l10nCache[l10nName];
}
load(

@@ -612,3 +618,6 @@ l10nName,

function(result_){ result = result_; }
function(result_){
l10nCache[l10nName] = result_;
result = result_;
}
);

@@ -615,0 +624,0 @@ return result;

{
"name": "dojo",
"version": "1.14.2",
"version": "1.15.0",
"directories": {

@@ -14,3 +14,3 @@ "lib": "."

"sinon": "1.12.2",
"dojo": "1.14.2"
"dojo": "1.15.0"
},

@@ -17,0 +17,0 @@ "main": "main",

dojo
====
This is the foundation package for the Dojo 1 Toolkit. While still being maintained, new development is focused on Dojo 2.
This is the foundation package for the Dojo 1 Toolkit. While still being maintained, new development is primarily focused on modern Dojo.
Checkout the [Dojo 2 website](https://dojo.io/) or if you want a more detailed technical status and overview, checkout [`dojo/meta`](https://github.com/dojo/meta).
Checkout the [Dojo framework website](https://dojo.io/) or if you want a more detailed technical status and overview, checkout the [`Dojo roadmap`](https://dojo.io/community/).

@@ -80,2 +80,2 @@ This package is sometimes

Information](<http://dojotoolkit.org/license>). The Dojo Toolkit is Copyright
(c) 2005-2017, JS Foundation. All rights reserved.
(c) 2005-2018, JS Foundation. All rights reserved.

@@ -12,2 +12,32 @@ define([

], function(exports, RequestError, CancelError, Deferred, ioQuery, array, lang, Promise, has){
function isArrayBuffer(value) {
return has('native-arraybuffer') && value instanceof ArrayBuffer
}
function isBlob(value) {
return has('native-blob') && value instanceof Blob
}
function isFormElement(value) {
if(typeof HTMLFormElement !== 'undefined') { //all other
return value instanceof HTMLFormElement;
} else { //IE<=7
value.tagName === "FORM"
}
}
function isFormData(value) {
return has('native-formdata') && value instanceof FormData;
}
function shouldDeepCopy(value) {
return value &&
typeof value === 'object' &&
!isFormData(value) &&
!isFormElement(value) &&
!isBlob(value) &&
!isArrayBuffer(value)
}
exports.deepCopy = function(target, source) {

@@ -18,3 +48,3 @@ for (var name in source) {

if (tval !== sval) {
if (sval && typeof sval === 'object' && !(has('native-formdata') && sval instanceof FormData)) {
if (shouldDeepCopy(sval)) {
if (Object.prototype.toString.call(sval) === '[object Date]') { // use this date test to handle crossing frame boundaries

@@ -41,3 +71,4 @@ target[name] = new Date(sval);

var clonedArray = [];
source.forEach(function(svalItem) {
for (var i = 0, l = source.length; i < l; i++) {
var svalItem = source[i];
if (typeof svalItem === 'object') {

@@ -48,3 +79,4 @@ clonedArray.push(exports.deepCopy({}, svalItem));

}
});
}
return clonedArray;

@@ -151,3 +183,3 @@ };

if(data && !skipData){
if(typeof data === 'object' && (!(has('native-xhr2')) || !(data instanceof ArrayBuffer || data instanceof Blob ))){
if(typeof data === 'object' && (!(has('native-xhr2')) || !(isArrayBuffer(data) || isBlob(data) ))){
options.data = ioQuery.objectToQuery(data);

@@ -154,0 +186,0 @@ }

@@ -30,2 +30,12 @@ define([

has.add('native-blob', function(){
// if true, the environment has a native Blob implementation
return typeof Blob !== 'undefined';
});
has.add('native-arraybuffer', function(){
// if true, the environment has a native ArrayBuffer implementation
return typeof ArrayBuffer !== 'undefined';
});
has.add('native-response-type', function(){

@@ -32,0 +42,0 @@ return has('native-xhr') && typeof new XMLHttpRequest().responseType !== 'undefined';

define([
'intern!object',
'intern/chai!assert',
'../../back'
], function (registerSuite, assert, back) {
'../../back',
'../../has',
'../../sniff'
], function (registerSuite, assert, back, has) {
registerSuite({

@@ -24,2 +26,3 @@ name: 'dojo/back',

var str;
var hasMozilla = has('mozilla');

@@ -29,3 +32,7 @@ for (var i = cases.length; i--;) {

back.setHash(str);
assert.strictEqual(str, back.getHash());
if (hasMozilla) {
assert.strictEqual(str, decodeURIComponent(back.getHash()));
} else {
assert.strictEqual(str, back.getHash());
}
}

@@ -32,0 +39,0 @@ }

@@ -13,2 +13,4 @@ define([

function assertDates(date1, date2) {
assert.ok(date1, 'Date 1 does not have a value');
assert.ok(date2, 'Date 2 does not have a value.');
assert.instanceOf(date1, Date);

@@ -29,2 +31,3 @@ assert.instanceOf(date2, Date);

require(deps, dfd.resolve);
return dfd;
}

@@ -78,3 +81,3 @@

assert.equal(locale.format(date, {formatLength: 'short', selector: 'date', locale: 'de-at'}), '11.08.06');
assert.equal(locale.format(date, {formatLength: 'short', selector: 'date', locale: 'ja-jp'}), '2006/08/11');
assert.equal(locale.format(date, {formatLength: 'short', selector: 'date', locale: 'ja-jp'}), '2006\u5E748\u670811\u65E5');
},

@@ -252,16 +255,16 @@

'leading zero month': function () {
assertDates(locale.parse('06/08/11', {formatLength: 'short', selector: 'date', locale: 'ja'}), AUG_11_2006);
assertDates(locale.parse('06\u5E7408\u670811\u65E5', {formatLength: 'short', selector: 'date', locale: 'ja'}), AUG_11_2006);
},
'single digit month': function () {
assertDates(locale.parse('06/8/11', {formatLength: 'short', selector: 'date', locale: 'ja'}), AUG_11_2006);
assertDates(locale.parse('06\u5E748\u670811\u65E5', {formatLength: 'short', selector: 'date', locale: 'ja'}), AUG_11_2006);
},
'tolerate four digit year': function () {
assertDates(locale.parse('2006/8/11', {formatLength: 'short', selector: 'date', locale: 'ja'}), AUG_11_2006);
},
assertDates(locale.parse('2006\u5E748\u670811\u65E5', {formatLength: 'short', selector: 'date', locale: 'ja'}), AUG_11_2006);
}
'four digit year in strict mode returns null': function () {
assert.isNull(locale.parse('2006/8/11', {formatLength: 'short', selector: 'date', locale: 'ja', strict: true}));
}
// 'four digit year in strict mode returns null': function () {
// assert.isNull(locale.parse('2006\u5E748\u670811\u65E5', {formatLength: 'short', selector: 'date', locale: 'ja', strict: true}));
// }
},

@@ -271,7 +274,7 @@

'leading zero month': function () {
assertDates(locale.parse('2006/08/11', {formatLength: 'medium', selector: 'date', locale: 'ja'}), AUG_11_2006);
assertDates(locale.parse('2006\u5E7408\u670811\u65E5', {formatLength: 'medium', selector: 'date', locale: 'ja'}), AUG_11_2006);
},
'single digit month': function () {
assertDates(locale.parse('2006/8/11', {formatLength: 'medium', selector: 'date', locale: 'ja'}), AUG_11_2006);
assertDates(locale.parse('2006\u5E748\u670811\u65E5', {formatLength: 'medium', selector: 'date', locale: 'ja'}), AUG_11_2006);
}

@@ -278,0 +281,0 @@ },

@@ -6,4 +6,5 @@ define([

'../../dom-construct',
'../../dom-attr'
], function (registerSuite, assert, sinon, domConstruct, domAttr) {
'../../dom-attr',
'../../has'
], function (registerSuite, assert, sinon, domConstruct, domAttr, has) {
var baseId = "dom-construct",

@@ -553,3 +554,8 @@ uniqueId = 0;

//assert
assert.equal(svg.children.length, 0);
if (svg.children == null) {
// IE does not support children property on <svg>.
assert.equal(svg.innerHTML, "");
} else {
assert.equal(svg.children.length, 0);
}
}

@@ -556,0 +562,0 @@ };

@@ -8,3 +8,4 @@ define([

'../../dom-construct',
], function (registerSuite, assert, sinon, dom, has, domConstruct) {
'../../Deferred'
], function (registerSuite, assert, sinon, dom, has, domConstruct, Deferred) {

@@ -43,9 +44,18 @@ var baseId = "dojo_dom",

setTimeout(function () { //make async because FF seems to need a bit to setup the iframe's contentDocument after adding to the page
iframe.contentDocument.body.appendChild(iframeChild);
//make async because FF seems to need a bit to setup the iframe's contentDocument after adding to the page
var dfd = new Deferred();
function placeContent() {
if (iframe.contentDocument && iframe.contentDocument.body) {
iframe.contentDocument.body.appendChild(iframeChild);
node.id = nodeId;
iframeChild.id = iframeChildId;
}, 0);
node.id = nodeId;
iframeChild.id = iframeChildId;
dfd.resolve();
} else {
setTimeout(placeContent, 0);
}
}
setTimeout(placeContent, 0);
return dfd.promise;
},

@@ -208,3 +218,3 @@ teardown: function () {

} else {
assert.isTrue(node.hasAttribute("unselectable"));
assert.isFalse(node.hasAttribute("unselectable"));
}

@@ -231,3 +241,3 @@

} else {
assert.isTrue(node.hasAttribute("unselectable"));
assert.isFalse(node.hasAttribute("unselectable"));
}

@@ -254,3 +264,3 @@

} else {
assert.isFalse(node.hasAttribute("unselectable"));
assert.isTrue(node.hasAttribute("unselectable"));
}

@@ -302,6 +312,16 @@

node.appendChild(child);
setTimeout(function () { //make async because FF seems to need a bit to setup the iframe's contentDocument after adding to the page
domConstruct.place(iframeContent, iframe.contentDocument.body);
}, 0);
//make async because FF seems to need a bit to setup the iframe's contentDocument after adding to the page
var dfd = new Deferred();
function placeContent() {
if (iframe.contentDocument && iframe.contentDocument.body) {
domConstruct.place(iframeContent, iframe.contentDocument.body);
dfd.resolve();
} else {
setTimeout(placeContent, 0);
}
}
setTimeout(placeContent, 0);
return dfd.promise;
},

@@ -308,0 +328,0 @@ teardown: function () {

@@ -72,2 +72,9 @@ define([

});
},
'cached results': function () {
var l10n = i18n.getLocalization(bundlePath, 'salutations', 'en');
assert.equal(l10n.hello, 'Hello');
l10n.hello = 'test';
l10n = i18n.getLocalization(bundlePath, 'salutations', 'en');
assert.equal(l10n.hello, 'test');
}

@@ -74,0 +81,0 @@ })

@@ -11,6 +11,10 @@ define([

], function (registerSuite, assert, iframe, kernel, topic, dom, domConstruct) {
var sandbox;
function form(method, test) {
return {
setup: function () {
domConstruct.place('<form id="postTest" method="' + method + '" enctype="multipart/form-data"></form>', document.body);
delete document.__dojoToDomId;
sandbox = document.createElement('div');
document.body.appendChild(sandbox);
domConstruct.place('<form id="postTest" method="' + method + '" enctype="multipart/form-data"></form>', sandbox);
},

@@ -21,3 +25,3 @@

teardown: function () {
domConstruct.destroy('postTest');
document.body.removeChild(sandbox);
}

@@ -213,9 +217,6 @@ };

function increment() {
self._testTopicCount++;
self._testTopicCount++;
}
var handles = [
topic.subscribe('/dojo/io/start', increment),
topic.subscribe('/dojo/io/send', increment),
topic.subscribe('/dojo/io/load', increment),
topic.subscribe('/dojo/io/done', increment)
topic.subscribe('/dojo/io/load', increment)
];

@@ -234,5 +235,4 @@

topic.subscribe('/dojo/io/stop', dfd.callback(function () {
self.parent._testTopicCount++;
assert.strictEqual(self.parent._testTopicCount, 5);
topic.subscribe('/dojo/io/done', dfd.callback(function () {
assert.strictEqual(self.parent._testTopicCount, 1);
}));

@@ -239,0 +239,0 @@

@@ -43,2 +43,4 @@ define([

return function () {
delete window.tests;
var MyNonDojoClass = window.MyNonDojoClass = function () {};

@@ -270,3 +272,4 @@ MyNonDojoClass.extend = function () {

container = null;
window.foo = undefined;
delete window.foo;
delete window.tests;
}

@@ -273,0 +276,0 @@

@@ -22,2 +22,3 @@ define([

var rejectedResult;
var dfd = this.async();

@@ -37,3 +38,3 @@ deferredToResolve.promise.then(function (result) {

// Use this.async so we don't rely on the promise implementation under test
deferredToReject.promise.always(this.async().callback(function (rejectedAlwaysResult) {
deferredToReject.promise.always(dfd.callback(function (rejectedAlwaysResult) {
assert.strictEqual(resolvedResult, expectedResolvedResult);

@@ -40,0 +41,0 @@ assert.strictEqual(resolvedAlwaysResult, resolvedResult);

@@ -56,4 +56,5 @@ /* global scriptLoad, myTasks */

}).then(def.reject, def.callback(function (error) {
if (error.type) {
assert.strictEqual(error.type, 'error');
var source = error.source;
if (source.type) {
assert.strictEqual(source.type, 'error');
}

@@ -60,0 +61,0 @@ else {

define([
'intern!object',
'intern/chai!assert',
'../../../request/util'
], function (registerSuite, assert, util) {
'../../../request/util',
'../../../has',
'../../../request/xhr'
], function(registerSuite, assert, util, has){
registerSuite({
name: 'dojo/request/util',
'deepCopy': function () {
var formData = new FormData();
var object1 = {
apple: 0,
banana: {
weight: 52,
price: 100,
code: "B12345",
purchased: new Date(2016, 0, 1)
},
cherry: 97
};
var object2 = {
banana: {
price: 200,
code: "B98765",
purchased: new Date(2017, 0, 1)
},
formData: formData,
durian: 100
};
util.deepCopy(object1, object2);
'deepCopy': function(){
var object1 = {
apple: 0,
banana: {
weight: 52,
price: 100,
code: "B12345",
purchased: new Date(2016, 0, 1)
},
cherry: 97
};
var object2 = {
banana: {
price: 200,
code: "B98765",
purchased: new Date(2017, 0, 1)
},
durian: 100
};
util.deepCopy(object1, object2);
assert.strictEqual(object1.banana.weight, 52);
assert.strictEqual(object1.banana.price, 200);
assert.strictEqual(object1.banana.code, "B98765");
assert.strictEqual(object1.formData, formData);
assert.equal(object1.banana.purchased.getTime(), new Date(2017, 0, 1).getTime());
},
'deepCopy with FormData': function(){
if (has('native-formdata')) {
var formData = new FormData();
var object1 = {
apple: 0,
banana: {
weight: 52,
price: 100,
code: "B12345",
purchased: new Date(2016, 0, 1)
},
cherry: 97
};
var object2 = {
banana: {
price: 200,
code: "B98765",
purchased: new Date(2017, 0, 1)
},
formData: formData,
durian: 100
};
util.deepCopy(object1, object2);
assert.strictEqual(object1.banana.weight, 52);
assert.strictEqual(object1.banana.price, 200);
assert.strictEqual(object1.banana.code, "B98765");
assert.strictEqual(object1.formData, formData);
assert.equal(object1.banana.purchased.getTime(), new Date(2017, 0, 1).getTime());
} else {
this.skip('Do not run test if FormData not available.');
}
},
'deepCopy with Blob': function(){
if (has('native-blob')) {
var blob = new Blob([JSON.stringify({test: "data"})], {type: 'application/json'});
var object1 = {
apple: 0,
banana: {
weight: 52,
price: 100,
code: "B12345",
purchased: new Date(2016, 0, 1)
},
cherry: 97
};
var object2 = {
banana: {
price: 200,
code: "B98765",
purchased: new Date(2017, 0, 1)
},
blob: blob,
durian: 100
};
util.deepCopy(object1, object2);
assert.strictEqual(object1.banana.weight, 52);
assert.strictEqual(object1.banana.price, 200);
assert.strictEqual(object1.banana.code, "B98765");
assert.strictEqual(object1.blob, blob);
assert.equal(object1.banana.purchased.getTime(), new Date(2017, 0, 1).getTime());
} else {
this.skip('Do not run test if Blob not available.');
}
}
});
});

@@ -9,4 +9,5 @@ define([

'dojo/query',
'require'
], function (registerSuite, assert, xhr, RequestTimeoutError, CancelError, all, query, require) {
'require',
'../../../has'
], function(registerSuite, assert, xhr, RequestTimeoutError, CancelError, all, query, require, has){
var global = this;

@@ -18,5 +19,16 @@ var hasFormData = 'FormData' in this && typeof FormData === 'function';

function hasFile(){
if (typeof File !== 'undefined') {
try {
new File();
} catch (e) {
// File is not a constructor.
}
}
return false;
}
registerSuite({
name: 'dojo/request/xhr',
'.get': function () {
'.get': function(){
var promise = xhr.get('/__services/request/xhr', {

@@ -33,3 +45,3 @@ preventCache: true,

return promise.response.then(function (response) {
return promise.response.then(function(response){
assert.strictEqual(response.data.method, 'GET');

@@ -41,3 +53,3 @@ assert.strictEqual(response.xhr.readyState, 4);

'.get 404': function () {
'.get 404': function(){
var def = this.async(),

@@ -50,3 +62,3 @@ promise = xhr.get(require.toUrl('./xhr_blarg.html'), {

def.reject,
def.callback(function (error) {
def.callback(function(error){
assert.strictEqual(error.response.status, 404);

@@ -57,3 +69,3 @@ })

'.get json with truthy value': function () {
'.get json with truthy value': function(){
var def = this.async(),

@@ -66,3 +78,3 @@ promise = xhr.get(require.toUrl('./support/truthy.json'), {

promise.then(
def.callback(function (response) {
def.callback(function(response){
assert.strictEqual(response, true);

@@ -72,3 +84,3 @@ })

},
'.get json with falsy value': function () {
'.get json with falsy value': function(){
var def = this.async(),

@@ -81,3 +93,3 @@ promise = xhr.get(require.toUrl('./support/falsy.json'), {

promise.then(
def.callback(function (response) {
def.callback(function(response){
assert.strictEqual(response, false);

@@ -88,3 +100,3 @@ })

'.get with progress': function () {
'.get with progress': function(){
var def = this.async(),

@@ -95,12 +107,17 @@ promise = xhr.get(require.toUrl('./support/truthy.json'), {

});
promise.then(null, null, def.callback(function(event) {
promise.then(def.callback(
function(){
}), function(error){
assert.isTrue(false, error);
}, def.callback(function(event){
assert.strictEqual(event.transferType, 'download');
}));
return def.promise;
},
'.get with query': function () {
'.get with query': function(){
var def = this.async(),
promise = xhr.get('/__services/request/xhr?color=blue', {
query: {
foo: [ 'bar', 'baz' ],
foo: ['bar', 'baz'],
thud: 'thonk',

@@ -112,3 +129,3 @@ xyzzy: 3

promise.response.then(def.callback(function (response) {
promise.response.then(def.callback(function(response){
assert.strictEqual(response.data.method, 'GET');

@@ -125,6 +142,6 @@ var query = response.data.query;

'.post': function () {
'.post': function(){
var def = this.async(),
promise = xhr.post('/__services/request/xhr', {
data: { color: 'blue' },
data: {color: 'blue'},
handleAs: 'json'

@@ -134,3 +151,3 @@ });

promise.response.then(
def.callback(function (response) {
def.callback(function(response){
assert.strictEqual(response.data.method, 'POST');

@@ -145,118 +162,122 @@ var payload = response.data.payload;

},
'.post ArrayBuffer': function() {
if (!ArrayBuffer) {
this.skip('ArrayBuffer not available');
}
var def = this.async(),
str = 'foo',
arrbuff = new ArrayBuffer(str.length),
i8array = new Uint8Array(arrbuff);
'.post ArrayBuffer': function(){
if (has('native-arraybuffer')) {
var def = this.async(),
str = 'foo',
arrbuff = new ArrayBuffer(str.length),
i8array = new Uint8Array(arrbuff);
for (var i = 0; i < str.length; i++) {
i8array[i] = str.charCodeAt(i);
}
var promise = xhr.post('/__services/request/xhr', {
data: arrbuff,
handleAs: 'json',
headers: {
'Content-Type':'text/plain'
for (var i = 0; i < str.length; i++) {
i8array[i] = str.charCodeAt(i);
}
});
var promise = xhr.post('/__services/request/xhr', {
data: arrbuff,
handleAs: 'json',
headers: {
'Content-Type': 'text/plain'
}
});
promise.response.then(
def.callback(function (response) {
assert.strictEqual(response.data.method, 'POST');
var payload = response.data.payload;
promise.response.then(
def.callback(function(response){
assert.strictEqual(response.data.method, 'POST');
var payload = response.data.payload;
assert.deepEqual(payload, {'foo':''});
}),
def.reject
);
assert.deepEqual(payload, {'foo': ''});
}),
def.reject
);
} else {
this.skip('ArrayBuffer not available');
}
},
'.post Blob': function() {
if (!Blob) {
this.skip('Blob not available');
}
var def = this.async(),
str = 'foo',
blob = new Blob([str], {type:'text/plain'});
'.post Blob': function(){
if (has('native-blob')) {
var def = this.async(),
str = 'foo',
blob = new Blob([str], {type: 'text/plain'});
var promise = xhr.post('/__services/request/xhr', {
data: blob,
handleAs: 'json',
headers: {
'Content-Type':'text/plain'
}
});
var promise = xhr.post('/__services/request/xhr', {
data: blob,
handleAs: 'json',
headers: {
'Content-Type': 'text/plain'
}
});
promise.response.then(
def.callback(function (response) {
assert.strictEqual(response.data.method, 'POST');
var payload = response.data.payload;
promise.response.then(
def.callback(function(response){
assert.strictEqual(response.data.method, 'POST');
var payload = response.data.payload;
assert.deepEqual(payload, {'foo':''});
}),
def.reject
);
assert.deepEqual(payload, {'foo': ''});
}),
def.reject
);
} else {
this.skip('Blob not available');
}
},
'.post File': function() {
if (!File) {
this.skip('File not available');
}
var def = this.async(),
str = 'foo',
file = new File([str], 'bar.txt', {type:'text/plain'});
'.post File': function(){
if (hasFile()) {
var def = this.async(),
str = 'foo',
file = new File([str], 'bar.txt', {type: 'text/plain'});
var promise = xhr.post('/__services/request/xhr', {
data: file,
handleAs: 'json',
headers: {
'Content-Type':'text/plain'
}
});
var promise = xhr.post('/__services/request/xhr', {
data: file,
handleAs: 'json',
headers: {
'Content-Type': 'text/plain'
}
});
promise.response.then(
def.callback(function (response) {
assert.strictEqual(response.data.method, 'POST');
var payload = response.data.payload;
promise.response.then(
def.callback(function(response){
assert.strictEqual(response.data.method, 'POST');
var payload = response.data.payload;
assert.deepEqual(payload, {'foo':''});
}),
def.reject
);
assert.deepEqual(payload, {'foo': ''});
}),
def.reject
);
} else {
this.skip('File or File constructor not available');
}
},
'.post File with upload progress': function() {
if (!File) {
this.skip('File not available');
}
var def = this.async(),
str = 'foo',
file = new File([str], 'bar.txt', {type:'text/plain'});
'.post File with upload progress': function(){
if (hasFile()) {
var def = this.async(),
str = 'foo',
file = new File([str], 'bar.txt', {type: 'text/plain'});
var promise = xhr.post('/__services/request/xhr', {
data: file,
handleAs: 'json',
uploadProgress: true,
query: {
simulateProgress: true
},
headers: {
'Content-Type':'text/plain'
}
});
var promise = xhr.post('/__services/request/xhr', {
data: file,
handleAs: 'json',
uploadProgress: true,
query: {
simulateProgress: true
},
headers: {
'Content-Type': 'text/plain'
}
});
promise.then(null, def.reject, def.callback(function (progressEvent) {
assert.isDefined(progressEvent.xhr);
assert.deepEqual(progressEvent.transferType, 'upload');
}));
promise.then(null, def.reject, def.callback(function(progressEvent){
assert.isDefined(progressEvent.xhr);
assert.deepEqual(progressEvent.transferType, 'upload');
}));
} else {
this.skip('File or File constructor not available');
}
},
'.post with query': function () {
'.post with query': function(){
var def = this.async(),
promise = xhr.post('/__services/request/xhr', {
query: {
foo: [ 'bar', 'baz' ],
foo: ['bar', 'baz'],
thud: 'thonk',
xyzzy: 3
},
data: { color: 'blue' },
data: {color: 'blue'},
handleAs: 'json'

@@ -266,3 +287,3 @@ });

promise.then(
def.callback(function (data) {
def.callback(function(data){
assert.strictEqual(data.method, 'POST');

@@ -273,3 +294,3 @@ var query = data.query,

assert.ok(query);
assert.deepEqual(query.foo, [ 'bar', 'baz' ]);
assert.deepEqual(query.foo, ['bar', 'baz']);
assert.strictEqual(query.thud, 'thonk');

@@ -285,3 +306,3 @@ assert.strictEqual(query.xyzzy, '3');

'.post string payload': function () {
'.post string payload': function(){
var def = this.async(),

@@ -294,3 +315,3 @@ promise = xhr.post('/__services/request/xhr', {

promise.then(
def.callback(function (data) {
def.callback(function(data){
assert.strictEqual(data.method, 'POST');

@@ -309,7 +330,7 @@

'.put': function () {
'.put': function(){
var def = this.async(),
promise = xhr.put('/__services/request/xhr', {
query: { foo: 'bar' },
data: { color: 'blue' },
query: {foo: 'bar'},
data: {color: 'blue'},
handleAs: 'json'

@@ -319,3 +340,3 @@ });

promise.then(
def.callback(function (data) {
def.callback(function(data){
assert.strictEqual(data.method, 'PUT');

@@ -333,6 +354,6 @@

'.del': function () {
'.del': function(){
var def = this.async(),
promise = xhr.del('/__services/request/xhr', {
query: { foo: 'bar' },
query: {foo: 'bar'},
handleAs: 'json'

@@ -342,3 +363,3 @@ });

promise.then(
def.callback(function (data) {
def.callback(function(data){
assert.strictEqual(data.method, 'DELETE');

@@ -351,3 +372,3 @@ assert.strictEqual(data.query.foo, 'bar');

'timeout': function () {
'timeout': function(){
var def = this.async(),

@@ -363,3 +384,3 @@ promise = xhr.get('/__services/request/xhr', {

def.reject,
def.callback(function (error) {
def.callback(function(error){
assert.instanceOf(error, RequestTimeoutError);

@@ -370,3 +391,3 @@ })

cancel: function () {
cancel: function(){
var def = this.async(),

@@ -381,3 +402,3 @@ promise = xhr.get('/__services/request/xhr', {

def.reject,
def.callback(function (error) {
def.callback(function(error){
assert.instanceOf(error, CancelError);

@@ -389,3 +410,3 @@ })

sync: function () {
sync: function(){
var called = false;

@@ -395,3 +416,3 @@

sync: true
}).then(function () {
}).then(function(){
called = true;

@@ -403,3 +424,3 @@ });

'cross-domain fails': function () {
'cross-domain fails': function(){
var def = this.async();

@@ -409,3 +430,3 @@

def.reject,
function () {
function(){
def.resolve(true);

@@ -416,3 +437,3 @@ }

'has Content-Type with data': function () {
'has Content-Type with data': function(){
var def = this.async();

@@ -424,3 +445,3 @@

}).then(
def.callback( function (response) {
def.callback(function(response){
assert.equal(response.headers['content-type'], 'application/x-www-form-urlencoded');

@@ -432,3 +453,3 @@ }),

'no Content-Type with no data': function() {
'no Content-Type with no data': function(){
var def = this.async();

@@ -439,3 +460,3 @@

}).then(
def.callback( function (response) {
def.callback(function(response){
assert.isUndefined(response.headers['content-type']);

@@ -447,7 +468,7 @@ }),

headers: function () {
headers: function(){
var def = this.async();
xhr.get('/__services/request/xhr').response.then(
def.callback(function (response) {
def.callback(function(response){
assert.notEqual(response.getHeader('Content-Type'), null);

@@ -459,7 +480,7 @@ }),

'custom Content-Type': function () {
'custom Content-Type': function(){
var def = this.async(),
expectedContentType = 'application/x-test-xhr';
function post(headers) {
function post(headers){
return xhr.post('/__services/request/xhr', {

@@ -483,3 +504,3 @@ query: {

}).then(
def.callback(function (results) {
def.callback(function(results){
assert.match(

@@ -498,3 +519,3 @@ results.lowercase.headers['content-type'],

'queryable xml': function () {
'queryable xml': function(){
var def = this.async();

@@ -505,3 +526,3 @@

}).then(
def.callback(function (xmlDoc) {
def.callback(function(xmlDoc){
var results = query('bar', xmlDoc);

@@ -515,3 +536,3 @@

'strip fragment': function () {
'strip fragment': function(){
var def = this.async(),

@@ -521,4 +542,4 @@ promise = xhr.get('/__services/request/xhr?color=blue#some-hash', {

});
promise.response.then(def.callback(function (response) {
promise.response.then(def.callback(function(response){
assert.strictEqual(response.data.method, 'GET');

@@ -530,4 +551,6 @@ assert.strictEqual(response.data.url, '/__services/request/xhr?color=blue');

'form data': {
setup: function () {
if(!hasFormData) { return; }
setup: function(){
if (!hasFormData) {
return;
}

@@ -539,4 +562,4 @@ formData = new FormData();

post: function () {
if(!hasFormData) {
post: function(){
if (!hasFormData) {
this.skip('No FormData to test');

@@ -551,4 +574,4 @@ }

}).then(
def.callback(function (data) {
assert.deepEqual(data, { foo: 'bar', baz: 'blah' });
def.callback(function(data){
assert.deepEqual(data, {foo: 'bar', baz: 'blah'});
}),

@@ -559,3 +582,3 @@ def.reject

teardown: function () {
teardown: function(){
formData = null;

@@ -566,3 +589,3 @@ }

'response type': {
'Blob': function () {
'Blob': function(){
if (!hasResponseType) {

@@ -574,3 +597,3 @@ this.skip('No responseType to test');

handleAs: 'blob'
}).then(function (response) {
}).then(function(response){
assert.strictEqual(response.constructor, Blob);

@@ -580,3 +603,3 @@ });

'Blob POST': function () {
'Blob POST': function(){
if (!hasResponseType) {

@@ -588,3 +611,3 @@ this.skip('No responseType to test');

handleAs: 'blob'
}).then(function (response) {
}).then(function(response){
assert.strictEqual(response.constructor, Blob);

@@ -594,27 +617,27 @@ });

'ArrayBuffer': function () {
if (!hasResponseType) {
'ArrayBuffer': function(){
if (has('native-arraybuffer') && hasResponseType) {
return xhr.get('/__services/request/xhr/responseTypeGif', {
handleAs: 'arraybuffer'
}).then(function(response){
assert.strictEqual(response.constructor, ArrayBuffer);
});
} else {
this.skip('No responseType to test');
}
return xhr.get('/__services/request/xhr/responseTypeGif', {
handleAs: 'arraybuffer'
}).then(function (response) {
assert.strictEqual(response.constructor, ArrayBuffer);
});
},
'ArrayBuffer POST': function () {
if (!hasResponseType) {
'ArrayBuffer POST': function(){
if (has('native-arraybuffer') && hasResponseType) {
return xhr.post('/__services/request/xhr/responseTypeGif', {
handleAs: 'arraybuffer'
}).then(function(response){
assert.strictEqual(response.constructor, ArrayBuffer);
});
} else {
this.skip('No responseType to test');
}
return xhr.post('/__services/request/xhr/responseTypeGif', {
handleAs: 'arraybuffer'
}).then(function (response) {
assert.strictEqual(response.constructor, ArrayBuffer);
});
},
'document': function () {
'document': function(){
if (!hasResponseType) {

@@ -626,3 +649,3 @@ this.skip('No responseType to test');

handleAs: 'document'
}).then(function (response) {
}).then(function(response){
assert.strictEqual(response.constructor, document.constructor);

@@ -632,3 +655,3 @@ });

'document POST': function () {
'document POST': function(){
if (!hasResponseType) {

@@ -640,3 +663,3 @@ this.skip('No responseType to test');

handleAs: 'document'
}).then(function (response) {
}).then(function(response){
assert.strictEqual(response.constructor, document.constructor);

@@ -648,3 +671,3 @@ });

'Web Workers': {
'from blob': function () {
'from blob': function(){
if (!('URL' in global)) {

@@ -670,4 +693,4 @@ this.skip('URL is not supported');

var workerFunction = function () {
self.addEventListener('message', function (event) {
var workerFunction = function(){
self.addEventListener('message', function(event){
if (event.data.baseUrl) {

@@ -678,5 +701,5 @@ testXhr(event.data.baseUrl, event.data.testUrl);

dojoConfig = { async: true };
dojoConfig = {async: true};
function testXhr(baseUrl, testUrl) {
function testXhr(baseUrl, testUrl){
var xhr = new XMLHttpRequest();

@@ -686,3 +709,3 @@

xhr.onreadystatechange = function () {
xhr.onreadystatechange = function(){
if (xhr.readyState === 4 && xhr.status === 200) {

@@ -696,11 +719,10 @@ var blob = new Blob([xhr.response], {type: 'application/javascript'});

'dojo/request/xhr'
], function(xhr) {
xhr.get(testUrl).then(function (response) {
], function(xhr){
xhr.get(testUrl).then(function(response){
if (response === 'true') {
self.postMessage('success');
}
else {
} else {
throw new Error(response);
}
}, function (error) {
}, function(error){
throw error;

@@ -716,14 +738,13 @@ });

var blob = new Blob(['(' + workerFunction.toString()+')()'], {type: 'application/javascript'});
var blob = new Blob(['(' + workerFunction.toString() + ')()'], {type: 'application/javascript'});
var worker = new Worker(URL.createObjectURL(blob));
worker.addEventListener('error', function (error) {
worker.addEventListener('error', function(error){
dfd.reject(error);
});
worker.addEventListener('message', function (message) {
worker.addEventListener('message', function(message){
if (message.data === 'success') {
dfd.resolve();
}
else {
} else {
dfd.reject(message);

@@ -730,0 +751,0 @@ }

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc