2013-07-14 20:46:12 +00:00
|
|
|
// Test for https://github.com/ether/etherpad-lite/issues/1763
|
|
|
|
|
|
|
|
// This test fails in Opera, IE and Safari
|
|
|
|
// Opera fails due to a weird way of handling the order of execution, yet actual performance seems fine
|
|
|
|
// Safari fails due the delay being too great yet the actual performance seems fine
|
|
|
|
// Firefox might panic that the script is taking too long so will fail
|
|
|
|
// IE will fail due to running out of memory as it can't fit 2M chars in memory.
|
|
|
|
|
|
|
|
// Just FYI Google Docs crashes on large docs whilst trying to Save, it's likely the limitations we are
|
|
|
|
// experiencing are more to do with browser limitations than improper implementation.
|
|
|
|
// A ueber fix for this would be to have a separate lower cpu priority thread that handles operations that aren't
|
|
|
|
// visible to the user.
|
|
|
|
|
|
|
|
// Adapted from John McLear's original test case.
|
|
|
|
|
2020-11-23 18:21:51 +00:00
|
|
|
xdescribe('Responsiveness of Editor', function () {
|
2013-07-14 20:46:12 +00:00
|
|
|
// create a new pad before each test run
|
2020-11-23 18:21:51 +00:00
|
|
|
beforeEach(function (cb) {
|
2013-07-14 20:46:12 +00:00
|
|
|
helper.newPad(cb);
|
|
|
|
this.timeout(6000);
|
|
|
|
});
|
2020-09-08 14:18:19 +00:00
|
|
|
// JM commented out on 8th Sep 2020 for a release, after release this needs uncommenting
|
|
|
|
// And the test needs to be fixed to work in Firefox 52 on Windows 7. I am not sure why it fails on this specific platform
|
|
|
|
// The errors show this.timeout... then crash the browser but I am sure something is actually causing the stack trace and
|
|
|
|
// I just need to narrow down what, offers to help accepted.
|
2020-11-23 18:21:51 +00:00
|
|
|
it('Fast response to keypress in pad with large amount of contents', function (done) {
|
|
|
|
// skip on Windows Firefox 52.0
|
|
|
|
if (window.bowser && window.bowser.windows && window.bowser.firefox && window.bowser.version == '52.0') {
|
2020-09-09 20:40:53 +00:00
|
|
|
this.skip();
|
|
|
|
}
|
2020-11-23 18:21:51 +00:00
|
|
|
const inner$ = helper.padInner$;
|
|
|
|
const chrome$ = helper.padChrome$;
|
|
|
|
const chars = '0000000000'; // row of placeholder chars
|
|
|
|
const amount = 200000; // number of blocks of chars we will insert
|
|
|
|
const length = (amount * (chars.length) + 1); // include a counter for each space
|
|
|
|
let text = ''; // the text we're gonna insert
|
2020-09-26 20:57:21 +00:00
|
|
|
this.timeout(amount * 150); // Changed from 100 to 150 to allow Mac OSX Safari to be slow.
|
2013-07-14 20:46:12 +00:00
|
|
|
|
|
|
|
// get keys to send
|
2020-11-23 18:21:51 +00:00
|
|
|
const keyMultiplier = 10; // multiplier * 10 == total number of key events
|
|
|
|
let keysToSend = '';
|
|
|
|
for (var i = 0; i <= keyMultiplier; i++) {
|
2013-07-14 20:46:12 +00:00
|
|
|
keysToSend += chars;
|
|
|
|
}
|
|
|
|
|
2020-11-23 18:21:51 +00:00
|
|
|
const textElement = inner$('div');
|
2013-07-14 20:46:12 +00:00
|
|
|
textElement.sendkeys('{selectall}'); // select all
|
|
|
|
textElement.sendkeys('{del}'); // clear the pad text
|
|
|
|
|
2020-11-23 18:21:51 +00:00
|
|
|
for (var i = 0; i <= amount; i++) {
|
|
|
|
text = `${text + chars} `; // add the chars and space to the text contents
|
2013-07-14 20:46:12 +00:00
|
|
|
}
|
|
|
|
inner$('div').first().text(text); // Put the text contents into the pad
|
|
|
|
|
2020-11-23 18:21:51 +00:00
|
|
|
helper.waitFor(() => // Wait for the new contents to be on the pad
|
2020-11-25 06:11:47 +00:00
|
|
|
inner$('div').text().length > length
|
2020-11-23 18:21:51 +00:00
|
|
|
).done(() => {
|
|
|
|
expect(inner$('div').text().length).to.be.greaterThan(length); // has the text changed?
|
|
|
|
const start = Date.now(); // get the start time
|
2013-07-14 20:46:12 +00:00
|
|
|
|
|
|
|
// send some new text to the screen (ensure all 3 key events are sent)
|
2020-11-23 18:21:51 +00:00
|
|
|
const el = inner$('div').first();
|
|
|
|
for (let i = 0; i < keysToSend.length; ++i) {
|
2013-07-14 20:46:12 +00:00
|
|
|
var x = keysToSend.charCodeAt(i);
|
2020-11-23 18:21:51 +00:00
|
|
|
['keyup', 'keypress', 'keydown'].forEach((type) => {
|
|
|
|
const e = $.Event(type);
|
2013-07-14 20:46:12 +00:00
|
|
|
e.keyCode = x;
|
|
|
|
el.trigger(e);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2020-11-23 18:21:51 +00:00
|
|
|
helper.waitFor(() => { // Wait for the ability to process
|
|
|
|
const el = inner$('body');
|
|
|
|
if (el[0].textContent.length > amount) return true;
|
|
|
|
}).done(() => {
|
|
|
|
const end = Date.now(); // get the current time
|
|
|
|
const delay = end - start; // get the delay as the current time minus the start time
|
2013-07-14 20:46:12 +00:00
|
|
|
|
2020-09-27 14:13:55 +00:00
|
|
|
expect(delay).to.be.below(600);
|
2013-07-14 20:46:12 +00:00
|
|
|
done();
|
2020-09-27 14:13:55 +00:00
|
|
|
}, 5000);
|
2013-07-14 20:46:12 +00:00
|
|
|
}, 10000);
|
|
|
|
});
|
|
|
|
});
|