test_cache2-01e-basic-bypass-if-busy.js (988B)
1 "use strict"; 2 3 function run_test() { 4 do_get_profile(); 5 6 // Open for write, delay the actual write 7 asyncOpenCacheEntry( 8 "http://a/", 9 "disk", 10 Ci.nsICacheStorage.OPEN_NORMALLY, 11 null, 12 new OpenCallback(NEW | DONTFILL, "a1m", "a1d", function () { 13 var bypassed = false; 14 15 // Open and bypass 16 asyncOpenCacheEntry( 17 "http://a/", 18 "disk", 19 Ci.nsICacheStorage.OPEN_BYPASS_IF_BUSY, 20 null, 21 new OpenCallback(NOTFOUND, "", "", function () { 22 Assert.ok(!bypassed); 23 bypassed = true; 24 }) 25 ); 26 27 // do_execute_soon for two reasons: 28 // 1. we want finish_cache2_test call for sure after do_test_pending, but all the callbacks here 29 // may invoke synchronously 30 // 2. precaution when the OPEN_BYPASS_IF_BUSY invocation become a post one day 31 executeSoon(function () { 32 Assert.ok(bypassed); 33 finish_cache2_test(); 34 }); 35 }) 36 ); 37 38 do_test_pending(); 39 }