Skip to content

Commit

Permalink
fix: Edge throws unspecified error
Browse files Browse the repository at this point in the history
run tests on FF
  • Loading branch information
Patrick Kubiak committed Oct 8, 2019
1 parent 4286ef4 commit d99b7b4
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 8 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ addons:
- google-chrome
packages:
- google-chrome-stable
firefox: latest
language: node_js
node_js:
- "node"
Expand Down
9 changes: 8 additions & 1 deletion karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,14 @@ module.exports = function (config) {

// start these browsers
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
browsers: ['ChromeHeadless'],
browsers: ['ChromeHeadless', 'FirefoxHeadless'],

customLaunchers: {
FirefoxHeadless: {
base: 'Firefox',
flags: ['-headless']
}
},

// Continuous Integration mode
// if true, Karma captures browsers, runs the tests and exits
Expand Down
10 changes: 3 additions & 7 deletions local-storage-poorlyfill.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
*
*/

/* global DOMException */

// strict mode
'use strict';

Expand Down Expand Up @@ -98,11 +96,9 @@
supported = false
}
} catch (e) {
/* istanbul ignore next */
if (e instanceof DOMException) {
// access is denied for this document
supported = false
}
// chrome throws DOMException
// edge throws Unspecified error
supported = false
}

return supported
Expand Down
17 changes: 17 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,23 @@ describe('localStorage poorlyfill', function () {
})
})

context('when using window.localStorage throws Unspecified error', function () {
before(function () {
// localStorage is disabled
sandbox.replaceGetter(window, 'localStorage', function () {
throw new Error()
})
})

after(function () {
sandbox.restore()
})

it('should return false', function () {
assert.isFalse(window.__localStorage._isSupported(), 'not supported')
})
})

context('when window.localStorage is not an object', function () {
before(function () {
// localStorage is disabled
Expand Down

0 comments on commit d99b7b4

Please sign in to comment.