url_worker.js 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. onmessage = function(event) {
  2. if (event.data != 0) {
  3. var worker = new Worker('url_worker.js');
  4. worker.onmessage = function(event) {
  5. postMessage(event.data);
  6. }
  7. worker.postMessage(event.data - 1);
  8. return;
  9. }
  10. status = false;
  11. try {
  12. if ((URL instanceof Object)) {
  13. status = true;
  14. }
  15. } catch(e) {
  16. }
  17. postMessage({type: 'status', status: status, msg: 'URL object:' + URL});
  18. status = false;
  19. var blob = null;
  20. try {
  21. blob = new Blob([]);
  22. status = true;
  23. } catch(e) {
  24. }
  25. postMessage({type: 'status', status: status, msg: 'Blob:' + blob});
  26. status = false;
  27. var url = null;
  28. try {
  29. url = URL.createObjectURL(blob);
  30. status = true;
  31. } catch(e) {
  32. }
  33. postMessage({type: 'status', status: status, msg: 'Blob URL:' + url});
  34. status = false;
  35. try {
  36. URL.revokeObjectURL(url);
  37. status = true;
  38. } catch(e) {
  39. }
  40. postMessage({type: 'status', status: status, msg: 'Blob Revoke URL'});
  41. status = false;
  42. var url = null;
  43. try {
  44. url = URL.createObjectURL(true);
  45. } catch(e) {
  46. status = true;
  47. }
  48. postMessage({type: 'status', status: status, msg: 'CreateObjectURL should fail if the arg is not a blob'});
  49. status = false;
  50. var url = null;
  51. try {
  52. url = URL.createObjectURL(blob);
  53. status = true;
  54. } catch(e) {
  55. }
  56. postMessage({type: 'status', status: status, msg: 'Blob URL2:' + url});
  57. postMessage({type: 'url', url: url});
  58. status = false;
  59. try {
  60. URL.createObjectURL(new Object());
  61. } catch(e) {
  62. status = true;
  63. }
  64. postMessage({type: 'status', status: status, msg: 'Exception wanted' });
  65. var blob = new Blob([123]);
  66. var uri = URL.createObjectURL(blob);
  67. postMessage({type: 'status', status: !!uri,
  68. msg: "The URI has been generated from the blob"});
  69. var u = new URL(uri);
  70. postMessage({type: 'status', status: u.origin == 'http://mochi.test:8888',
  71. msg: "The URL generated from a blob URI has an origin."});
  72. postMessage({type: 'finish' });
  73. }