mirror of
https://github.com/Polymer/polymer.git
synced 2025-02-25 18:55:30 -06:00
Merge pull request #3119 from Polymer/disable-chunked-tests
Disable chunked dom-repeat tests on IE due to CI rAF flakiness.
This commit is contained in:
commit
34bf229e7b
@ -3646,207 +3646,204 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
||||
|
||||
});
|
||||
|
||||
suite('chunked rendering', function() {
|
||||
// TODO(kschaaf): This test suite has proven to be flaky only on IE, only
|
||||
// on CI (Sauce) presumably because of rAF handling in the CI environment
|
||||
// disabling for IE for now to avoid Polymer tests being flaky
|
||||
if (!/Trident/.test(navigator.userAgent)) {
|
||||
|
||||
// Patch requestAnimationFrame to setTimeout to reduce IE test flakiness on CI
|
||||
var rAF;
|
||||
suiteSetup(function() {
|
||||
rAF = window.requestAnimationFrame;
|
||||
window.requestAnimationFrame = setTimeout;
|
||||
});
|
||||
suiteTeardown(function() {
|
||||
window.requestAnimationFrame = rAF;
|
||||
});
|
||||
suite('chunked rendering', function() {
|
||||
|
||||
test('basic chunked rendering', function(done) {
|
||||
test('basic chunked rendering', function(done) {
|
||||
|
||||
var checkItemOrder = function(stamped) {
|
||||
for (var i=0; i<stamped.length; i++) {
|
||||
assert.equal(stamped[i].textContent, i);
|
||||
}
|
||||
};
|
||||
|
||||
var lastLength = 0;
|
||||
var checkCount = function() {
|
||||
var stamped = Polymer.dom(chunked.root).querySelectorAll('*:not(template)');
|
||||
checkItemOrder(stamped);
|
||||
if (stamped.length && lastLength === 0) {
|
||||
// Initial rendering of initial count
|
||||
assert.equal(stamped.length, 10);
|
||||
} else {
|
||||
// Remaining rendering incremenets
|
||||
assert.isTrue(stamped.length > lastLength);
|
||||
}
|
||||
if (stamped.length < 100) {
|
||||
lastLength = stamped.length;
|
||||
checkUntilComplete();
|
||||
} else {
|
||||
// Final rendering at exact item count
|
||||
assert.equal(stamped.length, 100);
|
||||
done();
|
||||
}
|
||||
};
|
||||
var checkUntilComplete = function() {
|
||||
// On polyfilled MO, need to wait one setTimeout before rAF
|
||||
if (MutationObserver._isPolyfilled) {
|
||||
setTimeout(function() {
|
||||
requestAnimationFrame(checkCount);
|
||||
});
|
||||
} else {
|
||||
requestAnimationFrame(checkCount);
|
||||
}
|
||||
};
|
||||
|
||||
chunked.items = chunked.preppedItems.slice();
|
||||
checkUntilComplete();
|
||||
|
||||
});
|
||||
|
||||
test('mutations during chunked rendering', function(done) {
|
||||
|
||||
var checkItemOrder = function(stamped) {
|
||||
var last = -1;
|
||||
for (var i=0; i<stamped.length; i++) {
|
||||
var curr = parseFloat(stamped[i].textContent);
|
||||
assert.isTrue(curr > last);
|
||||
last = curr;
|
||||
}
|
||||
};
|
||||
|
||||
var mutateArray = function(repeater, renderedCount) {
|
||||
// The goal here is to remove & add some, and do it over
|
||||
// the threshold of where we have currently rendered items, and
|
||||
// ensure that the prop values of the newly inserted items are in
|
||||
// ascending order so we can do a simple check in checkItemOrder
|
||||
var overlap = 2;
|
||||
var remove = 4;
|
||||
var add = 6;
|
||||
var start = renderedCount.length - overlap;
|
||||
if (start + add < repeater.items.length) {
|
||||
var end = start + remove;
|
||||
var args = ['items', start, remove];
|
||||
var startVal = repeater.items[start].prop;
|
||||
var endVal = repeater.items[end].prop;
|
||||
var delta = (endVal - startVal) / add;
|
||||
for (var i=0; i<add; i++) {
|
||||
args.push({prop: startVal + i*delta});
|
||||
var checkItemOrder = function(stamped) {
|
||||
for (var i=0; i<stamped.length; i++) {
|
||||
assert.equal(stamped[i].textContent, i);
|
||||
}
|
||||
repeater.splice.apply(repeater, args);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
var lastLength = 0;
|
||||
var mutateCount = 5;
|
||||
var checkCount = function() {
|
||||
var stamped = Polymer.dom(chunked.root).querySelectorAll('*:not(template)');
|
||||
checkItemOrder(stamped);
|
||||
if (stamped.length && lastLength === 0) {
|
||||
// Initial rendering of initial count
|
||||
assert.equal(stamped.length, 10);
|
||||
} else {
|
||||
// Remaining rendering incremenets
|
||||
assert.isTrue(stamped.length > lastLength);
|
||||
}
|
||||
if (stamped.length < chunked.items.length) {
|
||||
if (mutateCount-- > 0) {
|
||||
mutateArray(chunked, stamped);
|
||||
}
|
||||
lastLength = stamped.length;
|
||||
checkUntilComplete();
|
||||
} else {
|
||||
// Final rendering at exact item count
|
||||
assert.equal(stamped.length, chunked.items.length);
|
||||
done();
|
||||
}
|
||||
};
|
||||
var checkUntilComplete = function() {
|
||||
// On polyfilled MO, need to wait one setTimeout before rAF
|
||||
if (MutationObserver._isPolyfilled) {
|
||||
setTimeout(function() {
|
||||
requestAnimationFrame(checkCount);
|
||||
});
|
||||
} else {
|
||||
requestAnimationFrame(checkCount);
|
||||
}
|
||||
};
|
||||
|
||||
chunked.items = chunked.preppedItems.slice();
|
||||
checkUntilComplete();
|
||||
|
||||
});
|
||||
|
||||
|
||||
test('mutations during chunked rendering, sort & filtered', function(done) {
|
||||
|
||||
var checkItemOrder = function(stamped) {
|
||||
var last = Infinity;
|
||||
for (var i=0; i<stamped.length; i++) {
|
||||
var curr = parseFloat(stamped[i].textContent);
|
||||
assert.isTrue(curr <= last);
|
||||
assert.strictEqual(curr % 2, 0);
|
||||
last = curr;
|
||||
}
|
||||
};
|
||||
|
||||
var mutateArray = function(repeater, stamped) {
|
||||
var start = parseInt(stamped[0].textContent);
|
||||
var end = parseInt(stamped[stamped.length-1].textContent);
|
||||
var mid = (end-start)/2;
|
||||
for (var i=0; i<5; i++) {
|
||||
chunked.push('items', {prop: mid + 1});
|
||||
}
|
||||
chunked.splice('items', Math.round(stamped.length/2), 3);
|
||||
};
|
||||
|
||||
var lastLength = 0;
|
||||
var mutateCount = 5;
|
||||
var checkCount = function() {
|
||||
var stamped = Polymer.dom(chunked.root).querySelectorAll('*:not(template)');
|
||||
checkItemOrder(stamped);
|
||||
var filteredLength = chunked.items.filter(chunked.$.repeater.filter).length;
|
||||
if (stamped.length && lastLength === 0) {
|
||||
// Initial rendering of initial count
|
||||
assert.equal(stamped.length, 10);
|
||||
} else {
|
||||
// Remaining rendering incremenets
|
||||
if (stamped.length < filteredLength) {
|
||||
var lastLength = 0;
|
||||
var checkCount = function() {
|
||||
var stamped = Polymer.dom(chunked.root).querySelectorAll('*:not(template)');
|
||||
checkItemOrder(stamped);
|
||||
if (stamped.length && lastLength === 0) {
|
||||
// Initial rendering of initial count
|
||||
assert.equal(stamped.length, 10);
|
||||
} else {
|
||||
// Remaining rendering incremenets
|
||||
assert.isTrue(stamped.length > lastLength);
|
||||
}
|
||||
}
|
||||
if (stamped.length < filteredLength) {
|
||||
if (mutateCount-- > 0) {
|
||||
mutateArray(chunked, stamped);
|
||||
if (stamped.length < 100) {
|
||||
lastLength = stamped.length;
|
||||
checkUntilComplete();
|
||||
} else {
|
||||
// Final rendering at exact item count
|
||||
assert.equal(stamped.length, 100);
|
||||
done();
|
||||
}
|
||||
lastLength = stamped.length;
|
||||
checkUntilComplete();
|
||||
} else {
|
||||
assert.equal(stamped.length, filteredLength);
|
||||
done();
|
||||
}
|
||||
};
|
||||
var checkUntilComplete = function() {
|
||||
// On polyfilled MO, need to wait one setTimeout before rAF
|
||||
if (MutationObserver._isPolyfilled) {
|
||||
setTimeout(function() {
|
||||
};
|
||||
var checkUntilComplete = function() {
|
||||
// On polyfilled MO, need to wait one setTimeout before rAF
|
||||
if (MutationObserver._isPolyfilled) {
|
||||
setTimeout(function() {
|
||||
requestAnimationFrame(checkCount);
|
||||
});
|
||||
} else {
|
||||
requestAnimationFrame(checkCount);
|
||||
});
|
||||
} else {
|
||||
requestAnimationFrame(checkCount);
|
||||
}
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
chunked.$.repeater.sort = function(a, b) {
|
||||
return b.prop - a.prop;
|
||||
};
|
||||
chunked.$.repeater.filter = function(a) {
|
||||
return (a.prop % 2) === 0;
|
||||
};
|
||||
chunked.items = chunked.preppedItems.slice();
|
||||
checkUntilComplete();
|
||||
chunked.items = chunked.preppedItems.slice();
|
||||
checkUntilComplete();
|
||||
|
||||
});
|
||||
|
||||
test('mutations during chunked rendering', function(done) {
|
||||
|
||||
var checkItemOrder = function(stamped) {
|
||||
var last = -1;
|
||||
for (var i=0; i<stamped.length; i++) {
|
||||
var curr = parseFloat(stamped[i].textContent);
|
||||
assert.isTrue(curr > last);
|
||||
last = curr;
|
||||
}
|
||||
};
|
||||
|
||||
var mutateArray = function(repeater, renderedCount) {
|
||||
// The goal here is to remove & add some, and do it over
|
||||
// the threshold of where we have currently rendered items, and
|
||||
// ensure that the prop values of the newly inserted items are in
|
||||
// ascending order so we can do a simple check in checkItemOrder
|
||||
var overlap = 2;
|
||||
var remove = 4;
|
||||
var add = 6;
|
||||
var start = renderedCount.length - overlap;
|
||||
if (start + add < repeater.items.length) {
|
||||
var end = start + remove;
|
||||
var args = ['items', start, remove];
|
||||
var startVal = repeater.items[start].prop;
|
||||
var endVal = repeater.items[end].prop;
|
||||
var delta = (endVal - startVal) / add;
|
||||
for (var i=0; i<add; i++) {
|
||||
args.push({prop: startVal + i*delta});
|
||||
}
|
||||
repeater.splice.apply(repeater, args);
|
||||
}
|
||||
};
|
||||
|
||||
var lastLength = 0;
|
||||
var mutateCount = 5;
|
||||
var checkCount = function() {
|
||||
var stamped = Polymer.dom(chunked.root).querySelectorAll('*:not(template)');
|
||||
checkItemOrder(stamped);
|
||||
if (stamped.length && lastLength === 0) {
|
||||
// Initial rendering of initial count
|
||||
assert.equal(stamped.length, 10);
|
||||
} else {
|
||||
// Remaining rendering incremenets
|
||||
assert.isTrue(stamped.length > lastLength);
|
||||
}
|
||||
if (stamped.length < chunked.items.length) {
|
||||
if (mutateCount-- > 0) {
|
||||
mutateArray(chunked, stamped);
|
||||
}
|
||||
lastLength = stamped.length;
|
||||
checkUntilComplete();
|
||||
} else {
|
||||
// Final rendering at exact item count
|
||||
assert.equal(stamped.length, chunked.items.length);
|
||||
done();
|
||||
}
|
||||
};
|
||||
var checkUntilComplete = function() {
|
||||
// On polyfilled MO, need to wait one setTimeout before rAF
|
||||
if (MutationObserver._isPolyfilled) {
|
||||
setTimeout(function() {
|
||||
requestAnimationFrame(checkCount);
|
||||
});
|
||||
} else {
|
||||
requestAnimationFrame(checkCount);
|
||||
}
|
||||
};
|
||||
|
||||
chunked.items = chunked.preppedItems.slice();
|
||||
checkUntilComplete();
|
||||
|
||||
});
|
||||
|
||||
|
||||
test('mutations during chunked rendering, sort & filtered', function(done) {
|
||||
|
||||
var checkItemOrder = function(stamped) {
|
||||
var last = Infinity;
|
||||
for (var i=0; i<stamped.length; i++) {
|
||||
var curr = parseFloat(stamped[i].textContent);
|
||||
assert.isTrue(curr <= last);
|
||||
assert.strictEqual(curr % 2, 0);
|
||||
last = curr;
|
||||
}
|
||||
};
|
||||
|
||||
var mutateArray = function(repeater, stamped) {
|
||||
var start = parseInt(stamped[0].textContent);
|
||||
var end = parseInt(stamped[stamped.length-1].textContent);
|
||||
var mid = (end-start)/2;
|
||||
for (var i=0; i<5; i++) {
|
||||
chunked.push('items', {prop: mid + 1});
|
||||
}
|
||||
chunked.splice('items', Math.round(stamped.length/2), 3);
|
||||
};
|
||||
|
||||
var lastLength = 0;
|
||||
var mutateCount = 5;
|
||||
var checkCount = function() {
|
||||
var stamped = Polymer.dom(chunked.root).querySelectorAll('*:not(template)');
|
||||
checkItemOrder(stamped);
|
||||
var filteredLength = chunked.items.filter(chunked.$.repeater.filter).length;
|
||||
if (stamped.length && lastLength === 0) {
|
||||
// Initial rendering of initial count
|
||||
assert.equal(stamped.length, 10);
|
||||
} else {
|
||||
// Remaining rendering incremenets
|
||||
if (stamped.length < filteredLength) {
|
||||
assert.isTrue(stamped.length > lastLength);
|
||||
}
|
||||
}
|
||||
if (stamped.length < filteredLength) {
|
||||
if (mutateCount-- > 0) {
|
||||
mutateArray(chunked, stamped);
|
||||
}
|
||||
lastLength = stamped.length;
|
||||
checkUntilComplete();
|
||||
} else {
|
||||
assert.equal(stamped.length, filteredLength);
|
||||
done();
|
||||
}
|
||||
};
|
||||
var checkUntilComplete = function() {
|
||||
// On polyfilled MO, need to wait one setTimeout before rAF
|
||||
if (MutationObserver._isPolyfilled) {
|
||||
setTimeout(function() {
|
||||
requestAnimationFrame(checkCount);
|
||||
});
|
||||
} else {
|
||||
requestAnimationFrame(checkCount);
|
||||
}
|
||||
};
|
||||
|
||||
chunked.$.repeater.sort = function(a, b) {
|
||||
return b.prop - a.prop;
|
||||
};
|
||||
chunked.$.repeater.filter = function(a) {
|
||||
return (a.prop % 2) === 0;
|
||||
};
|
||||
chunked.items = chunked.preppedItems.slice();
|
||||
checkUntilComplete();
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user