Wednesday 15 August 2012

javascript - Loading a script file in a Chrome App Sandbox -



javascript - Loading a script file in a Chrome App Sandbox -

i'm working on chrome app, , have script file that's saved in app's sandboxed filesystem. (it's available via url filesystem:chrome-extension_****/persistent/script.js

i'm able utilize chrome's filesystemapi read file in main app window. however, need accessible , executable in sandboxed page.

i have next in manifest -

"sandbox": { "pages": ["sandboxed_page.html"], "content_security_policy": "sandbox allow-scripts;" },

and i'm using page this:

<iframe id="sandbox_frame" seamless="seamless" src="sandboxed_page.html" sandbox="allow-scripts"></iframe>

i tried loading file in main app window, utilize window.url.createobjecturl() convert blob: url, , passed url via postmessage() sandbox. in sandbox, i'm trying load url <script> element. error saying not allowed load local resource: blob:chrome-extension%3a//...

the other alternative (which working) load contents of script.js in main app, , send entire string through postmessage(). not sure idea, script.js pretty big.

am doing wrong, or loading local scripts in sandboxes prohibited chrome's security policies?

i went through https://developer.chrome.com/apps/app_external, there's no mention of sending external resources sandbox.

sandboxed pages execute in unique origin i.e. 1 different app itself, , can't access filesystem urls across different origins. same goes object urls created files.

you're stuck postmessage approach, though may able create more efficient transfering arraybuffer rather copying info string. see https://developer.mozilla.org/en-us/docs/web/guide/performance/using_web_workers#passing_data_by_transferring_ownership_(transferable_objects).

javascript google-chrome iframe google-chrome-app

No comments:

Post a Comment