Commit 16ca8044 authored by JC Brand's avatar JC Brand

Add experimental support for running the XMPP conneciton inside a shared worker

Still lacks inter-tab communication to update state across tabs, i.e.
when sending a 1-on-1 message in one tab, it doesn't appear in another,
because that information is not available via the websocket connection.

- Create a new `Connection` class that extends Strophe.Connection and
    move related code from `converse-core.js` into this class.
- Store the session in localStorage when using a worker
- Move XEP-0156 code to connection.js
    This allows us to initialize the connection without needing to know the
    domain.
parent 5e479d3b
...@@ -578,6 +578,9 @@ For documentation on the configuration options that ``Strophe.Connection`` ...@@ -578,6 +578,9 @@ For documentation on the configuration options that ``Strophe.Connection``
accepts, refer to the accepts, refer to the
`Strophe.Connection documentation <http://strophe.im/strophejs/doc/1.2.8/files/strophe-js.html#Strophe.Connection.Strophe.Connection>`_. `Strophe.Connection documentation <http://strophe.im/strophejs/doc/1.2.8/files/strophe-js.html#Strophe.Connection.Strophe.Connection>`_.
Restricting the supported authentication mechanisms:
****************************************************
As an example, suppose you want to restrict the supported SASL authentication As an example, suppose you want to restrict the supported SASL authentication
mechanisms, then you'd pass in the ``mechanisms`` as a ``connection_options`` mechanisms, then you'd pass in the ``mechanisms`` as a ``connection_options``
``key:value`` pair: ``key:value`` pair:
...@@ -589,9 +592,29 @@ mechanisms, then you'd pass in the ``mechanisms`` as a ``connection_options`` ...@@ -589,9 +592,29 @@ mechanisms, then you'd pass in the ``mechanisms`` as a ``connection_options``
'mechanisms': [ 'mechanisms': [
converse.env.Strophe.SASLMD5, converse.env.Strophe.SASLMD5,
] ]
}, }
});
Running the XMPP Connection inside a shared worker
**************************************************
Newer versions of Strophe.js, support the ability to run the XMPP Connection
inside a `shared worker <https://developer.mozilla.org/en-US/docs/Web/API/SharedWorker>`_ that's shared
between open tabs in the browser in which Converse is running (and which have the same domain).
*Note:* This feature is experimental and there currently is no way to
synchronize actions between tabs. For example, sent 1-on-1 messages aren't
reflected by the server, so you if you send such a message in one tab, it won't
appear in another.
.. code-block:: javascript
converse.initialize({
connection_options: { 'worker': true }
}); });
.. _`credentials_url`: .. _`credentials_url`:
credentials_url credentials_url
......
...@@ -3283,9 +3283,12 @@ ...@@ -3283,9 +3283,12 @@
} }
}, },
"strophe.js": { "strophe.js": {
"version": "1.3.4", "version": "github:strophe/strophejs#c4a94e59877c06dc2395f4ccbd26f3fee67a4c9f",
"resolved": "https://registry.npmjs.org/strophe.js/-/strophe.js-1.3.4.tgz", "from": "strophe.js@github:strophe/strophejs#c4a94e59877c06dc2395f4ccbd26f3fee67a4c9f",
"integrity": "sha512-jSLDG8jolhAwGOSgiJ7DTMSYK3wVoEJHKtpVRyEacQZ6CWA6z2WRPJpcFMjsIweq5aP9/XIvKUQqHBu/ZhvESA==" "requires": {
"abab": "^2.0.3",
"xmldom": "^0.1.27"
}
}, },
"twemoji": { "twemoji": {
"version": "12.1.5", "version": "12.1.5",
...@@ -4901,30 +4904,27 @@ ...@@ -4901,30 +4904,27 @@
} }
}, },
"@octokit/endpoint": { "@octokit/endpoint": {
"version": "6.0.3", "version": "6.0.5",
"resolved": "https://registry.npmjs.org/@octokit/endpoint/-/endpoint-6.0.3.tgz", "resolved": "https://registry.npmjs.org/@octokit/endpoint/-/endpoint-6.0.5.tgz",
"integrity": "sha512-Y900+r0gIz+cWp6ytnkibbD95ucEzDSKzlEnaWS52hbCDNcCJYO5mRmWW7HRAnDc7am+N/5Lnd8MppSaTYx1Yg==", "integrity": "sha512-70K5u6zd45ItOny6aHQAsea8HHQjlQq85yqOMe+Aj8dkhN2qSJ9T+Q3YjUjEYfPRBcuUWNgMn62DQnP/4LAIiQ==",
"dev": true, "dev": true,
"requires": { "requires": {
"@octokit/types": "^5.0.0", "@octokit/types": "^5.0.0",
"is-plain-object": "^3.0.0", "is-plain-object": "^4.0.0",
"universal-user-agent": "^5.0.0" "universal-user-agent": "^6.0.0"
}, },
"dependencies": { "dependencies": {
"is-plain-object": { "is-plain-object": {
"version": "3.0.1", "version": "4.1.1",
"resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-3.0.1.tgz", "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-4.1.1.tgz",
"integrity": "sha512-Xnpx182SBMrr/aBik8y+GuR4U1L9FqMSojwDQwPMmxyC6bvEqly9UBCxhauBF5vNh2gwWJNX6oDV7O+OM4z34g==", "integrity": "sha512-5Aw8LLVsDlZsETVMhoMXzqsXwQqr/0vlnBYzIXJbYo2F4yYlhLHs+Ez7Bod7IIQKWkJbJfxrWD7pA1Dw1TKrwA==",
"dev": true "dev": true
}, },
"universal-user-agent": { "universal-user-agent": {
"version": "5.0.0", "version": "6.0.0",
"resolved": "https://registry.npmjs.org/universal-user-agent/-/universal-user-agent-5.0.0.tgz", "resolved": "https://registry.npmjs.org/universal-user-agent/-/universal-user-agent-6.0.0.tgz",
"integrity": "sha512-B5TPtzZleXyPrUMKCpEHFmVhMN6EhmJYjG5PQna9s7mXeSqGTLap4OpqLl5FCEFUI3UBmllkETwKf/db66Y54Q==", "integrity": "sha512-isyNax3wXoKaulPDZWHQqbmIx1k2tb9fb3GGDBRxCscfYV2Ch7WxPArBsFEG8s/safwXTT7H4QGhaIkTp9447w==",
"dev": true, "dev": true
"requires": {
"os-name": "^3.1.0"
}
} }
} }
}, },
...@@ -4982,19 +4982,19 @@ ...@@ -4982,19 +4982,19 @@
} }
}, },
"@octokit/request": { "@octokit/request": {
"version": "5.4.5", "version": "5.4.7",
"resolved": "https://registry.npmjs.org/@octokit/request/-/request-5.4.5.tgz", "resolved": "https://registry.npmjs.org/@octokit/request/-/request-5.4.7.tgz",
"integrity": "sha512-atAs5GAGbZedvJXXdjtKljin+e2SltEs48B3naJjqWupYl2IUBbB/CJisyjbNHcKpHzb3E+OYEZ46G8eakXgQg==", "integrity": "sha512-FN22xUDP0i0uF38YMbOfx6TotpcENP5W8yJM1e/LieGXn6IoRxDMnBf7tx5RKSW4xuUZ/1P04NFZy5iY3Rax1A==",
"dev": true, "dev": true,
"requires": { "requires": {
"@octokit/endpoint": "^6.0.1", "@octokit/endpoint": "^6.0.1",
"@octokit/request-error": "^2.0.0", "@octokit/request-error": "^2.0.0",
"@octokit/types": "^5.0.0", "@octokit/types": "^5.0.0",
"deprecation": "^2.0.0", "deprecation": "^2.0.0",
"is-plain-object": "^3.0.0", "is-plain-object": "^4.0.0",
"node-fetch": "^2.3.0", "node-fetch": "^2.3.0",
"once": "^1.4.0", "once": "^1.4.0",
"universal-user-agent": "^5.0.0" "universal-user-agent": "^6.0.0"
}, },
"dependencies": { "dependencies": {
"@octokit/request-error": { "@octokit/request-error": {
...@@ -5009,19 +5009,16 @@ ...@@ -5009,19 +5009,16 @@
} }
}, },
"is-plain-object": { "is-plain-object": {
"version": "3.0.1", "version": "4.1.1",
"resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-3.0.1.tgz", "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-4.1.1.tgz",
"integrity": "sha512-Xnpx182SBMrr/aBik8y+GuR4U1L9FqMSojwDQwPMmxyC6bvEqly9UBCxhauBF5vNh2gwWJNX6oDV7O+OM4z34g==", "integrity": "sha512-5Aw8LLVsDlZsETVMhoMXzqsXwQqr/0vlnBYzIXJbYo2F4yYlhLHs+Ez7Bod7IIQKWkJbJfxrWD7pA1Dw1TKrwA==",
"dev": true "dev": true
}, },
"universal-user-agent": { "universal-user-agent": {
"version": "5.0.0", "version": "6.0.0",
"resolved": "https://registry.npmjs.org/universal-user-agent/-/universal-user-agent-5.0.0.tgz", "resolved": "https://registry.npmjs.org/universal-user-agent/-/universal-user-agent-6.0.0.tgz",
"integrity": "sha512-B5TPtzZleXyPrUMKCpEHFmVhMN6EhmJYjG5PQna9s7mXeSqGTLap4OpqLl5FCEFUI3UBmllkETwKf/db66Y54Q==", "integrity": "sha512-isyNax3wXoKaulPDZWHQqbmIx1k2tb9fb3GGDBRxCscfYV2Ch7WxPArBsFEG8s/safwXTT7H4QGhaIkTp9447w==",
"dev": true, "dev": true
"requires": {
"os-name": "^3.1.0"
}
} }
} }
}, },
...@@ -5072,9 +5069,9 @@ ...@@ -5072,9 +5069,9 @@
} }
}, },
"@octokit/types": { "@octokit/types": {
"version": "5.0.1", "version": "5.1.2",
"resolved": "https://registry.npmjs.org/@octokit/types/-/types-5.0.1.tgz", "resolved": "https://registry.npmjs.org/@octokit/types/-/types-5.1.2.tgz",
"integrity": "sha512-GorvORVwp244fGKEt3cgt/P+M0MGy4xEDbckw+K5ojEezxyMDgCaYPKVct+/eWQfZXOT7uq0xRpmrl/+hliabA==", "integrity": "sha512-+zuMnja97vuZmWa+HdUY+0KB9MLwcEHueSSyKu0G/HqZaFYCVdLpBkavb0xyDlH7eoBdvAvSX/+Y8+4FOEZkrQ==",
"dev": true, "dev": true,
"requires": { "requires": {
"@types/node": ">= 8" "@types/node": ">= 8"
...@@ -7558,19 +7555,6 @@ ...@@ -7558,19 +7555,6 @@
"through2": "^3.0.0" "through2": "^3.0.0"
}, },
"dependencies": { "dependencies": {
"handlebars": {
"version": "4.7.6",
"resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.7.6.tgz",
"integrity": "sha512-1f2BACcBfiwAfStCKZNrUCgqNZkGsAT7UM3kkYtXuLo0KnaVfjKOyf7PRzB6++aK9STyT1Pd2ZCPe3EGOXleXA==",
"dev": true,
"requires": {
"minimist": "^1.2.5",
"neo-async": "^2.6.0",
"source-map": "^0.6.1",
"uglify-js": "^3.1.4",
"wordwrap": "^1.0.0"
}
},
"inherits": { "inherits": {
"version": "2.0.4", "version": "2.0.4",
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
...@@ -7583,12 +7567,6 @@ ...@@ -7583,12 +7567,6 @@
"integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==",
"dev": true "dev": true
}, },
"source-map": {
"version": "0.6.1",
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
"integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==",
"dev": true
},
"through2": { "through2": {
"version": "3.0.2", "version": "3.0.2",
"resolved": "https://registry.npmjs.org/through2/-/through2-3.0.2.tgz", "resolved": "https://registry.npmjs.org/through2/-/through2-3.0.2.tgz",
...@@ -9197,9 +9175,9 @@ ...@@ -9197,9 +9175,9 @@
"dev": true "dev": true
}, },
"envinfo": { "envinfo": {
"version": "7.5.1", "version": "7.7.2",
"resolved": "https://registry.npmjs.org/envinfo/-/envinfo-7.5.1.tgz", "resolved": "https://registry.npmjs.org/envinfo/-/envinfo-7.7.2.tgz",
"integrity": "sha512-hQBkDf2iO4Nv0CNHpCuSBeaSrveU6nThVxFGTrq/eDlV716UQk09zChaJae4mZRsos1x4YLY2TaH3LHUae3ZmQ==", "integrity": "sha512-k3Eh5bKuQnZjm49/L7H4cHzs2FlL5QjbTB3JrPxoTI8aJG7hVMe4uKyJxSYH4ahseby2waUwk5OaKX/nAsaYgg==",
"dev": true "dev": true
}, },
"err-code": { "err-code": {
...@@ -13757,9 +13735,9 @@ ...@@ -13757,9 +13735,9 @@
} }
}, },
"localforage": { "localforage": {
"version": "1.7.4", "version": "1.8.1",
"resolved": "https://registry.npmjs.org/localforage/-/localforage-1.7.4.tgz", "resolved": "https://registry.npmjs.org/localforage/-/localforage-1.8.1.tgz",
"integrity": "sha512-3EmVZatmNVeCo/t6Te7P06h2alGwbq8wXlSkcSXMvDE2/edPmsVqTPlzGnZaqwZZDBs6v+kxWpqjVsqsNJT8jA==", "integrity": "sha512-azSSJJfc7h4bVpi0PGi+SmLQKJl2/8NErI+LhJsrORNikMZnhaQ7rv9fHj+ofwgSHrKRlsDCL/639a6nECIKuQ==",
"requires": { "requires": {
"lie": "3.1.1" "lie": "3.1.1"
} }
...@@ -13965,9 +13943,9 @@ ...@@ -13965,9 +13943,9 @@
} }
}, },
"macos-release": { "macos-release": {
"version": "2.4.0", "version": "2.4.1",
"resolved": "https://registry.npmjs.org/macos-release/-/macos-release-2.4.0.tgz", "resolved": "https://registry.npmjs.org/macos-release/-/macos-release-2.4.1.tgz",
"integrity": "sha512-ko6deozZYiAkqa/0gmcsz+p4jSy3gY7/ZsCEokPaYd8k+6/aXGkiTgr61+Owup7Sf+xjqW8u2ElhoM9SEcEfuA==", "integrity": "sha512-H/QHeBIN1fIGJX517pvK8IEK53yQOW7YcEI55oYtgjDdoCQQz7eJS94qt5kNrscReEyuD/JcdFCm2XBEcGOITg==",
"dev": true "dev": true
}, },
"make-dir": { "make-dir": {
...@@ -14195,9 +14173,9 @@ ...@@ -14195,9 +14173,9 @@
} }
}, },
"parse-json": { "parse-json": {
"version": "5.0.0", "version": "5.0.1",
"resolved": "https://registry.npmjs.org/parse-json/-/parse-json-5.0.0.tgz", "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-5.0.1.tgz",
"integrity": "sha512-OOY5b7PAEFV0E2Fir1KOkxchnZNCdowAJgQ5NuxjpBKTRP3pQhwkrkxqQjeoKJ+fO7bCpmIZaogI4eZGDMEGOw==", "integrity": "sha512-ztoZ4/DYeXQq4E21v169sC8qWINGpcosGv9XhTDvg9/hWvx/zrFkc9BiWxR58OJLHGk28j5BL0SDLeV2WmFZlQ==",
"dev": true, "dev": true,
"requires": { "requires": {
"@babel/code-frame": "^7.0.0", "@babel/code-frame": "^7.0.0",
...@@ -22874,11 +22852,10 @@ ...@@ -22874,11 +22852,10 @@
} }
}, },
"strophe.js": { "strophe.js": {
"version": "1.3.6", "version": "github:strophe/strophejs#c4a94e59877c06dc2395f4ccbd26f3fee67a4c9f",
"resolved": "https://registry.npmjs.org/strophe.js/-/strophe.js-1.3.6.tgz", "from": "github:strophe/strophejs#c4a94e59877c06dc2395f4ccbd26f3fee67a4c9f",
"integrity": "sha512-kTFdf6ziHqlp2PCr7Z7D/lhO+Hd0FIhzwXXlAIQNOqCWwnnTEor9folIUCVoXgZRMYPQ9BTXI2wBv88RG8mgAA==",
"requires": { "requires": {
"abab": "^2.0.0", "abab": "^2.0.3",
"ws": "^7.0.0", "ws": "^7.0.0",
"xmldom": "^0.1.27" "xmldom": "^0.1.27"
}, },
......
/* global mock */ /* global mock, converse */
describe("A chat room", function () { describe("A chat room", function () {
......
...@@ -599,74 +599,6 @@ window.addEventListener('converse-loaded', () => { ...@@ -599,74 +599,6 @@ window.addEventListener('converse-loaded', () => {
'preventDefault': function () {} 'preventDefault': function () {}
}; };
const OriginalConnection = Strophe.Connection;
function MockConnection (service, options) {
OriginalConnection.call(this, service, options);
Strophe.Bosh.prototype._processRequest = function () {}; // Don't attempt to send out stanzas
const sendIQ = this.sendIQ;
this.IQ_stanzas = [];
this.IQ_ids = [];
this.sendIQ = function (iq, callback, errback) {
if (!_.isElement(iq)) {
iq = iq.nodeTree;
}
this.IQ_stanzas.push(iq);
const id = sendIQ.bind(this)(iq, callback, errback);
this.IQ_ids.push(id);
return id;
}
const send = this.send;
this.sent_stanzas = [];
this.send = function (stanza) {
if (_.isElement(stanza)) {
this.sent_stanzas.push(stanza);
} else {
this.sent_stanzas.push(stanza.nodeTree);
}
return send.apply(this, arguments);
}
this.features = Strophe.xmlHtmlNode(
'<stream:features xmlns:stream="http://etherx.jabber.org/streams" xmlns="jabber:client">'+
'<ver xmlns="urn:xmpp:features:rosterver"/>'+
'<csi xmlns="urn:xmpp:csi:0"/>'+
'<this xmlns="http://jabber.org/protocol/caps" ver="UwBpfJpEt3IoLYfWma/o/p3FFRo=" hash="sha-1" node="http://prosody.im"/>'+
'<bind xmlns="urn:ietf:params:xml:ns:xmpp-bind">'+
'<required/>'+
'</bind>'+
`<sm xmlns='urn:xmpp:sm:3'/>`+
'<session xmlns="urn:ietf:params:xml:ns:xmpp-session">'+
'<optional/>'+
'</session>'+
'</stream:features>').firstChild;
this._proto._connect = () => {
this.connected = true;
this.mock = true;
this.jid = 'romeo@montague.lit/orchard';
this._changeConnectStatus(Strophe.Status.BINDREQUIRED);
};
this.bind = () => {
this.authenticated = true;
this.authenticated = true;
if (!_converse.no_connection_on_bind) {
this._changeConnectStatus(Strophe.Status.CONNECTED);
}
};
this._proto._disconnect = () => this._onDisconnectTimeout();
this._proto._onDisconnectTimeout = _.noop;
}
MockConnection.prototype = Object.create(OriginalConnection.prototype);
Strophe.Connection = MockConnection;
function clearIndexedDB () { function clearIndexedDB () {
const promise = u.getResolveablePromise(); const promise = u.getResolveablePromise();
const db_request = window.indexedDB.open("converse-test-persistent"); const db_request = window.indexedDB.open("converse-test-persistent");
......
/*global mock */ /*global mock, converse */
const Strophe = converse.env.Strophe; const Strophe = converse.env.Strophe;
const $iq = converse.env.$iq; const $iq = converse.env.$iq;
...@@ -56,7 +56,6 @@ describe("The Registration Panel", function () { ...@@ -56,7 +56,6 @@ describe("The Registration Panel", function () {
allow_registration: true }, allow_registration: true },
async function (done, _converse) { async function (done, _converse) {
spyOn(Strophe.Connection.prototype, 'connect');
await u.waitUntil(() => _.get(_converse.chatboxviews.get('controlbox'), 'registerpanel')); await u.waitUntil(() => _.get(_converse.chatboxviews.get('controlbox'), 'registerpanel'));
const toggle = document.querySelector(".toggle-controlbox"); const toggle = document.querySelector(".toggle-controlbox");
...@@ -66,6 +65,7 @@ describe("The Registration Panel", function () { ...@@ -66,6 +65,7 @@ describe("The Registration Panel", function () {
await u.waitUntil(() => u.isVisible(cbview.el)); await u.waitUntil(() => u.isVisible(cbview.el));
const registerview = cbview.registerpanel; const registerview = cbview.registerpanel;
spyOn(registerview, 'onProviderChosen').and.callThrough(); spyOn(registerview, 'onProviderChosen').and.callThrough();
spyOn(registerview, 'fetchRegistrationForm').and.callThrough();
registerview.delegateEvents(); // We need to rebind all events otherwise our spy won't be called registerview.delegateEvents(); // We need to rebind all events otherwise our spy won't be called
// Open the register panel // Open the register panel
...@@ -85,7 +85,8 @@ describe("The Registration Panel", function () { ...@@ -85,7 +85,8 @@ describe("The Registration Panel", function () {
form.querySelector('input[name=domain]').value = 'conversejs.org'; form.querySelector('input[name=domain]').value = 'conversejs.org';
submit_button.click(); submit_button.click();
expect(registerview.onProviderChosen).toHaveBeenCalled(); expect(registerview.onProviderChosen).toHaveBeenCalled();
await u.waitUntil(() => _converse.connection.connect.calls.count()); expect(registerview.fetchRegistrationForm).toHaveBeenCalled();
delete _converse.connection;
done(); done();
})); }));
...@@ -97,12 +98,12 @@ describe("The Registration Panel", function () { ...@@ -97,12 +98,12 @@ describe("The Registration Panel", function () {
allow_registration: true }, allow_registration: true },
async function (done, _converse) { async function (done, _converse) {
spyOn(Strophe.Connection.prototype, 'connect');
await u.waitUntil(() => _.get(_converse.chatboxviews.get('controlbox'), 'registerpanel')); await u.waitUntil(() => _.get(_converse.chatboxviews.get('controlbox'), 'registerpanel'));
const cbview = _converse.api.controlbox.get(); const cbview = _converse.api.controlbox.get();
cbview.el.querySelector('.toggle-register-login').click(); cbview.el.querySelector('.toggle-register-login').click();
const registerview = _converse.chatboxviews.get('controlbox').registerpanel; const registerview = _converse.chatboxviews.get('controlbox').registerpanel;
spyOn(registerview, 'fetchRegistrationForm').and.callThrough();
spyOn(registerview, 'onProviderChosen').and.callThrough(); spyOn(registerview, 'onProviderChosen').and.callThrough();
spyOn(registerview, 'getRegistrationFields').and.callThrough(); spyOn(registerview, 'getRegistrationFields').and.callThrough();
spyOn(registerview, 'onRegistrationFields').and.callThrough(); spyOn(registerview, 'onRegistrationFields').and.callThrough();
...@@ -115,7 +116,7 @@ describe("The Registration Panel", function () { ...@@ -115,7 +116,7 @@ describe("The Registration Panel", function () {
registerview.el.querySelector('input[type=submit]').click(); registerview.el.querySelector('input[type=submit]').click();
expect(registerview.onProviderChosen).toHaveBeenCalled(); expect(registerview.onProviderChosen).toHaveBeenCalled();
expect(registerview._registering).toBeTruthy(); expect(registerview._registering).toBeTruthy();
await u.waitUntil(() => _converse.connection.connect.calls.count()); await u.waitUntil(() => registerview.fetchRegistrationForm.calls.count());
let stanza = new Strophe.Builder("stream:features", { let stanza = new Strophe.Builder("stream:features", {
'xmlns:stream': "http://etherx.jabber.org/streams", 'xmlns:stream': "http://etherx.jabber.org/streams",
...@@ -294,7 +295,6 @@ describe("The Registration Panel", function () { ...@@ -294,7 +295,6 @@ describe("The Registration Panel", function () {
mock.initConverse( mock.initConverse(
['chatBoxesInitialized'], ['chatBoxesInitialized'],
{ auto_login: false, { auto_login: false,
view_mode: 'fullscreen',
discover_connection_methods: false, discover_connection_methods: false,
allow_registration: true }, allow_registration: true },
async function (done, _converse) { async function (done, _converse) {
......
/*global mock */ /*global mock, converse */
const $iq = converse.env.$iq; const $iq = converse.env.$iq;
const $msg = converse.env.$msg; const $msg = converse.env.$msg;
...@@ -23,8 +23,7 @@ describe("XEP-0198 Stream Management", function () { ...@@ -23,8 +23,7 @@ describe("XEP-0198 Stream Management", function () {
await _converse.api.user.login('romeo@montague.lit/orchard', 'secret'); await _converse.api.user.login('romeo@montague.lit/orchard', 'secret');
const sent_stanzas = _converse.connection.sent_stanzas; const sent_stanzas = _converse.connection.sent_stanzas;
let stanza = await u.waitUntil(() => let stanza = await u.waitUntil(() => sent_stanzas.filter(s => (s.tagName === 'enable'), 1000).pop());
sent_stanzas.filter(s => (s.tagName === 'enable')).pop());
expect(_converse.session.get('smacks_enabled')).toBe(false); expect(_converse.session.get('smacks_enabled')).toBe(false);
expect(Strophe.serialize(stanza)).toEqual('<enable resume="true" xmlns="urn:xmpp:sm:3"/>'); expect(Strophe.serialize(stanza)).toEqual('<enable resume="true" xmlns="urn:xmpp:sm:3"/>');
...@@ -33,7 +32,7 @@ describe("XEP-0198 Stream Management", function () { ...@@ -33,7 +32,7 @@ describe("XEP-0198 Stream Management", function () {
_converse.connection._dataRecv(mock.createRequest(result)); _converse.connection._dataRecv(mock.createRequest(result));
expect(_converse.session.get('smacks_enabled')).toBe(true); expect(_converse.session.get('smacks_enabled')).toBe(true);
await u.waitUntil(() => view.renderControlBoxPane.calls.count()); await u.waitUntil(() => view.renderControlBoxPane.calls?.count());
let IQ_stanzas = _converse.connection.IQ_stanzas; let IQ_stanzas = _converse.connection.IQ_stanzas;
await u.waitUntil(() => IQ_stanzas.length === 4); await u.waitUntil(() => IQ_stanzas.length === 4);
...@@ -105,7 +104,7 @@ describe("XEP-0198 Stream Management", function () { ...@@ -105,7 +104,7 @@ describe("XEP-0198 Stream Management", function () {
_converse.connection.IQ_stanzas = []; _converse.connection.IQ_stanzas = [];
IQ_stanzas = _converse.connection.IQ_stanzas; IQ_stanzas = _converse.connection.IQ_stanzas;
await _converse.api.connection.reconnect(); await _converse.api.connection.reconnect();
stanza = await u.waitUntil(() => sent_stanzas.filter(s => (s.tagName === 'resume')).pop()); stanza = await u.waitUntil(() => sent_stanzas.filter(s => (s.tagName === 'resume')).pop(), 1000);
expect(Strophe.serialize(stanza)).toEqual('<resume h="2" previd="some-long-sm-id" xmlns="urn:xmpp:sm:3"/>'); expect(Strophe.serialize(stanza)).toEqual('<resume h="2" previd="some-long-sm-id" xmlns="urn:xmpp:sm:3"/>');
result = u.toStanza(`<resumed xmlns="urn:xmpp:sm:3" h="another-sequence-number" previd="some-long-sm-id"/>`); result = u.toStanza(`<resumed xmlns="urn:xmpp:sm:3" h="another-sequence-number" previd="some-long-sm-id"/>`);
......
...@@ -310,7 +310,9 @@ converse.plugins.add('converse-register', { ...@@ -310,7 +310,9 @@ converse.plugins.add('converse-register', {
'_registering': true '_registering': true
}); });
await _converse.initConnection(this.domain); await _converse.initConnection(this.domain);
_converse.connection.connect(this.domain, "", status => this.onConnectStatusChanged(status)); // When testing, the test tears down before the async function
// above finishes. So we use optional chaining here
_converse.connection?.connect(this.domain, "", status => this.onConnectStatusChanged(status));
return false; return false;
}, },
......
This diff is collapsed.
This diff is collapsed.
...@@ -146,8 +146,8 @@ converse.plugins.add('converse-mam', { ...@@ -146,8 +146,8 @@ converse.plugins.add('converse-mam', {
_converse.onMAMError = function (iq) { _converse.onMAMError = function (iq) {
if (iq && iq.querySelectorAll('feature-not-implemented').length) { if (iq?.querySelectorAll('feature-not-implemented').length) {
log.warn(`Message Archive Management (XEP-0313) not supported by ${iq.getAttribute('from')}`); log.warn(`Message Archive Management (XEP-0313) not supported by ${iq.getAttribute('from')}`);
} else { } else {
log.error(`Error while trying to set archiving preferences for ${iq.getAttribute('from')}.`); log.error(`Error while trying to set archiving preferences for ${iq.getAttribute('from')}.`);
log.error(iq); log.error(iq);
......
...@@ -960,7 +960,7 @@ converse.plugins.add('converse-roster', { ...@@ -960,7 +960,7 @@ converse.plugins.add('converse-roster', {
// When reconnecting and not resuming a previous session, // When reconnecting and not resuming a previous session,
// we clear all cached presence data, since it might be stale // we clear all cached presence data, since it might be stale
// and we'll receive new presence updates // and we'll receive new presence updates
!_converse.haveResumed() && await clearPresences(); !_converse.connection.hasResumed() && await clearPresences();
} else { } else {
_converse.presences = new _converse.Presences(); _converse.presences = new _converse.Presences();
const id = `converse.presences-${_converse.bare_jid}`; const id = `converse.presences-${_converse.bare_jid}`;
......
...@@ -4,38 +4,25 @@ ...@@ -4,38 +4,25 @@
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {
"filesize": { "@converse/skeletor": {
"version": "6.1.0", "version": "github:conversejs/skeletor#b260c554f4ce961c29deea4740083e58a489aa9b",
"resolved": "https://registry.npmjs.org/filesize/-/filesize-6.1.0.tgz", "from": "github:conversejs/skeletor#b260c554f4ce961c29deea4740083e58a489aa9b",
"integrity": "sha512-LpCHtPQ3sFx67z+uh2HnSyWSLLu5Jxo21795uRDuar/EOuYWXib5EmPaGIBuSnRqH2IODiKA2k5re/K9OnN/Yg==",
"dev": true
},
"fs-extra": {
"version": "8.1.0",
"resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-8.1.0.tgz",
"integrity": "sha512-yhlQgA6mnOJUKOsRUFsgJdQCvkKhcz8tlZG5HBQfReYZy46OwLcY+Zia0mtdHsOo9y/hP+CxMN0TU9QxoOtG4g==",
"dev": true, "dev": true,
"requires": { "requires": {
"graceful-fs": "^4.2.0", "lit-html": "^1.2.1",
"jsonfile": "^4.0.0", "lodash-es": "^4.17.14"
"universalify": "^0.1.0"
},
"dependencies": {
"jsonfile": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz",
"integrity": "sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss=",
"dev": true,
"requires": {
"graceful-fs": "^4.1.6"
}
}
} }
}, },
"graceful-fs": { "abab": {
"version": "4.2.3", "version": "2.0.3",
"resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.3.tgz", "resolved": "https://registry.npmjs.org/abab/-/abab-2.0.3.tgz",
"integrity": "sha512-a30VEBm4PEdx1dRB7MFK7BejejvCvBronbLjht+sHuGYj8PHs7M/5Z+rt5lw551vZ7yfTCj4Vuyy3mSJytDWRQ==", "integrity": "sha512-tsFzPpcttalNjFBCFMqsKYQcWxxen1pgJR56by//QwvJc4/OUS3kPOOttx2tSIfjsylB0pYu7f5D3K1RCxUnUg==",
"dev": true
},
"filesize": {
"version": "6.1.0",
"resolved": "https://registry.npmjs.org/filesize/-/filesize-6.1.0.tgz",
"integrity": "sha512-LpCHtPQ3sFx67z+uh2HnSyWSLLu5Jxo21795uRDuar/EOuYWXib5EmPaGIBuSnRqH2IODiKA2k5re/K9OnN/Yg==",
"dev": true "dev": true
}, },
"immediate": { "immediate": {
...@@ -50,16 +37,6 @@ ...@@ -50,16 +37,6 @@
"integrity": "sha1-elSbvZ/+FYWwzQoZHiAwVb7ldLQ=", "integrity": "sha1-elSbvZ/+FYWwzQoZHiAwVb7ldLQ=",
"dev": true "dev": true
}, },
"jsonfile": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-5.0.0.tgz",
"integrity": "sha512-NQRZ5CRo74MhMMC3/3r5g2k4fjodJ/wh8MxjFbCViWKFjxrnudWSY5vomh+23ZaXzAS7J3fBZIR2dV6WbmfM0w==",
"dev": true,
"requires": {
"graceful-fs": "^4.1.6",
"universalify": "^0.1.2"
}
},
"lie": { "lie": {
"version": "3.1.1", "version": "3.1.1",
"resolved": "https://registry.npmjs.org/lie/-/lie-3.1.1.tgz", "resolved": "https://registry.npmjs.org/lie/-/lie-3.1.1.tgz",
...@@ -69,6 +46,12 @@ ...@@ -69,6 +46,12 @@
"immediate": "~3.0.5" "immediate": "~3.0.5"
} }
}, },
"lit-html": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/lit-html/-/lit-html-1.2.1.tgz",
"integrity": "sha512-GSJHHXMGLZDzTRq59IUfL9FCdAlGfqNp/dEa7k7aBaaWD+JKaCjsAk9KYm2V12ItonVaYx2dprN66Zdm1AuBTQ==",
"dev": true
},
"localforage": { "localforage": {
"version": "1.7.3", "version": "1.7.3",
"resolved": "https://registry.npmjs.org/localforage/-/localforage-1.7.3.tgz", "resolved": "https://registry.npmjs.org/localforage/-/localforage-1.7.3.tgz",
...@@ -81,6 +64,7 @@ ...@@ -81,6 +64,7 @@
"lodash": { "lodash": {
"version": "4.17.19", "version": "4.17.19",
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.19.tgz", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.19.tgz",
"integrity": "sha512-JNvd8XER9GQX0v2qJgsaN/mzFCNA5BRe/j8JN9d+tWyGLSodKQHKFicdwNYzWwI3wjRnaKPsGj1XkBjx/F96DQ==",
"dev": true "dev": true
}, },
"lodash-es": { "lodash-es": {
...@@ -95,32 +79,32 @@ ...@@ -95,32 +79,32 @@
"integrity": "sha512-SBt6v6Tbp20Jf8hU0cpcc/+HBHGMY8/Q+yA6Ih0tBQE8tfdZ6U4PRG0iNvUUjLx/hVyOP53n0UfGBymlfaaXCg==", "integrity": "sha512-SBt6v6Tbp20Jf8hU0cpcc/+HBHGMY8/Q+yA6Ih0tBQE8tfdZ6U4PRG0iNvUUjLx/hVyOP53n0UfGBymlfaaXCg==",
"dev": true, "dev": true,
"requires": { "requires": {
"lodash": "^4.17.19" "lodash": "^4.17.11"
} }
}, },
"twemoji": { "strophe.js": {
"version": "12.1.5", "version": "github:strophe/strophejs#c4a94e59877c06dc2395f4ccbd26f3fee67a4c9f",
"resolved": "https://registry.npmjs.org/twemoji/-/twemoji-12.1.5.tgz", "from": "github:strophe/strophejs#c4a94e59877c06dc2395f4ccbd26f3fee67a4c9f",
"integrity": "sha512-B0PBVy5xomwb1M/WZxf/IqPZfnoIYy1skXnlHjMwLwTNfZ9ljh8VgWQktAPcJXu8080WoEh6YwQGPVhDVqvrVQ==",
"dev": true, "dev": true,
"requires": { "requires": {
"fs-extra": "^8.0.1", "abab": "^2.0.3",
"jsonfile": "^5.0.0", "ws": "^7.0.0",
"twemoji-parser": "12.1.3", "xmldom": "^0.1.27"
"universalify": "^0.1.2"
} }
}, },
"twemoji-parser": { "ws": {
"version": "12.1.3", "version": "7.3.1",
"resolved": "https://registry.npmjs.org/twemoji-parser/-/twemoji-parser-12.1.3.tgz", "resolved": "https://registry.npmjs.org/ws/-/ws-7.3.1.tgz",
"integrity": "sha512-ND4LZXF4X92/PFrzSgGkq6KPPg8swy/U0yRw1k/+izWRVmq1HYi3khPwV3XIB6FRudgVICAaBhJfW8e8G3HC7Q==", "integrity": "sha512-D3RuNkynyHmEJIpD2qrgVkc9DQ23OrN/moAwZX4L8DfvszsJxpjQuUq3LMx6HoYji9fbIOBY18XWBsAux1ZZUA==",
"dev": true "dev": true,
"optional": true
}, },
"universalify": { "xmldom": {
"version": "0.1.2", "version": "0.1.31",
"resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz", "resolved": "https://registry.npmjs.org/xmldom/-/xmldom-0.1.31.tgz",
"integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==", "integrity": "sha512-yS2uJflVQs6n+CyjHoaBmVSqIDevTAWrzMmjG1Gc7h1qQ7uVozNhEPJAwZXWyGQ/Gafo3fCwrcaokezLPupVyQ==",
"dev": true "dev": true,
"optional": true
} }
} }
} }
...@@ -42,6 +42,6 @@ ...@@ -42,6 +42,6 @@
"localforage": "^1.7.3", "localforage": "^1.7.3",
"lodash-es": "^4.17.15", "lodash-es": "^4.17.15",
"pluggable.js": "2.0.1", "pluggable.js": "2.0.1",
"strophe.js": "1.3.6" "strophe.js": "strophe/strophejs#c4a94e59877c06dc2395f4ccbd26f3fee67a4c9f"
} }
} }
import { html } from "lit-html"; import { html } from "lit-html";
export default (o) => html`<span class="spinner fa fa-spinner centered ${o.classes || ''}"/>` export default (o={}) => html`<span class="spinner fa fa-spinner centered ${o.classes || ''}"/>`
...@@ -89,7 +89,7 @@ module.exports = { ...@@ -89,7 +89,7 @@ module.exports = {
] ]
}, { }, {
test: /\.js$/, test: /\.js$/,
exclude: /(node_modules|spec|mockup)/, include: /src/,
use: { use: {
loader: 'babel-loader', loader: 'babel-loader',
options: { options: {
......
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
modtools_disable_query: ['moderator', 'participant', 'visitor'], modtools_disable_query: ['moderator', 'participant', 'visitor'],
enable_smacks: true, enable_smacks: true,
i18n: 'en', i18n: 'en',
// connection_options: { 'worker': '/dist/shared-connection-worker.js' },
message_archiving: 'always', message_archiving: 'always',
muc_domain: 'conference.chat.example.org', muc_domain: 'conference.chat.example.org',
muc_respect_autojoin: true, muc_respect_autojoin: true,
......
...@@ -20,6 +20,7 @@ module.exports = merge(common, { ...@@ -20,6 +20,7 @@ module.exports = merge(common, {
new MiniCssExtractPlugin({filename: '../dist/converse.min.css'}), new MiniCssExtractPlugin({filename: '../dist/converse.min.css'}),
new CopyWebpackPlugin({ new CopyWebpackPlugin({
patterns: [ patterns: [
{from: 'src/headless/node_modules/strophe.js/src/shared-connection-worker.js', to: 'shared-connection-worker.js'},
{from: 'sounds', to: 'sounds'}, {from: 'sounds', to: 'sounds'},
{from: 'images/favicon.ico', to: 'images/favicon.ico'}, {from: 'images/favicon.ico', to: 'images/favicon.ico'},
{from: 'images/custom_emojis', to: 'images/custom_emojis'}, {from: 'images/custom_emojis', to: 'images/custom_emojis'},
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment