Skip to content

Commit 90927d2

Browse files
committed
Fix sidebar app failing to load in Firefox extension.
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
1 parent 134aec5 commit 90927d2

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/sidebar/app.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,5 +225,16 @@ module.exports = angular.module('h', [
225225

226226
processAppOpts();
227227

228+
// Work around a check in Angular's $sniffer service that causes it to
229+
// incorrectly determine that Firefox extensions are Chrome Packaged Apps which
230+
// do not support the HTML 5 History API. This results Angular redirecting the
231+
// browser on startup and thus the app fails to load.
232+
// See https://github.com/angular/angular.js/blob/a03b75c6a812fcc2f616fc05c0f1710e03fca8e9/src/ng/sniffer.js#L30
233+
if (window.chrome && !window.chrome.app) {
234+
window.chrome.app = {
235+
dummyAddedByHypothesisClient: true,
236+
};
237+
}
238+
228239
var appEl = document.querySelector('hypothesis-app');
229240
angular.bootstrap(appEl, ['h'], {strictDi: true});

0 commit comments

Comments
 (0)