-
Notifications
You must be signed in to change notification settings - Fork 27.4k
Firefox WebExtensions misdetected as Chrome Packaged Apps #16068
Comments
Angular has a check for Chrome Packaged Apps in its `$sniffer` service which changes the behavior of the $location service and in the Firefox extension, triggers a redirect from `/client/app.html` to `/#client/app.html` on startup, breaking the sidebar app. This commit works around the problem by adding a fake `window.chrome.app` object to convince Angular that the Firefox extension is not a Chrome Packaged App. Issue reported upstream at angular/angular.js#16068
Hi @robertknight, As you tested it with AngularJS 1.5.11, could you verify the issue also occurs with 1.6.4 ? I doubt that change is solving your problem, but it's always interesting to know whether or not the behavior is different. |
Thank-you for the quick response. The |
If window.chrome.app isn't true in a FF web extension, how can the check in the sniffer for packaged apps be true? It specifically checks for window.chrome.app edit: I didn't see the second window.chrome.app check is reversed with ! |
If I get this straight, the following is happening:
Which evaluates to
Which results in true. The change @robertknight made in the referenced PR in his repo (see https://github.com/hypothesis/client/pull/460/files) changes this so that window.chrome.app is overridden and no runtime property is available on it which will evaluate to:
Which will evaluate to false and fixes the issue for him. |
You've got it right. If you're able to create a PR that would be great. A question I have is whether it is necessary to explicitly test for Chrome packaged apps / NW.js instead of feature-detecting the availability of the history APIs. According to this comment, |
Good question, this is the second time an issue like this arises (5 months ago the one for NW apps was fixed). Maybe @gkalpak or @Narretz have an idea on why it's being checked this way instead of feature detection. I guess it has to do with:
But my knowlegde of that is limited (if existing). |
IIRC the problem is that Chrome Packaged Apps will do something bad when you try to access history.pushState. |
Right. You can find more details in #13945. |
I'm submitting a ...
Current behavior:
In the current version of Firefox WebExtensions,
window.chrome
andwindow.chrome.runtime
exist butwindow.chrome.app
does not. A check in $sniffer misdetects the application as a Chrome Packaged App. This in turn disables the HTML 5 History API support in the $location service causing unexpected behaviour elsewhere. In the case of our app it caused the $location service to try and redirect the browser to a hash-bangified version (/path/app.html
=>#!/path/app.html
) of the URL on startup, breaking the app.Expected / new behavior:
The
isChromePackagedApp
check referenced above should return false in an HTML page loaded from a Firefox WebExtension.Angular version: 1.5.11
Browser: [Firefox 51]
Other information
A workaround for Firefox WebExtension authors is to set
window.chrome.app
to a dummy object before Angular bootstraps so that the check does not produce a false positive.The text was updated successfully, but these errors were encountered: