Closed Bug 1191516 Opened 6 years ago Closed 6 years ago

Cannot launch open web apps from the browser

Categories

(Core Graveyard :: DOM: Apps, defect)

defect
Not set
normal

Tracking

(firefox43 fixed)

RESOLVED FIXED
mozilla43
Tracking Status
firefox43 --- fixed

People

(Reporter: jesmith, Assigned: marco)

Details

Attachments

(2 files)

User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:39.0) Gecko/20100101 Firefox/39.0
Build ID: 20150630154324

Steps to reproduce:

use navigator.mozApps.checkInstalled to get access to an app the user installed
try to launch that app using launch()


Actual results:

Security wrapper denied access to property launch on privileged Javascript object. TypeError: req.result.launch is not a function



Expected results:

The app should have launched.
Firefox should have a way for a user to launch an installed web app, ideally passing a starting URL. In chrome app manifests, an app can specify a url_handler, so that going to a certain web address in chrome causes the app to open. A wildcard can be included, allowing the app to be opened with a "deep link."

There appears to be an analogous feature for Firefox OS, but nothing for the desktop.

I was hoping that although I cannot open to the specific place in the app I want, I might be able to open the app using the launch() method documented here:
https://developer.mozilla.org/en-US/docs/Web/API/DOMApplication

I was able to get the app object using the checkInstalled method, but calling launch on that object just results in the above security exception.

You can reproduce this as follows:
1. Visit http://m.kaon.com/c/ka using Firefox and install that app
2. Visit https://apps.kaonadn.net/fflaunch.html#4559009

The latter page is able to get the app object, but you'll see the referenced security exception in the log when it tries to launch it.

If there is a way to make this work, my next request will be to have a way of getting a URL into the app (as an argument to launch would be the obvious solution).
Severity: normal → major
Component: Untriaged → Web Apps
OS: Unspecified → Mac OS X
Hardware: Unspecified → x86_64
Fabrice, do you have any insight into what's going on here? Or do you know who the desktop app runtime folks are who can answer this?
Flags: needinfo?(fabrice)
I'm not sure what's going on... Myk, is that something you've seen already?
Flags: needinfo?(fabrice) → needinfo?(myk)
Hmm, I'm unsure too.  I thought perhaps it was because the launch request comes from a different origin than the origin that installed the app, but I can reproduce on http://www.mykzilla.org/app/, where the requests both come from the same origin (press the install button, then press the launch button).

Nevertheless, launching apps does work on Marketplace.  I'm not the expert there, but I think Marketplace uses mozApps.getInstalled to get the list of apps installed from its origin:

https://github.com/mozilla/zamboni/blob/be1aa96d5e24fe398c18929732f4cac4f75769a8/mkt/commonplace/templates/commonplace/iframe-install.html#L16

And then it calls "launch" on one of the apps in the results array:

https://github.com/mozilla/zamboni/blob/be1aa96d5e24fe398c18929732f4cac4f75769a8/mkt/commonplace/templates/commonplace/iframe-install.html#L255

Nevertheless, I would expect checkInstalled -> launch to work as well, at least from the same origin.  So I'm not sure what's going on.
Flags: needinfo?(myk)
As an experiment, I put that iframe-install.html code (with a couple small mods) onto the site I referenced as ffstore.html. Then I went to one of my allowed origin domains and tried messaging it in an IFRAME to see if it worked any better.

window.addEventListener('message', function(e) {console.log('Received message: ' + JSON.stringify(e.data));})
var ifr = document.createElement("iframe");ifr.src='https://apps.kaonadn.net/ffstore.html';
document.body.appendChild(ifr);ifr.contentWindow.postMessage({'name':'getInstalled'},"*")

The result was:

 Received message: {"name":"getInstalled","result":[]}

In other words, getInstalled doesn't return any results on the site. Of course, I didn't install them *from* that site to begin with. So I uninstalled an app and installed it using the install-package message so the site itself did the install. After that, I was able to see it with getInstalled and I was able to launch it with launch–app.

The original problem I reported is still there. Even after installing it this way, I cannot access the object if I grab it using checkInstalled. So that bug (if it is not by design) is still present.

However, using that store code on my site is a really good work-around. It lets me do everything I need to do, and then some. Users who already installed the app will have an issue, but after I rejigger my installation code to use this IFRAME/message technique, it looks like a better long-term approach anyway.

I still need a way to get a deep link into the app I'm launching, though. Any ideas?

Can I file a feature request that you add an argument option to "launch"? If so, do I do that here, or someplace else?
Assignee: nobody → mar.castelluccio
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true
Attachment #8645395 - Flags: review?(fabrice)
Attachment #8645396 - Flags: review?(fabrice)
Component: Web Apps → DOM: Apps
Product: Firefox → Core
Version: 39 Branch → Trunk
Attachment #8645395 - Flags: review?(fabrice) → review+
Attachment #8645396 - Flags: review?(fabrice) → review+
Whiteboard: autoland-try
Whiteboard: autoland-try → [autoland-try]
autoland doesn't seem to work.
Severity: major → normal
OS: Mac OS X → All
Hardware: x86_64 → All
Whiteboard: [autoland-try]
Keywords: checkin-needed
Product: Core → Core Graveyard
You need to log in before you can comment on or make changes to this bug.