mozilla / r2d2b2g

Firefox OS Simulator is a test environment for Firefox OS. Use it to test your apps in a Firefox OS-like environment that looks and feels like a mobile phone.
https://addons.mozilla.org/en-US/firefox/addon/firefox-os-simulator/
Other
392 stars 139 forks source link

Simulator does not recognize the "mobilenetwork" permission #711

Open reinvented opened 11 years ago

reinvented commented 11 years ago

Reporting an issue discussed at some length in mozilla.dev.webapps

Trying to run an app that requests the "mobilenetwork" permission:

https://github.com/reinvented/getcellid/tree/mobilenetwork/www

The manifest.webapp looks, in part, like this:

"type": "privileged",
"permissions": {
    "mobilenetwork": { "description":"Obtain information from the device about cell ID." },
    "systemXHR": { "description":"Update OpenCellID.org using data connection." },
    "geolocation": { "description":"Obtain geolocation from the device GPS." }
}

The Simulator reports an error:

Unknown permission 'mobilenetwork'.

Trying (without really knowing what I'm doing) to diagnose, I find that it is resources/r2d2b2g/lib/validator.js that does the validation of the manifest.

This script loads the list of valid permissions from resource://gre/modules/PermissionsTable.jsm

When I open that URI in Firefox, the "mobilenetwork" permission is not listed.

However, in the file included with the Simulator extension:

resources/r2d2b2g/data/mac64/B2G.app/Contents/MacOS/modules/PermissionsTable.jsm

the "mobilenetwork" permission is listed.

Opening the URI resource://gre/modules/ in Firefox I see:

Index of jar:file:///Applications/Firefox.app/Contents/MacOS/omni.ja!/modules/

at the top of the page, which makes me think that perhaps the validator.js is getting its PermissionsTable.jsm from the wrong place?

mykmelez commented 11 years ago

@reinvented Thanks for the detailed and comprehensive bug report!

When @rpl initially implemented manifest validation, in #323, he pushed the manifest from Firefox to B2G for validation using B2G's PermissionsTable.jsm, which knows about the "mobilenetwork" permission. But @ochameau later changed the validator to use Firefox's version of that file in order to simplify the validation flow, and it looks like that's the cause of this bug.

I'm not sure what the best solution is. We could switch back to validating in B2G, which would solve this problem at the cost of re-complicating the validation flow. Or perhaps we could load B2G's PermissionsTable.jsm in Firefox somehow (f.e. by generating a file: URL to it and then loading it via Cu.import).

@ochameau What do you think?