[Pkg-javascript-commits] [node-stream-http] 162/208: Adding support for Service Workers.
Bastien Roucariès
rouca at moszumanska.debian.org
Sun Aug 13 13:39:40 UTC 2017
This is an automated email from the git hooks/post-receive script.
rouca pushed a commit to branch master
in repository node-stream-http.
commit 0a04a09f6843ab72f4d454a834519be9c6fa81d8
Author: Mikeal Rogers <mikeal.rogers at gmail.com>
Date: Wed Nov 16 19:18:19 2016 -0800
Adding support for Service Workers.
---
lib/capability.js | 17 ++++++++++++-----
1 file changed, 12 insertions(+), 5 deletions(-)
diff --git a/lib/capability.js b/lib/capability.js
index 4801c8d..cc19253 100644
--- a/lib/capability.js
+++ b/lib/capability.js
@@ -6,12 +6,19 @@ try {
exports.blobConstructor = true
} catch (e) {}
-var xhr = new global.XMLHttpRequest()
-// If XDomainRequest is available (ie only, where xhr might not work
-// cross domain), use the page location. Otherwise use example.com
-xhr.open('GET', global.XDomainRequest ? '/' : 'https://example.com')
+// Service workers don't have XHR
+if (global.XMLHttpRequest) {
+ var xhr = new global.XMLHttpRequest()
+ // If XDomainRequest is available (ie only, where xhr might not work
+ // cross domain), use the page location. Otherwise use example.com
+ xhr.open('GET', global.XDomainRequest ? '/' : 'https://example.com')
+} else {
+ var xhr = null
+}
+
function checkTypeSupport (type) {
+ if (!xhr) return false
try {
xhr.responseType = type
return xhr.responseType === type
@@ -30,7 +37,7 @@ exports.arraybuffer = haveArrayBuffer && checkTypeSupport('arraybuffer')
exports.msstream = !exports.fetch && haveSlice && checkTypeSupport('ms-stream')
exports.mozchunkedarraybuffer = !exports.fetch && haveArrayBuffer &&
checkTypeSupport('moz-chunked-arraybuffer')
-exports.overrideMimeType = isFunction(xhr.overrideMimeType)
+exports.overrideMimeType = xhr ? isFunction(xhr.overrideMimeType) : false
exports.vbArray = isFunction(global.VBArray)
function isFunction (value) {
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-stream-http.git
More information about the Pkg-javascript-commits
mailing list