3 return new Promise(function(resolve
, reject
) {
4 var request
= new XMLHttpRequest();
5 request
.addEventListener(
7 function(event
) { reject(event
); });
8 request
.addEventListener(
10 function(event
) { resolve(request
.response
); });
11 request
.open('GET', url
);
16 function load_image(url
, cross_origin
) {
17 return new Promise(function(resolve
, reject
) {
18 var img
= document
.createElement('img');
19 document
.body
.appendChild(img
);
20 img
.onload = function() {
23 img
.onerror = function() {
26 if (cross_origin
!= '') {
27 img
.crossOrigin
= cross_origin
;