worker_basic.js (771B)
1 /* eslint-env worker */ 2 importScripts("filesystem_commons.js"); 3 4 function finish() { 5 postMessage({ type: "finish" }); 6 } 7 8 function ok(a, msg) { 9 postMessage({ type: "test", test: !!a, message: msg }); 10 } 11 12 function is(a, b, msg) { 13 ok(a === b, msg); 14 } 15 16 function isnot(a, b, msg) { 17 ok(a != b, msg); 18 } 19 20 var tests = [ 21 function () { 22 test_basic(directory, next); 23 }, 24 function () { 25 test_getFilesAndDirectories(directory, true, next); 26 }, 27 function () { 28 test_getFiles(directory, false, next); 29 }, 30 function () { 31 test_getFiles(directory, true, next); 32 }, 33 ]; 34 35 function next() { 36 if (!tests.length) { 37 finish(); 38 return; 39 } 40 41 var test = tests.shift(); 42 test(); 43 } 44 45 var directory; 46 47 onmessage = function (e) { 48 directory = e.data; 49 next(); 50 };