@@ -110,7 +110,7 @@ export var test_getImage = function (done) {
110110 // <snippet module="http" title="http">
111111 // ### Get Image from URL
112112 // ``` JavaScript
113- http . getImage ( "http ://www.google.com/images/errors/logo_sm_2. png" ) . then ( function ( r ) {
113+ http . getImage ( "https ://httpbin.org/image/ png" ) . then ( function ( r ) {
114114 //// Argument (r) is Image!
115115 // <hide>
116116 result = r ;
@@ -309,7 +309,7 @@ export var test_request_responseContentToJSONShouldReturnJSON = function (done)
309309export var test_request_responseContentToImageShouldReturnCorrectImage = function ( done ) {
310310 var result ;
311311
312- http . request ( { url : "http ://www.google.com/images/errors/logo_sm_2. png" , method : "GET" } ) . then ( function ( response ) {
312+ http . request ( { url : "https ://httpbin.org/image/ png" , method : "GET" } ) . then ( function ( response ) {
313313 response . content . toImage ( ) . then ( ( source ) => {
314314 result = source ;
315315 try {
@@ -452,180 +452,4 @@ function doRequest(url: string, done: Function) {
452452 } , function ( e ) {
453453 done ( e ) ;
454454 } ) ;
455- }
456-
457- export var test_XMLHttpRequest_isDefined = function ( ) {
458- TKUnit . assert ( types . isDefined ( global [ "XMLHttpRequest" ] ) , "XMLHttpRequest should be defined!" ) ;
459- } ;
460-
461- var xhr = new XMLHttpRequest ( ) ;
462-
463- export var test_XMLHttpRequest_open_isDefined = function ( ) {
464- TKUnit . assert ( types . isFunction ( xhr . open ) , "XMLHttpRequest.open should be defined!" ) ;
465- } ;
466-
467- export var test_XMLHttpRequest_send_isDefined = function ( ) {
468- TKUnit . assert ( types . isFunction ( xhr . send ) , "XMLHttpRequest.send should be defined!" ) ;
469- } ;
470-
471- export var test_XMLHttpRequest_setRequestHeader_isDefined = function ( ) {
472- TKUnit . assert ( types . isFunction ( xhr . setRequestHeader ) , "XMLHttpRequest.setRequestHeader should be defined!" ) ;
473- } ;
474-
475- export var test_XMLHttpRequest_getAllResponseHeaders_isDefined = function ( ) {
476- TKUnit . assert ( types . isFunction ( xhr . getAllResponseHeaders ) , "XMLHttpRequest.getAllResponseHeaders should be defined!" ) ;
477- } ;
478-
479- export var test_XMLHttpRequest_getResponseHeader_isDefined = function ( ) {
480- TKUnit . assert ( types . isFunction ( xhr . getResponseHeader ) , "XMLHttpRequest.getResponseHeader should be defined!" ) ;
481- } ;
482-
483- export var test_XMLHttpRequest_overrideMimeType_isDefined = function ( ) {
484- TKUnit . assert ( types . isFunction ( xhr . overrideMimeType ) , "XMLHttpRequest.overrideMimeType should be defined!" ) ;
485- } ;
486-
487- export var test_XMLHttpRequest_readyState_isDefined = function ( ) {
488- TKUnit . assert ( types . isDefined ( xhr . readyState ) , "XMLHttpRequest.readyState should be defined!" ) ;
489- } ;
490-
491- export var test_XMLHttpRequest_responseText_isDefined = function ( ) {
492- TKUnit . assert ( types . isDefined ( xhr . responseText ) , "XMLHttpRequest.responseText should be defined!" ) ;
493- } ;
494-
495- export var test_XMLHttpRequest_readyStateShouldChange = function ( done ) {
496- var count = 0 ;
497- xhr = new XMLHttpRequest ( ) ;
498-
499- TKUnit . assert ( xhr . readyState === 0 , "xhr.readyState should be UNSENT!" ) ;
500-
501- xhr . onreadystatechange = function ( ) {
502- try {
503-
504- if ( count === 0 ) {
505- TKUnit . assert ( xhr . readyState === 1 , "xhr.readyState should be OPEN!" ) ;
506- } else if ( count === 1 ) {
507- TKUnit . assert ( xhr . readyState === 2 , "xhr.readyState should be HEADERS_RECEIVED!" ) ;
508- } else if ( count === 2 ) {
509- TKUnit . assert ( xhr . readyState === 3 , "xhr.readyState should be LOADING!" ) ;
510- } else if ( count === 3 ) {
511- TKUnit . assert ( xhr . readyState === 4 , "xhr.readyState should be DONE!" ) ;
512- }
513-
514- count ++ ;
515-
516- done ( null ) ;
517- }
518- catch ( err ) {
519- done ( err ) ;
520- }
521- } ;
522-
523- xhr . open ( "GET" , "https://httpbin.org/get" ) ;
524- xhr . send ( ) ;
525- } ;
526-
527- export var test_XMLHttpRequest_headersSentAndReceivedProperly = function ( done ) {
528- xhr = new XMLHttpRequest ( ) ;
529- xhr . open ( "GET" , "https://httpbin.org/get" ) ;
530- xhr . setRequestHeader ( "Content-Type" , "application/json" ) ;
531- xhr . onreadystatechange = function ( ) {
532- if ( xhr . readyState > 1 ) {
533- try {
534- TKUnit . assert ( xhr . getResponseHeader ( "Content-Type" ) === "application/json" , "Headers not sent/received properly!" ) ;
535- done ( null ) ;
536- }
537- catch ( err ) {
538- done ( err ) ;
539- }
540- }
541- } ;
542- xhr . send ( ) ;
543- } ;
544-
545- export var test_XMLHttpRequest_contentSentAndReceivedProperly = function ( done ) {
546- xhr = new XMLHttpRequest ( ) ;
547- xhr . open ( "POST" , "https://httpbin.org/post" ) ;
548- xhr . setRequestHeader ( "Content-Type" , "application/json" ) ;
549- xhr . onreadystatechange = function ( ) {
550- if ( xhr . readyState > 3 ) {
551- var result = JSON . parse ( xhr . responseText ) ;
552- try {
553- TKUnit . assert ( result [ "json" ] [ "MyVariableOne" ] === "ValueOne" && result [ "json" ] [ "MyVariableTwo" ] === "ValueTwo" , "Content not sent/received properly!" ) ;
554- done ( null ) ;
555- }
556- catch ( err ) {
557- done ( err ) ;
558- }
559- }
560- } ;
561- xhr . send ( JSON . stringify ( { MyVariableOne : "ValueOne" , MyVariableTwo : "ValueTwo" } ) ) ;
562- } ;
563-
564- export var test_XMLHttpRequest_abortShouldCancelonreadystatechange = function ( done ) {
565- var flag = false ;
566-
567- xhr = new XMLHttpRequest ( ) ;
568- xhr . open ( "POST" , "https://httpbin.org/post" ) ;
569- xhr . setRequestHeader ( "Content-Type" , "application/json" ) ;
570- xhr . onreadystatechange = function ( ) {
571- flag = true ;
572- } ;
573- xhr . send ( JSON . stringify ( { MyVariableOne : "ValueOne" , MyVariableTwo : "ValueTwo" } ) ) ;
574- xhr . abort ( ) ;
575-
576- TKUnit . assert ( flag === false , "Content not sent/received properly!" ) ;
577- done ( null ) ;
578- } ;
579-
580- export var test_XMLHttpRequest_requestShouldBePossibleAfterAbort = function ( done ) {
581- xhr = new XMLHttpRequest ( ) ;
582- xhr . open ( "POST" , "https://httpbin.org/post" ) ;
583- xhr . setRequestHeader ( "Content-Type" , "application/json" ) ;
584- xhr . onreadystatechange = function ( ) {
585- if ( xhr . readyState > 3 ) {
586- var result = JSON . parse ( xhr . responseText ) ;
587- try {
588- TKUnit . assert ( result [ "json" ] [ "MyVariableOne" ] === "ValueOne" && result [ "json" ] [ "MyVariableTwo" ] === "ValueTwo" , "Content not sent/received properly!" ) ;
589- done ( null ) ;
590- }
591- catch ( err ) {
592- done ( err ) ;
593- }
594- }
595- } ;
596- xhr . send ( JSON . stringify ( { MyVariableOne : "ValueOne" , MyVariableTwo : "ValueTwo" } ) ) ;
597- xhr . abort ( ) ;
598-
599- xhr . send ( JSON . stringify ( { MyVariableOne : "ValueOne" , MyVariableTwo : "ValueTwo" } ) ) ;
600- } ;
601-
602- export function test_raises_onload_Event ( done ) {
603- let xhr = new XMLHttpRequest ( ) ;
604- xhr . onload = ( ) => {
605- done ( null ) ;
606- }
607- xhr . open ( "GET" , "https://httpbin.org/get" ) ;
608- xhr . send ( ) ;
609- }
610-
611- export function test_raises_onerror_Event ( done ) {
612- let xhr = new XMLHttpRequest ( ) ;
613- xhr . onerror = ( ) => {
614- done ( null ) ;
615- }
616- xhr . open ( "GET" , "https://no-such-domain-httpbin.org" ) ;
617- xhr . send ( ) ;
618- }
619-
620- export function test_responseType ( done ) {
621- let xhr = new XMLHttpRequest ( ) ;
622- xhr . responseType = "" ;
623- xhr . responseType = "text" ;
624-
625- TKUnit . assertThrows (
626- ( ) => xhr . responseType = "json" ,
627- "Didn't raise on unsupported type." ,
628- "Response type of 'json' not supported."
629- ) ;
630- done ( null ) ;
631- }
455+ }
0 commit comments