[Pkg-javascript-commits] [sockjs-client] 198/350: Fix #187 try/catch access to document.domain
tonnerre at ancient-solutions.com
tonnerre at ancient-solutions.com
Fri Aug 5 01:04:21 UTC 2016
This is an automated email from the git hooks/post-receive script.
tonnerre-guest pushed a commit to branch upstream
in repository sockjs-client.
commit f9ef2dfc265bdf23aa848f047f3c218c2154017f
Author: Bryce Kahle <bkahle at gmail.com>
Date: Mon Oct 20 15:35:41 2014 -0400
Fix #187 try/catch access to document.domain
---
lib/main.js | 3 ++-
lib/transport/sender/xdr.js | 3 ++-
lib/utils/browser.js | 14 ++++++++++++++
3 files changed, 18 insertions(+), 2 deletions(-)
diff --git a/lib/main.js b/lib/main.js
index 87c3606..6f48855 100644
--- a/lib/main.js
+++ b/lib/main.js
@@ -11,6 +11,7 @@ var u = require('url')
, eventUtils = require('./utils/event')
, transport = require('./utils/transport')
, objectUtils = require('./utils/object')
+ , browser = require('./utils/browser')
, SecurityError = require('./error/security')
, InvalidAccessError = require('./error/invalid-access')
, InvalidStateError = require('./error/invalid-state')
@@ -109,7 +110,7 @@ function SockJS(url, protocols, transportsWhitelist) {
// obtain server info
// http://sockjs.github.io/sockjs-protocol/sockjs-protocol-0.3.3.html#section-26
this._urlInfo = {
- nullOrigin: global.document && !global.document.domain
+ nullOrigin: !browser.hasDomain()
, sameOrigin: urlUtils.isOriginEqual(this.url, loc.href)
, sameScheme: urlUtils.isSchemeEqual(this.url, loc.href)
};
diff --git a/lib/transport/sender/xdr.js b/lib/transport/sender/xdr.js
index 6025d5a..8bbb06e 100644
--- a/lib/transport/sender/xdr.js
+++ b/lib/transport/sender/xdr.js
@@ -3,6 +3,7 @@
var EventEmitter = require('events').EventEmitter
, util = require('util')
, eventUtils = require('../../utils/event')
+ , browser = require('../../utils/browser')
;
var debug = function() {};
@@ -91,6 +92,6 @@ XDRObject.prototype.close = function() {
};
// IE 8/9 if the request target uses the same scheme - #79
-XDRObject.enabled = !!(global.XDomainRequest && global.document && global.document.domain);
+XDRObject.enabled = !!(global.XDomainRequest && browser.hasDomain());
module.exports = XDRObject;
diff --git a/lib/utils/browser.js b/lib/utils/browser.js
index ccc30d8..844b2a8 100644
--- a/lib/utils/browser.js
+++ b/lib/utils/browser.js
@@ -10,4 +10,18 @@ module.exports = {
return global.navigator &&
/konqueror/i.test(global.navigator.userAgent);
}
+
+ // #187 wrap document.domain in try/catch because of WP8 from file:///
+, hasDomain: function () {
+ // non-browser client always has a domain
+ if (!global.document) {
+ return true;
+ }
+
+ try {
+ return !!global.document.domain;
+ } catch (e) {
+ return false;
+ }
+ }
};
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/sockjs-client.git
More information about the Pkg-javascript-commits
mailing list