dom/workers/test/jsm_url_worker.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/workers/test/jsm_url_worker.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,82 @@
     1.4 +onmessage = function(event) {
     1.5 +  if (event.data != 0) {
     1.6 +    var worker = new Worker('jsm_url_worker.js');
     1.7 +    worker.onmessage = function(event) {
     1.8 +      postMessage(event.data);
     1.9 +    }
    1.10 +
    1.11 +    worker.postMessage(event.data - 1);
    1.12 +    return;
    1.13 +  }
    1.14 +
    1.15 +  status = false;
    1.16 +  try {
    1.17 +    if ((URL instanceof Object)) {
    1.18 +      status = true;
    1.19 +    }
    1.20 +  } catch(e) {
    1.21 +  }
    1.22 +
    1.23 +  postMessage({type: 'status', status: status, msg: 'URL object:' + URL});
    1.24 +
    1.25 +  status = false;
    1.26 +  var blob = null;
    1.27 +  try {
    1.28 +    blob = new Blob([]);
    1.29 +    status = true;
    1.30 +  } catch(e) {
    1.31 +  }
    1.32 +
    1.33 +  postMessage({type: 'status', status: status, msg: 'Blob:' + blob});
    1.34 +
    1.35 +  status = false;
    1.36 +  var url = null;
    1.37 +  try {
    1.38 +    url = URL.createObjectURL(blob);
    1.39 +    status = true;
    1.40 +  } catch(e) {
    1.41 +  }
    1.42 +
    1.43 +  postMessage({type: 'status', status: status, msg: 'Blob URL:' + url});
    1.44 +
    1.45 +  status = false;
    1.46 +  try {
    1.47 +    URL.revokeObjectURL(url);
    1.48 +    status = true;
    1.49 +  } catch(e) {
    1.50 +  }
    1.51 +
    1.52 +  postMessage({type: 'status', status: status, msg: 'Blob Revoke URL'});
    1.53 +
    1.54 +  status = false;
    1.55 +  var url = null;
    1.56 +  try {
    1.57 +    url = URL.createObjectURL(true);
    1.58 +  } catch(e) {
    1.59 +    status = true;
    1.60 +  }
    1.61 +
    1.62 +  postMessage({type: 'status', status: status, msg: 'CreateObjectURL should fail if the arg is not a blob'});
    1.63 +
    1.64 +  status = false;
    1.65 +  var url = null;
    1.66 +  try {
    1.67 +    url = URL.createObjectURL(blob);
    1.68 +    status = true;
    1.69 +  } catch(e) {
    1.70 +  }
    1.71 +
    1.72 +  postMessage({type: 'status', status: status, msg: 'Blob URL2:' + url});
    1.73 +  postMessage({type: 'url', url: url});
    1.74 +
    1.75 +  status = false;
    1.76 +  try {
    1.77 +    URL.createObjectURL(new Object());
    1.78 +  } catch(e) {
    1.79 +    status = true;
    1.80 +  }
    1.81 +
    1.82 +  postMessage({type: 'status', status: status, msg: 'Exception wanted' });
    1.83 +
    1.84 +  postMessage({type: 'finish' });
    1.85 +}

mercurial