Skip to content

Commit

Permalink
Improved for Mozilla Browsers
Browse files Browse the repository at this point in the history
  • Loading branch information
Maykonn committed Jun 19, 2018
1 parent 87d4d84 commit f09631f
Showing 1 changed file with 5 additions and 30 deletions.
35 changes: 5 additions & 30 deletions BrowsingModeDetector.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,36 +209,11 @@ var MozillaBrowser = function (BrowsingModeDetector) {
this.BrowsingModeDetector = BrowsingModeDetector;

this.detectBrowsingMode = function () {
var db;
var self = this;

var callbackWhenIndexedDBWorking = function (e) {
if (typeof self.BrowsingModeDetector.getBrowsingMode() === 'undefined') {
self.BrowsingModeDetector.retry(
function () {
return db.readyState === 'done';
},
function (isTimeout) {
if (isTimeout) {
return callbackWhenIndexedDBNotWorking(e);
}

if (db.result) {
self.BrowsingModeDetector.setBrowsingInNormalMode();
}
}
);
}
};

var callbackWhenIndexedDBNotWorking = function (e) {
// On Firefox ESR versions, actually IndexedDB don't works.
self.BrowsingModeDetector.setBrowsingInIncognitoMode();
};

db = indexedDB.open("i");
db.onsuccess = callbackWhenIndexedDBWorking;
db.onerror = callbackWhenIndexedDBNotWorking;
if (navigator.serviceWorker) {
this.BrowsingModeDetector.setBrowsingInNormalMode();
} else {
this.BrowsingModeDetector.setBrowsingInIncognitoMode();
}
};

return this;
Expand Down

0 comments on commit f09631f

Please sign in to comment.