dom/workers/test/url_worker.js

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

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

mercurial