blackberry / BB10-WebWorks-Framework

The BB10 WebWorks Framework is packaged within an application BAR file to run on a BB10 device (or simulator)
61 stars 34 forks source link

setting blackberry.io.sandbox can prevent success or error callbacks from being called when requesting #284

Open gtanner opened 12 years ago

gtanner commented 12 years ago

Testcase:

blackberry.io.sandbox = false; 
webkitRequestFileSystem(PERSISTENT, 1024, function () { 
    console.log("should get here"); 
}, function () { 
    console.log('or here')
});
blackberry.io.sandbox = true;

Result: No callback is invoked from the request fileSystem call.

gtanner commented 12 years ago

The problem is caused by the second set of blackberry.io.sandbox

nukulb commented 12 years ago

so if you do this you are good?

blackberry.io.sandbox = true;

webkitRequestFileSystem(PERSISTENT, 1024, function () { 
    console.log("should get here"); 
}, function () { 
    console.log('or here')
});
gtanner commented 12 years ago

Correct.

gtanner commented 12 years ago

The issue is I want to reset back to the users value of sandbox as fast as possible in cordova. Currently I am resetting it in the success handler (but that leaves time that user code could access the fileSystem and get something that is unexpected)

nukulb commented 12 years ago

not sure if we can easily fix this

gtanner commented 12 years ago

I wonder if this is another notch in support for redesigning this concept a-la #229?

I am not feeling safe having to flip this flag and allowing a window that the application can get an unexpected copy of the fileSystem.

I am wondering if the sandbox flag would better live as a param to requestFileSystem? That way there is no global state that needs to be managed between requests.

nukulb commented 12 years ago

why do you need to unsandbox in cordova?

can you do the same work in the controller webview through an index.js file of an extension which is forever unsandboxed?

gtanner commented 12 years ago

For the capture API: https://github.com/gtanner/incubator-cordova-js/blob/master/lib/webworks/qnx/plugin/qnx/capture.js#L27-40

nukulb commented 12 years ago

You should be able to do blackberry.io.sandbox = sb before the fs.roo.getFile

nukulb commented 12 years ago

Still in the callback but sooner

Also it seems as if in your code if it fails the sandbox property will set to unsandbox

gtanner commented 12 years ago

Yeah, that code isn't final, just checked it in so you can see it.

I can move the sandbox reset but I am still not a fan and would like this fixed / cleaned up in a future release.